Class: Transactionable::Debit
Constant Summary
Constants inherited
from Transaction
Transaction::TRANSACTION_TYPES
Instance Method Summary
collapse
Methods inherited from Transaction
create_from_remote, #remote
Instance Method Details
#max_refund_amount ⇒ Object
13
14
15
|
# File 'app/models/transactionable/debit.rb', line 13
def max_refund_amount
amount - refunds.sum(:amount)
end
|
#refund!(refund_amount = nil) ⇒ Object
5
6
7
8
9
10
11
|
# File 'app/models/transactionable/debit.rb', line 5
def refund!(refund_amount = nil)
ensure_valid_refund(refund_amount)
remote_refund = refund_amount ? remote.refund(amount: amount_in_cents(refund_amount)) : remote.refund
transaction = Transactionable::Refund.create_from_remote(remote_refund)
refunds << transaction
transactionable.transactions << transaction
end
|