From 17f9f895c77cc27c08c1c1c34b82d4a34c3a226c Mon Sep 17 00:00:00 2001 From: Brendan Deere Date: Fri, 23 Sep 2016 15:04:11 -0700 Subject: Add Installment#actionable This scope returns all installments which have not been fulfilled by a Spree order and the actionable date is today or has past. It is used to find installments that require reprocessing --- app/models/solidus_subscriptions/installment.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/models/solidus_subscriptions/installment.rb') diff --git a/app/models/solidus_subscriptions/installment.rb b/app/models/solidus_subscriptions/installment.rb index 38317bd..cedffa0 100644 --- a/app/models/solidus_subscriptions/installment.rb +++ b/app/models/solidus_subscriptions/installment.rb @@ -13,6 +13,11 @@ module SolidusSubscriptions validates :subscription, presence: true + scope :actionable, (lambda do + where("#{table_name}.actionable_date <= ?", Time.zone.now). + where(order_id: nil) + end) + # Get the builder for the subscription_line_item. This will be an # object that can generate the appropriate line item for the subscribable # object -- cgit v1.2.3