not allow to add / modify / delete transaction with parent account
This commit is contained in:
@@ -267,6 +267,10 @@ func (s *TransactionService) CreateTransaction(c *core.Context, transaction *mod
|
||||
return errs.ErrCannotAddTransactionToHiddenAccount
|
||||
}
|
||||
|
||||
if sourceAccount.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS || (destinationAccount != nil && destinationAccount.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS) {
|
||||
return errs.ErrCannotAddTransactionToParentAccount
|
||||
}
|
||||
|
||||
if (transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_OUT || transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN) &&
|
||||
sourceAccount.Currency == destinationAccount.Currency && transaction.Amount != transaction.RelatedAccountAmount {
|
||||
return errs.ErrTransactionSourceAndDestinationAmountNotEqual
|
||||
@@ -492,6 +496,10 @@ func (s *TransactionService) ModifyTransaction(c *core.Context, transaction *mod
|
||||
return errs.ErrCannotModifyTransactionInHiddenAccount
|
||||
}
|
||||
|
||||
if sourceAccount.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS || (destinationAccount != nil && destinationAccount.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS) {
|
||||
return errs.ErrCannotModifyTransactionInParentAccount
|
||||
}
|
||||
|
||||
if (transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_OUT || transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN) &&
|
||||
sourceAccount.Currency == destinationAccount.Currency && transaction.Amount != transaction.RelatedAccountAmount {
|
||||
return errs.ErrTransactionSourceAndDestinationAmountNotEqual
|
||||
@@ -852,6 +860,10 @@ func (s *TransactionService) DeleteTransaction(c *core.Context, uid int64, trans
|
||||
return errs.ErrCannotDeleteTransactionInHiddenAccount
|
||||
}
|
||||
|
||||
if sourceAccount.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS || (destinationAccount != nil && destinationAccount.Type == models.ACCOUNT_TYPE_MULTI_SUB_ACCOUNTS) {
|
||||
return errs.ErrCannotDeleteTransactionInParentAccount
|
||||
}
|
||||
|
||||
// Update transaction row to deleted
|
||||
deletedRows, err := sess.ID(oldTransaction.TransactionId).Cols("deleted", "deleted_unix_time").Where("uid=? AND deleted=?", uid, false).Update(updateModel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user