Module: Spree::TypedAdjustmentLine

Extended by:
ActiveSupport::Concern
Included in:
Discount, Fee, TaxLine
Defined in:
app/models/concerns/spree/typed_adjustment_line.rb

Overview

Shared shape of the typed adjustment rows (TaxLine, Discount, Fee): dual-FK cart/order owner (exactly one), consolidated metadata JSON column, money display and strict amount parsing.

Instance Method Summary collapse

Instance Method Details

#currency ⇒ Object



44
45
46
# File 'app/models/concerns/spree/typed_adjustment_line.rb', line 44

def currency
  owner&.currency
end

#order=(record) ⇒ Object

Bridge for legacy callers assigning current_order (now a Spree::Cart) to the order association — routes carts to the cart FK instead.



35
36
37
38
39
40
41
42
# File 'app/models/concerns/spree/typed_adjustment_line.rb', line 35

def order=(record)
  if record.is_a?(Spree::Cart)
    self.cart = record
    super(nil)
  else
    super
  end
end

#owner ⇒ Spree::Cart, ...

The exactly-one owner of this row — the cart during checkout, the order after completion. New code must read owner, never assume order.

Returns:



29
30
31
# File 'app/models/concerns/spree/typed_adjustment_line.rb', line 29

def owner
  order || cart
end