Skip to content

Commit

Permalink
return early if amount entered is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
JuzerShakir committed Nov 10, 2023
1 parent 1dface5 commit 109238e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 109238e

Please sign in to comment.