Sha256: 36ea7b633a4433b7a6b599718c3cf8aa039d50bcd6c9391965a091340baa3a7d
Contents?: true
Size: 859 Bytes
Versions: 1
Compression:
Stored size: 859 Bytes
Contents
module Trade module Ordering::Refund def apply_for_refund(payment_id = nil) if ['unpaid', 'refunding', 'refunded'].include? self.payment_status return end if payment_id payments = self.payments.where(id: payment_id) else payments = self.payments end payments.each do |payment| refund = self.refunds.build(payment_id: payment.id) refund.type = payment.type.sub(/Payment/, '') + 'Refund' refund.total_amount = payment.total_amount refund.currency = payment.currency self.received_amount -= payment.total_amount end self.payment_status = 'refunding' self.class.transaction do self.confirm_refund! self.save! end end def confirm_refund! self.trade_items.each(&:confirm_refund!) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_trade-0.0.3 | app/models/trade/ordering/refund.rb |