diff --git a/app/models/transaction.rb b/app/models/transaction.rb index f506dbda..91d8d5fb 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -38,8 +38,8 @@ def should_generate_new_friendly_id? # * Custom Validations def amount_to_be_less_than_balance - balance = persisted? ? amount_was + thaali.balance : thaali.balance return if amount.nil? + balance = persisted? ? amount_was + thaali.balance : thaali.balance if amount > balance errors.add(:amount, "cannot be greater than the balance")