Class: SolidusSubscriptions::Installment
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- SolidusSubscriptions::Installment
- Defined in:
- app/models/solidus_subscriptions/installment.rb
Instance Method Summary collapse
-
#failed!(order) ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as a failure.
-
#fulfilled? ⇒ Boolean
Had this installment been fulfilled by a completed order.
-
#out_of_stock ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as out of stock.
-
#payment_failed!(order) ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as having a failed payment.
-
#state ⇒ Symbol
Returns the state of this fulfillment.
-
#success!(order) ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as a success.
-
#unfulfilled? ⇒ Boolean
Does this installment still need to be fulfilled by a completed order.
Instance Method Details
#failed!(order) ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as a failure
70 71 72 73 74 75 76 77 78 |
# File 'app/models/solidus_subscriptions/installment.rb', line 70 def failed!(order) advance_actionable_date! details.create!( success: false, order: order, message: I18n.t('solidus_subscriptions.installment_details.failed') ) end |
#fulfilled? ⇒ Boolean
Had this installment been fulfilled by a completed order
90 91 92 |
# File 'app/models/solidus_subscriptions/installment.rb', line 90 def fulfilled? details.exists?(success: true) end |
#out_of_stock ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as out of stock.
37 38 39 40 41 42 43 44 |
# File 'app/models/solidus_subscriptions/installment.rb', line 37 def out_of_stock advance_actionable_date! details.create!( success: false, message: I18n.t('solidus_subscriptions.installment_details.out_of_stock') ) end |
#payment_failed!(order) ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as having a failed payment
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/models/solidus_subscriptions/installment.rb', line 108 def payment_failed!(order) details.create!( success: false, order: order, message: I18n.t('solidus_subscriptions.installment_details.payment_failed') ) if subscription.maximum_reprocessing_time_reached? && !subscription.canceled? subscription.force_cancel! update!(actionable_date: nil) else advance_actionable_date! end end |
#state ⇒ Symbol
Returns the state of this fulfillment
97 98 99 |
# File 'app/models/solidus_subscriptions/installment.rb', line 97 def state fulfilled? ? :fulfilled : :unfulfilled end |
#success!(order) ⇒ SolidusSubscriptions::InstallmentDetail
Mark this installment as a success
53 54 55 56 57 58 59 60 61 |
# File 'app/models/solidus_subscriptions/installment.rb', line 53 def success!(order) update!(actionable_date: nil) details.create!( success: true, order: order, message: I18n.t('solidus_subscriptions.installment_details.success') ) end |
#unfulfilled? ⇒ Boolean
Does this installment still need to be fulfilled by a completed order
83 84 85 |
# File 'app/models/solidus_subscriptions/installment.rb', line 83 def unfulfilled? !fulfilled? end |