diff options
author | Sean <seand7565@gmail.com> | 2020-12-15 14:43:08 -0600 |
---|---|---|
committer | Sean <seand7565@gmail.com> | 2020-12-16 08:33:25 -0600 |
commit | 5ad9618cfeaf6e8aa26cb23798cb85c2c20fa22c (patch) | |
tree | 25d58b417e59d6bc6c1ea7f1afb1378b0191fb64 /app/models/solidus_subscriptions/installment.rb | |
parent | 982e340b73a63089907a3e68ebd7395f16892fa2 (diff) |
Avoid processing installments with cancelled subscriptions
Anyone who cancels their subscription with a failed installment will
still have an order created the next time installments are created.
This is because installments don't check the status of their associated
subscriptions before being processed.
This update will ensure that only installments with active subscriptions
are processed.
Diffstat (limited to 'app/models/solidus_subscriptions/installment.rb')
-rw-r--r-- | app/models/solidus_subscriptions/installment.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/solidus_subscriptions/installment.rb b/app/models/solidus_subscriptions/installment.rb index 9185743..6d6baaa 100644 --- a/app/models/solidus_subscriptions/installment.rb +++ b/app/models/solidus_subscriptions/installment.rb @@ -23,6 +23,10 @@ module SolidusSubscriptions where.not(id: fulfilled_ids).distinct end) + scope :with_active_subscription, (lambda do + joins(:subscription).where.not(Subscription.table_name => {state: "canceled"}) + end) + scope :actionable, (lambda do unfulfilled.where("#{table_name}.actionable_date <= ?", Time.zone.today) end) |