summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/solidus_subscriptions/subscription_generator.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/solidus_subscriptions/subscription_generator.rb b/lib/solidus_subscriptions/subscription_generator.rb
index 8153912..7acedfa 100644
--- a/lib/solidus_subscriptions/subscription_generator.rb
+++ b/lib/solidus_subscriptions/subscription_generator.rb
@@ -34,6 +34,8 @@ module SolidusSubscriptions
Subscription.create!(subscription_attributes) do |sub|
sub.actionable_date = sub.next_actionable_date
+ end.tap do |_subscription|
+ cleanup_subscription_line_items(subscription_line_items)
end
end
@@ -54,6 +56,15 @@ module SolidusSubscriptions
private
+ def cleanup_subscription_line_items(subscription_line_items)
+ ids = subscription_line_items.pluck :id
+ SolidusSubscriptions::LineItem.where(id: ids).update_all(
+ interval_length: nil,
+ interval_units: nil,
+ end_date: nil
+ )
+ end
+
def subscription_configuration(subscription_line_item)
SubscriptionConfiguration.new(
subscription_line_item.interval_length,