Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -101,15 +101,19 @@ func GetAccounts(ctx context.Context) ([]models.Account, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(acc.AccountCode) >= 4 {
|
||||
acc.DisplayCode =
|
||||
strings.TrimSpace(acc.AccountCode[:3] + " " + acc.AccountCode[3:])
|
||||
} else {
|
||||
acc.DisplayCode = acc.AccountCode
|
||||
}
|
||||
acc.DisplayCode = formatAccountDisplayCode(acc.AccountCode)
|
||||
|
||||
accounts = append(accounts, acc)
|
||||
}
|
||||
|
||||
return accounts, rows.Err()
|
||||
}
|
||||
|
||||
func formatAccountDisplayCode(code string) string {
|
||||
trimmed := strings.TrimSpace(code)
|
||||
runes := []rune(trimmed)
|
||||
if len(runes) <= 3 {
|
||||
return trimmed
|
||||
}
|
||||
return strings.TrimSpace(string(runes[:3]) + " " + string(runes[3:]))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user