Class: Spree::Adjustment
- Extended by:
- DisplayMoney
- Defined in:
- app/models/spree/adjustment.rb
Overview
Adjustments represent a change to the item_total
of an Order. Each adjustment has an amount
that can be either positive or negative.
Adjustments can be “unfinalized” or “finalized”. Once an adjustment is finalized, it will not be automatically updated.
Instance Method Summary collapse
-
#cancellation? ⇒ Boolean
True when this is a cancellation adjustment (Cancellation adjustments have a UnitCancel source).
- #currency ⇒ Object
- #eligible? ⇒ Boolean (also: #eligible)
- #finalize ⇒ Object
- #finalize! ⇒ Object
-
#promotion? ⇒ Boolean
True when this is a promotion adjustment (Promotion adjustments have a PromotionAction source).
-
#tax? ⇒ Boolean
True when this is a tax adjustment (Tax adjustments have a TaxRate source).
- #unfinalize ⇒ Object
- #unfinalize! ⇒ Object
Methods included from DisplayMoney
Methods inherited from Base
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Instance Method Details
#cancellation? ⇒ Boolean
Returns true when this is a cancellation adjustment (Cancellation adjustments have a UnitCancel source).
81 82 83 |
# File 'app/models/spree/adjustment.rb', line 81 def cancellation? source_type == 'Spree::UnitCancel' end |
#currency ⇒ Object
66 67 68 |
# File 'app/models/spree/adjustment.rb', line 66 def currency adjustable ? adjustable.currency : Spree::Config[:currency] end |
#eligible? ⇒ Boolean Also known as: eligible
85 86 87 |
# File 'app/models/spree/adjustment.rb', line 85 def eligible? true end |
#finalize ⇒ Object
58 59 60 |
# File 'app/models/spree/adjustment.rb', line 58 def finalize update(finalized: true) end |
#finalize! ⇒ Object
50 51 52 |
# File 'app/models/spree/adjustment.rb', line 50 def finalize! update!(finalized: true) end |
#promotion? ⇒ Boolean
Returns true when this is a promotion adjustment (Promotion adjustments have a PromotionAction source).
71 72 73 |
# File 'app/models/spree/adjustment.rb', line 71 def promotion? source_type.to_s.in?(Spree::Config.adjustment_promotion_source_types.map(&:to_s)) end |
#tax? ⇒ Boolean
Returns true when this is a tax adjustment (Tax adjustments have a TaxRate source).
76 77 78 |
# File 'app/models/spree/adjustment.rb', line 76 def tax? source_type == 'Spree::TaxRate' end |
#unfinalize ⇒ Object
62 63 64 |
# File 'app/models/spree/adjustment.rb', line 62 def unfinalize update(finalized: false) end |
#unfinalize! ⇒ Object
54 55 56 |
# File 'app/models/spree/adjustment.rb', line 54 def unfinalize! update!(finalized: false) end |