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?, #compute, description, #description, #to_s

Methods inherited from Base

display_includes

Methods included from Spree::Core::Permalinks

#generate_permalink, #save_permalink

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