Class: SolidusFriendlyPromotions::Calculators::FlexiRate
- Inherits:
-
Spree::Calculator
- Object
- Spree::Calculator
- SolidusFriendlyPromotions::Calculators::FlexiRate
- Includes:
- PromotionCalculator
- Defined in:
- app/models/solidus_friendly_promotions/calculators/flexi_rate.rb
Instance Method Summary collapse
Methods included from PromotionCalculator
Instance Method Details
#compute(object) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/models/solidus_friendly_promotions/calculators/flexi_rate.rb', line 15 def compute(object) items_count = object.quantity items_count = [items_count, preferred_max_items].min unless preferred_max_items.zero? return BigDecimal("0") if items_count == 0 additional_items_count = items_count - 1 preferred_first_item + preferred_additional_item * additional_items_count end |