code refactor
This commit is contained in:
@@ -599,6 +599,11 @@ func (s *TransactionService) ModifyTransaction(c core.Context, transaction *mode
|
||||
return errs.ErrTransactionSourceAndDestinationAmountNotEqual
|
||||
}
|
||||
|
||||
if (transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_OUT || transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN) &&
|
||||
(transaction.Amount < 0 || transaction.RelatedAccountAmount < 0) {
|
||||
return errs.ErrTransferTransactionAmountCannotBeLessThanZero
|
||||
}
|
||||
|
||||
oldSourceAccount, oldDestinationAccount, err := s.getOldAccountModels(sess, transaction, oldTransaction, sourceAccount, destinationAccount)
|
||||
|
||||
if err != nil {
|
||||
@@ -1566,6 +1571,11 @@ func (s *TransactionService) doCreateTransaction(sess *xorm.Session, transaction
|
||||
return errs.ErrTransactionSourceAndDestinationAmountNotEqual
|
||||
}
|
||||
|
||||
if (transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_OUT || transaction.Type == models.TRANSACTION_DB_TYPE_TRANSFER_IN) &&
|
||||
(transaction.Amount < 0 || transaction.RelatedAccountAmount < 0) {
|
||||
return errs.ErrTransferTransactionAmountCannotBeLessThanZero
|
||||
}
|
||||
|
||||
// Get and verify category
|
||||
err = s.isCategoryValid(sess, transaction)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user