Class: Calculator::PercentOffSalePriceCalculator
- Inherits:
-
Spree::Calculator
- Object
- Spree::Calculator
- Calculator::PercentOffSalePriceCalculator
- Defined in:
- app/models/spree/calculator/percent_off_sale_price_calculator.rb
Class Method Summary collapse
-
.description ⇒ Object
TODO validate that the sale price is between 0 and 1.
Instance Method Summary collapse
Class Method Details
.description ⇒ Object
TODO validate that the sale price is between 0 and 1
4 5 6 |
# File 'app/models/spree/calculator/percent_off_sale_price_calculator.rb', line 4 def self.description "Calculates the sale price for a Variant by taking off a percentage of the original price" end |
Instance Method Details
#compute(sale_price) ⇒ Object
8 9 10 |
# File 'app/models/spree/calculator/percent_off_sale_price_calculator.rb', line 8 def compute(sale_price) (1.0 - sale_price.value.to_f) * sale_price.variant.original_price.to_f end |