summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrendan Deere <brendangdeere@gmail.com>2016-10-12 08:33:54 -0700
committerGitHub <noreply@github.com>2016-10-12 08:33:54 -0700
commit5aefefed74c73debdcde0d69e3be62cdd06bdf48 (patch)
tree59f556640d32abec0e7cadd4a2eedf6c3c373f77 /lib
parenta2418d36a5a5e9d77193f6fcdd44666fd624f29b (diff)
parent456e0dc13175ec93ae7a989d64649361aa744131 (diff)
Merge pull request #89 from brendandeere/skips
Skips
Diffstat (limited to 'lib')
-rw-r--r--lib/solidus_subscriptions/config.rb8
-rw-r--r--lib/solidus_subscriptions/processor.rb1
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/solidus_subscriptions/config.rb b/lib/solidus_subscriptions/config.rb
index 7eabfab..e19c308 100644
--- a/lib/solidus_subscriptions/config.rb
+++ b/lib/solidus_subscriptions/config.rb
@@ -1,6 +1,14 @@
module SolidusSubscriptions
module Config
class << self
+ # Maximum number of times a user can skip their subscription before it
+ # must be processed
+ mattr_accessor(:maximum_successive_skips) { 1 }
+
+ # Limit on the number of times a user can skip thier subscription. Once
+ # this limit is reached, no skips are permitted
+ mattr_accessor(:maximum_total_skips) { nil }
+
# Time between an installment failing to be processed and the system
# retrying to fulfil it
mattr_accessor(:reprocessing_interval) { 1.day }
diff --git a/lib/solidus_subscriptions/processor.rb b/lib/solidus_subscriptions/processor.rb
index c035ecf..40ff35e 100644
--- a/lib/solidus_subscriptions/processor.rb
+++ b/lib/solidus_subscriptions/processor.rb
@@ -82,6 +82,7 @@ module SolidusSubscriptions
def new_installments(user)
subscriptions_by_id.fetch(user.id, []).map do |sub|
ActiveRecord::Base.transaction do
+ sub.successive_skip_count = 0
sub.advance_actionable_date
sub.cancel! if sub.pending_cancellation?
sub.installments.create!