Class: Spree::Adjustment

Inherits:
Base
  • Object
show all
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

Methods included from DisplayMoney

money_methods

Methods inherited from Base

display_includes

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).

Returns:

  • (Boolean)

    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

#currencyObject



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

Returns:

  • (Boolean)


86
87
88
# File 'app/models/spree/adjustment.rb', line 86

def eligible?
  true
end

#finalizeObject



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).

Returns:

  • (Boolean)

    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).

Returns:

  • (Boolean)

    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

#unfinalizeObject



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