Class: SolidusFriendlyPromotions::Calculators::DistributedAmount

Inherits:
Spree::Calculator
  • Object
show all
Includes:
PromotionCalculator
Defined in:
app/models/solidus_friendly_promotions/calculators/distributed_amount.rb

Instance Method Summary collapse

Methods included from PromotionCalculator

#description

Instance Method Details

#compute_line_item(line_item) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/solidus_friendly_promotions/calculators/distributed_amount.rb', line 17

def compute_line_item(line_item)
  return 0 unless line_item
  return 0 unless preferred_currency.casecmp(line_item.currency).zero?

  distributable_line_items = calculable.applicable_line_items(line_item.order)
  return 0 unless line_item.in?(distributable_line_items)

  DistributedAmountsHandler.new(
    distributable_line_items,
    preferred_amount
  ).amount(line_item)
end