Class: Spree::Calculator::DistributedAmount

Inherits:
Spree::Calculator show all
Defined in:
app/models/spree/calculator/distributed_amount.rb

Instance Method Summary collapse

Methods inherited from Spree::Calculator

#available?, calculators, #compute, #description, description, #to_s

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

#compute_line_item(line_item) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'app/models/spree/calculator/distributed_amount.rb', line 13

def compute_line_item(line_item)
  if line_item && preferred_currency.casecmp(line_item.currency).zero?
    Spree::DistributedAmountsHandler.new(
      line_item,
      preferred_amount
    ).amount
  else
    0
  end
end