add withdrawl and deposit to FiatBalance and Balance

This commit is contained in:
João Geonizeli
2021-08-15 01:02:39 -03:00
parent c1129b9953
commit 4b1341677f
11 changed files with 170 additions and 30 deletions

View File

@@ -24,7 +24,17 @@ class FiatBalance < ApplicationRecord
monetize :amount_cents
validates :amount_cents, numericality: { greater_than_or_equal_to: 0 }
def amount_formatted
amount.format
end
def withdrawal!(value)
update!(amount_cents: amount_cents - value)
end
def deposit!(value)
update!(amount_cents: amount_cents + value)
end
end