Class: Spree::TaxRate

Inherits:
Base
  • Object
show all
Includes:
AdjustmentSource, CalculatedAdjustments, SoftDeletable
Defined in:
app/models/spree/tax_rate.rb

Instance Method Summary collapse

Methods included from AdjustmentSource

#remove_adjustments_from_incomplete_orders

Methods included from CalculatedAdjustments

#calculator_type, #calculator_type=

Methods inherited from Base

display_includes

Methods included from Core::Permalinks

#generate_permalink, #save_permalink

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


102
103
104
105
# File 'app/models/spree/tax_rate.rb', line 102

def active?
  (starts_at.nil? || starts_at < Time.current) &&
    (expires_at.nil? || expires_at > Time.current)
end

#adjustment_label(amount) ⇒ Object



107
108
109
110
111
112
113
114
# File 'app/models/spree/tax_rate.rb', line 107

def adjustment_label(amount)
  I18n.t(
    translation_key(amount),
    scope: "spree.adjustment_labels.tax_rates",
    name: name.presence || tax_categories.map(&:name).join(", "),
    amount: amount_for_adjustment_label
  )
end

#compute_amount(item) ⇒ Object

This method is used by Adjustment#update to recalculate the cost.



98
99
100
# File 'app/models/spree/tax_rate.rb', line 98

def compute_amount(item)
  calculator.compute(item)
end

#display_amountObject



116
117
118
# File 'app/models/spree/tax_rate.rb', line 116

def display_amount
  amount_for_adjustment_label
end