Merge pull request #15 from pnagurny/bug/create-account-parent

fix issue #13
This commit is contained in:
Patrick Nagurny
2020-01-15 11:23:04 -05:00
committed by GitHub

View File

@@ -43,6 +43,17 @@ func (model *Model) CreateAccount(account *types.Account, userId string) (err er
return errors.New("currency required") return errors.New("currency required")
} }
// don't allow setting parent that has transactions
count, err := model.db.GetSplitCountByAccountId(account.Parent)
if err != nil {
return
}
if count != 0 {
return errors.New("cannot set parent to account with transactions")
}
userAccounts, err := model.GetAccounts(account.OrgId, userId, "") userAccounts, err := model.GetAccounts(account.OrgId, userId, "")
if err != nil { if err != nil {