1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-02 20:28:38 -04:00

Ensure default currency isn't modified to be a non-currency

This commit is contained in:
2017-06-21 21:53:01 -04:00
parent 4e73e8b508
commit a42e051f74
4 changed files with 43 additions and 6 deletions

View File

@ -148,6 +148,15 @@ func UpdateSecurity(s *Security) error {
return err
}
user, err := GetUserTx(transaction, s.UserId)
if err != nil {
transaction.Rollback()
return err
} else if user.DefaultCurrency == s.SecurityId && s.Type != Currency {
transaction.Rollback()
return errors.New("Cannot change security which is user's default currency to be non-currency")
}
count, err := transaction.Update(s)
if err != nil {
transaction.Rollback()