This commit is contained in:
Patrick Nagurny
2020-01-15 11:21:23 -05:00
parent 45fc45736d
commit 122449f8fc

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 {