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).
82 83 84 |
# File 'app/models/spree/adjustment.rb', line 82 def cancellation? source_type == "Spree::UnitCancel" end |
#currency ⇒ Object
67 68 69 |
# File 'app/models/spree/adjustment.rb', line 67 def currency adjustable ? adjustable.currency : Spree::Config[:currency] end |
#eligible? ⇒ Boolean Also known as: eligible
86 87 88 |
# File 'app/models/spree/adjustment.rb', line 86 def eligible? true end |
#finalize ⇒ Object
59 60 61 |
# File 'app/models/spree/adjustment.rb', line 59 def finalize update(finalized: true) end |
#finalize! ⇒ Object
51 52 53 |
# File 'app/models/spree/adjustment.rb', line 51 def finalize! update!(finalized: true) end |
#promotion? ⇒ Boolean
Returns true when this is a promotion adjustment (Promotion adjustments have a PromotionAction source).
72 73 74 |
# File 'app/models/spree/adjustment.rb', line 72 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).
77 78 79 |
# File 'app/models/spree/adjustment.rb', line 77 def tax? source_type == "Spree::TaxRate" end |
#unfinalize ⇒ Object
63 64 65 |
# File 'app/models/spree/adjustment.rb', line 63 def unfinalize update(finalized: false) end |
#unfinalize! ⇒ Object
55 56 57 |
# File 'app/models/spree/adjustment.rb', line 55 def unfinalize! update!(finalized: false) end |