CreateAccount creates a new account in the database. It overrides the ledger and identity details, applies the account name, and fetches external account details. Parameters: - account model.Account: The Account model to be created. Returns: - model.Account: The created Account model. - error: An
(account model.Account)
| 135 | // - model.Account: The created Account model. |
| 136 | // - error: An error if the account could not be created. |
| 137 | func (l *LedgerForge) CreateAccount(account model.Account) (model.Account, error) { |
| 138 | err := l.overrideLedgerAndIdentity(&account) |
| 139 | if err != nil { |
| 140 | return model.Account{}, err |
| 141 | } |
| 142 | |
| 143 | err = l.applyAccountName(&account) |
| 144 | if err != nil { |
| 145 | return model.Account{}, err |
| 146 | } |
| 147 | |
| 148 | err = applyExternalAccount(&account) |
| 149 | if err != nil { |
| 150 | return model.Account{}, err |
| 151 | } |
| 152 | return l.datasource.CreateAccount(account) |
| 153 | } |
| 154 | |
| 155 | // GetAccount retrieves an account by its ID. |
| 156 | // It fetches the account from the datasource and includes additional data as specified. |