17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/models/solidus_friendly_promotions/calculators/tiered_percent_on_eligible_item_quantity.rb', line 17
def compute_line_item(line_item)
order = line_item.order
_base, percent = preferred_tiers.sort.reverse.detect do |value, _|
eligible_line_items_quantity_total(order) >= value
end
if preferred_currency.casecmp(order.currency).zero?
currency_exponent = ::Money::Currency.find(preferred_currency).exponent
(line_item.discountable_amount * (percent || preferred_base_percent) / 100).round(currency_exponent)
else
0
end
end
|