Class: Workarea::Pricing::Calculators::DiscountCalculator
- Inherits:
-
Object
- Object
- Workarea::Pricing::Calculators::DiscountCalculator
- Includes:
- Workarea::Pricing::Calculator
- Defined in:
- app/models/workarea/pricing/calculators/discount_calculator.rb
Instance Method Summary collapse
Methods included from Workarea::Pricing::Calculator
Instance Method Details
#adjust ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/models/workarea/pricing/calculators/discount_calculator.rb', line 7 def adjust most_valuable_group.apply if most_valuable_group.present? # This is mostly for paranoia - it will prevent any sloppy custom # discount coding from over-discounting. price_adjustment_groups.each do |price_adjustments| reconcile = Discount::ReconcileTotal.new(price_adjustments) reconcile.perform if reconcile.over_discounted? end end |
#application_groups ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/models/workarea/pricing/calculators/discount_calculator.rb', line 22 def application_groups @application_groups ||= Discount::ApplicationGroup.calculate( discounts, order, shippings ) end |
#most_valuable_group ⇒ Object
18 19 20 |
# File 'app/models/workarea/pricing/calculators/discount_calculator.rb', line 18 def most_valuable_group application_groups.sort { |a, b| a.value <=> b.value }.last end |