diff options
author | Alessandro Desantis <desa.alessandro@gmail.com> | 2021-02-05 13:30:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 13:30:47 +0100 |
commit | 3a3657b79bd5d98025136da4b39751e6a43b7b9f (patch) | |
tree | b7a57b183641d64d05e5e70e281fd78cb5e37ebd /app/models/solidus_subscriptions | |
parent | 69f0ca038b66d0ca36971405e51c0d3aa916cf19 (diff) | |
parent | 4717d24c0e7203210efe8c23b55467c3e728cdc5 (diff) |
Merge pull request #172 from solidusio-contrib/aldesantis/refactoring
Processor and Checkout refactoring
Diffstat (limited to 'app/models/solidus_subscriptions')
-rw-r--r-- | app/models/solidus_subscriptions/installment.rb | 7 | ||||
-rw-r--r-- | app/models/solidus_subscriptions/line_item.rb | 29 | ||||
-rw-r--r-- | app/models/solidus_subscriptions/subscription.rb | 9 |
3 files changed, 0 insertions, 45 deletions
diff --git a/app/models/solidus_subscriptions/installment.rb b/app/models/solidus_subscriptions/installment.rb index 0b5f627..aed1f62 100644 --- a/app/models/solidus_subscriptions/installment.rb +++ b/app/models/solidus_subscriptions/installment.rb @@ -31,13 +31,6 @@ module SolidusSubscriptions unfulfilled.where("#{table_name}.actionable_date <= ?", Time.zone.today) 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 - # - # @return [SolidusSubscriptions::LineItemBuilder] - delegate :line_item_builder, to: :subscription - # Mark this installment as out of stock. # # @return [SolidusSubscriptions::InstallmentDetail] The record of the failed diff --git a/app/models/solidus_subscriptions/line_item.rb b/app/models/solidus_subscriptions/line_item.rb index 64e6fb0..2583ecc 100644 --- a/app/models/solidus_subscriptions/line_item.rb +++ b/app/models/solidus_subscriptions/line_item.rb @@ -38,34 +38,5 @@ module SolidusSubscriptions validates :subscribable_id, presence: true validates :quantity, numericality: { greater_than: 0 } validates :interval_length, numericality: { greater_than: 0 }, unless: -> { subscription } - - def as_json(**options) - options[:methods] ||= [:dummy_line_item] - super(options) - end - - # Get a placeholder line item for calculating the values of future - # subscription orders. It is frozen and cannot be saved - def dummy_line_item - li = LineItemBuilder.new([self]).spree_line_items.first - return unless li - - li.order = dummy_order - li.validate - li.freeze - end - - private - - # Get a placeholder order for calculating the values of future - # subscription orders. It is a frozen duplicate of the current order and - # cannot be saved - def dummy_order - order = spree_line_item ? spree_line_item.order.dup : ::Spree::Order.create - order.ship_address = subscription.shipping_address || subscription.user.ship_address if subscription - order.bill_address = subscription.billing_address || subscription.user.bill_address if subscription - - order.freeze - end end end diff --git a/app/models/solidus_subscriptions/subscription.rb b/app/models/solidus_subscriptions/subscription.rb index 4168973..15424d8 100644 --- a/app/models/solidus_subscriptions/subscription.rb +++ b/app/models/solidus_subscriptions/subscription.rb @@ -203,15 +203,6 @@ module SolidusSubscriptions actionable_date 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 - # - # @return [SolidusSubscriptions::LineItemBuilder] - def line_item_builder - LineItemBuilder.new(line_items) - end - # The state of the last attempt to process an installment associated to # this subscription # |