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



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



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



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



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