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

#admin_form_preference_names, #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



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

def compute_line_item(line_item)
  return 0 unless line_item
  return 0 unless preferred_currency.casecmp(line_item.currency).zero?
  return 0 unless calculable.promotion.line_item_actionable?(line_item.order, line_item)
  Spree::DistributedAmountsHandler.new(
    actionable_line_items(line_item.order),
    preferred_amount
  ).amount(line_item)
end