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)



81
82
83
# File 'app/models/spree/adjustment.rb', line 81

def cancellation?
  source_type == 'Spree::UnitCancel'
end

#currencyObject



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

Returns:

  • (Boolean)


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

def eligible?
  true
end

#finalizeObject



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

Returns:

  • (Boolean)

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

Returns:

  • (Boolean)

    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

#unfinalizeObject



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