MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / applyAccountName

Method applyAccountName

account.go:83–97  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

81// Returns:
82// - error: An error if the identity could not be retrieved.
83func (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

Callers 1

CreateAccountMethod · 0.95

Calls 1

GetIdentityMethod · 0.95

Tested by

no test coverage detected