applyAccountName applies a name to the given account based on its identity. If the account name is empty, it fetches the identity and sets the account name based on the identity type (organization or individual). Parameters: - account *model.Account: A pointer to the Account model to which the name
(account *model.Account)
| 81 | // Returns: |
| 82 | // - error: An error if the identity could not be retrieved. |
| 83 | func (l *LedgerForge) applyAccountName(account *model.Account) error { |
| 84 | if account.Name == "" { |
| 85 | |
| 86 | identity, err := l.GetIdentity(account.IdentityID) |
| 87 | if err != nil { |
| 88 | return err |
| 89 | } |
| 90 | if identity.IdentityType == "organization" { |
| 91 | account.Name = identity.OrganizationName |
| 92 | } else { |
| 93 | account.Name = fmt.Sprintf("%s %s", identity.FirstName, identity.LastName) |
| 94 | } |
| 95 | } |
| 96 | return nil |
| 97 | } |
| 98 | |
| 99 | // overrideLedgerAndIdentity overrides the ledger and identity details of the given account |
| 100 | // based on the balance information. It fetches the balance by its ID and updates the account |
no test coverage detected