Module: RailsTrade::PaymentOrder
- Extended by:
- ActiveSupport::Concern
- Included in:
- PaymentOrder
- Defined in:
- app/models/rails_trade/payment_order.rb
Instance Method Summary collapse
- #checked_payment ⇒ Object
- #checked_to_order ⇒ Object
- #checked_to_payment ⇒ Object
- #confirm! ⇒ Object
- #revert_confirm! ⇒ Object
- #unchecked_payment ⇒ Object
- #unchecked_to_order ⇒ Object
- #unchecked_to_payment ⇒ Object
- #valid_check_amount ⇒ Object
Instance Method Details
#checked_payment ⇒ Object
32 33 34 35 |
# File 'app/models/rails_trade/payment_order.rb', line 32 def checked_payment checked_to_payment checked_to_order end |
#checked_to_order ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/rails_trade/payment_order.rb', line 51 def checked_to_order self.order && order.reload order.received_amount += self.check_amount if order.received_amount == order.compute_received_amount order.check_state order.save! else order.errors.add :received_amount, 'check not equal' logger.error "#{self.class.name}/Order: #{order.errors..join(', ')}" raise ActiveRecord::RecordInvalid.new(order) end end |
#checked_to_payment ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/rails_trade/payment_order.rb', line 37 def checked_to_payment self.payment payment.checked_amount += self.check_amount if payment.checked_amount == payment.compute_checked_amount payment.check_state payment.save! else payment.errors.add :checked_amount, 'check not equal' logger.error "#{self.class.name}/Payment: #{payment.errors..join(', ')}" raise ActiveRecord::RecordInvalid.new(payment) end end |
#confirm! ⇒ Object
98 99 100 101 |
# File 'app/models/rails_trade/payment_order.rb', line 98 def confirm! self.state = 'confirmed' self.save! end |
#revert_confirm! ⇒ Object
103 104 105 106 |
# File 'app/models/rails_trade/payment_order.rb', line 103 def revert_confirm! self.state = 'init' self.save! end |
#unchecked_payment ⇒ Object
65 66 67 68 |
# File 'app/models/rails_trade/payment_order.rb', line 65 def unchecked_payment unchecked_to_payment unchecked_to_order end |
#unchecked_to_order ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/models/rails_trade/payment_order.rb', line 84 def unchecked_to_order self.order && order.reload order.received_amount -= self.check_amount if order.received_amount == order.compute_received_amount order.check_state order.save! else order.errors.add :received_amount, 'uncheck not equal' logger.error "#{self.class.name}/Order: #{order.errors..join(', ')}" raise ActiveRecord::RecordInvalid.new(order) end end |
#unchecked_to_payment ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/models/rails_trade/payment_order.rb', line 70 def unchecked_to_payment self.payment && payment.reload payment.checked_amount -= self.check_amount if payment.checked_amount == payment.compute_checked_amount payment.check_state payment.save! else payment.errors.add :checked_amount, 'uncheck not equal' logger.error "#{self.class.name}/Payment: #{payment.errors..join(', ')}" raise ActiveRecord::RecordInvalid.new(payment) end end |
#valid_check_amount ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/models/rails_trade/payment_order.rb', line 22 def valid_check_amount if the_payment_amount > payment.total_amount + payment.adjust_amount self.errors.add(:check_amount, 'Total checked amount greater than payment\'s amount') end if the_order_amount > order.amount + order.adjust_amount self.errors.add(:check_amount, 'Total checked amount greater than Order\'s amount') end end |