Class: Calculator::TieredFlatRate

Inherits:
Calculator
  • Object
show all
Defined in:
app/models/spree/calculator/tiered_flat_rate.rb

Instance Method Summary collapse

Instance Method Details

#compute(object) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/spree/calculator/tiered_flat_rate.rb', line 22

def compute(object)
  _base, amount = preferred_tiers.sort.reverse.detect do |value, _|
    object.amount >= value
  end

  if preferred_currency.casecmp(object.currency).zero?
    amount || preferred_base_amount
  else
    0
  end
end