Class: Coupon::Calculator::FlatAmountOffPerUnit
- Inherits:
-
Base
- Object
- Base
- Coupon::Calculator::FlatAmountOffPerUnit
- Defined in:
- app/services/coupon/calculator/flat_amount_off_per_unit.rb
Overview
Flat AmountOff Per Unit, variant of FlatAmountOff, will discount the value
of flat amount once per quantity of the qualifying unit
Instance Method Summary collapse
Instance Method Details
#calculate(discount) ⇒ Object
5 6 7 8 9 10 |
# File 'app/services/coupon/calculator/flat_amount_off_per_unit.rb', line 5 def calculate(discount) @line_item_extractor.discountable_line_items.each do |line_item| allocated_amount = -[ @options[:flat_amount], line_item.discounted_price ].min allocate_to_line(line_item, discount, allocated_amount) end end |