mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 01:34:24 +08:00
fix some fields in transfer-out transaction does not be modified when modifying transfer-in transaction
This commit is contained in:
@@ -593,7 +593,8 @@ func (s *TransactionService) ModifyTransaction(transaction *models.Transaction,
|
|||||||
return errs.ErrTooMuchTransactionInOneSecond
|
return errs.ErrTooMuchTransactionInOneSecond
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedRows, err := sess.ID(relatedTransaction.TransactionId).Cols(updateCols...).Where("uid=? AND deleted=?", relatedTransaction.Uid, false).Update(relatedTransaction)
|
relatedUpdateCols := s.getRelatedUpdateColumns(updateCols)
|
||||||
|
updatedRows, err := sess.ID(relatedTransaction.TransactionId).Cols(relatedUpdateCols...).Where("uid=? AND deleted=?", relatedTransaction.Uid, false).Update(relatedTransaction)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -1050,6 +1051,26 @@ func (s *TransactionService) getOldAccountModels(sess *xorm.Session, transaction
|
|||||||
return oldSourceAccount, oldDestinationAccount, nil
|
return oldSourceAccount, oldDestinationAccount, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *TransactionService) getRelatedUpdateColumns(updateCols []string) []string {
|
||||||
|
relatedUpdateCols := make([]string, len(updateCols))
|
||||||
|
|
||||||
|
for i := 0; i < len(updateCols); i++ {
|
||||||
|
if updateCols[i] == "account_id" {
|
||||||
|
relatedUpdateCols[i] = "related_account_id"
|
||||||
|
} else if updateCols[i] == "related_account_id" {
|
||||||
|
relatedUpdateCols[i] = "account_id"
|
||||||
|
} else if updateCols[i] == "amount" {
|
||||||
|
relatedUpdateCols[i] = "related_account_amount"
|
||||||
|
} else if updateCols[i] == "related_account_amount" {
|
||||||
|
relatedUpdateCols[i] = "amount"
|
||||||
|
} else {
|
||||||
|
relatedUpdateCols[i] = updateCols[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return relatedUpdateCols
|
||||||
|
}
|
||||||
|
|
||||||
func (s *TransactionService) isCategoryValid(sess *xorm.Session, transaction *models.Transaction) error {
|
func (s *TransactionService) isCategoryValid(sess *xorm.Session, transaction *models.Transaction) error {
|
||||||
if transaction.Type == models.TRANSACTION_DB_TYPE_MODIFY_BALANCE {
|
if transaction.Type == models.TRANSACTION_DB_TYPE_MODIFY_BALANCE {
|
||||||
if transaction.CategoryId != 0 {
|
if transaction.CategoryId != 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user