Class: Workarea::Pricing::Discount::QuantityFixedPrice::ApplicationCalculator

Inherits:
Object
  • Object
show all
Defined in:
app/models/workarea/pricing/discount/quantity_fixed_price/application_calculator.rb

Overview

Responsible for calcuating a how many applicaitons a given set of items should recieve a Workarea::Pricing::Discount::QuantityFixedPrice. Limits at max application is set.

Instance Method Summary collapse

Constructor Details

#initialize(discount, items) ⇒ ApplicationCalculator

Returns a new instance of ApplicationCalculator.



12
13
14
15
# File 'app/models/workarea/pricing/discount/quantity_fixed_price/application_calculator.rb', line 12

def initialize(discount, items)
  @discount = discount
  @items = items
end

Instance Method Details

#applicationsInteger

The number of applications these items can recieve.

Returns:

  • (Integer)


21
22
23
24
25
26
27
28
# File 'app/models/workarea/pricing/discount/quantity_fixed_price/application_calculator.rb', line 21

def applications
  if max_applications.present? &&
       potential_applications > max_applications
    max_applications
  else
    potential_applications
  end
end