Module: Spree::AdjustmentSource

Included in:
Promotion::Actions::CreateAdjustment, Promotion::Actions::CreateItemAdjustments, TaxRate
Defined in:
app/models/concerns/spree/adjustment_source.rb

Instance Method Summary collapse

Instance Method Details

#deals_with_adjustments_for_deleted_sourceObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/models/concerns/spree/adjustment_source.rb', line 3

def deals_with_adjustments_for_deleted_source
  Spree::Deprecation.warn "AdjustmentSource#deals_with_adjustments_for_deleted_source is deprecated. Please use AdjustmentSource#remove_adjustments_from_incomplete_orders instead."

  remove_adjustments_from_incomplete_orders

  # The following is deprecated. As source_type without a source_id isn't
  # much better than a source_id that doesn't exist.  In Solidus itself the
  # relevant classes use `acts_as_paranoid` so it is useful to keep the
  # source_id around.
  adjustments.
    joins(:order).
    merge(Spree::Order.complete).
    update_all(source_id: nil, updated_at: Time.current)
end

#remove_adjustments_from_incomplete_ordersObject



18
19
20
21
22
23
# File 'app/models/concerns/spree/adjustment_source.rb', line 18

def remove_adjustments_from_incomplete_orders
  adjustments.
    joins(:order).
    merge(Spree::Order.incomplete).
    destroy_all
end