From 994f623f2306692434a76c65c4f5458e2dbb655f Mon Sep 17 00:00:00 2001 From: qowevisa Date: Thu, 28 Nov 2024 13:40:10 +0200 Subject: [PATCH] Rename ERROR_EXPENSE_INVALID_USERID -> ERROR_EXPENSE_INVALID_CARD_USERID --- db/expense.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/expense.go b/db/expense.go index 2c8e7f2..172c524 100644 --- a/db/expense.go +++ b/db/expense.go @@ -99,7 +99,7 @@ func (e *Expense) SetUserID(id uint) { } var ( - ERROR_EXPENSE_INVALID_USERID = errors.New("Expense's `UserID` and Card's `UserID` are not equal") + ERROR_EXPENSE_INVALID_CARD_USERID = errors.New("Expense's `UserID` and Card's `UserID` are not equal") ERROR_EXPENSE_CARD_INSUFFICIENT_BALANCE = errors.New("Card's `Balance` is lower than Expense's Value") ERROR_EXPENSE_INVALID_TYPE_USERID = errors.New("Expense's `UserID` and Type's `UserID` are not equal") ) @@ -110,7 +110,7 @@ func (e *Expense) BeforeCreate(tx *gorm.DB) error { return err } if card.UserID != e.UserID { - return ERROR_EXPENSE_INVALID_USERID + return ERROR_EXPENSE_INVALID_CARD_USERID } if card.Balance < e.Value { return ERROR_EXPENSE_CARD_INSUFFICIENT_BALANCE @@ -141,7 +141,7 @@ func (e *Expense) BeforeUpdate(tx *gorm.DB) (err error) { return err } if oldCard.UserID != e.UserID { - return ERROR_EXPENSE_INVALID_USERID + return ERROR_EXPENSE_INVALID_CARD_USERID } oldCard.Balance += original.Value if err := tx.Save(oldCard).Error; err != nil { @@ -155,7 +155,7 @@ func (e *Expense) BeforeUpdate(tx *gorm.DB) (err error) { return err } if newCard.UserID != e.UserID { - return ERROR_EXPENSE_INVALID_USERID + return ERROR_EXPENSE_INVALID_CARD_USERID } if newCard.Balance < e.Value { return ERROR_EXPENSE_CARD_INSUFFICIENT_BALANCE @@ -181,7 +181,7 @@ func (e *Expense) AfterDelete(tx *gorm.DB) (err error) { return err } if card.UserID != e.UserID { - return ERROR_EXPENSE_INVALID_USERID + return ERROR_EXPENSE_INVALID_CARD_USERID } card.Balance += e.Value if err := tx.Save(card).Error; err != nil {