Class: Spree::Calculator::FlatPercentItemTotal
- Inherits:
-
Calculator
- Object
- Calculator
- Spree::Calculator::FlatPercentItemTotal
- Defined in:
- app/models/spree/calculator/flat_percent_item_total.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.description ⇒ Object
7 8 9 |
# File 'app/models/spree/calculator/flat_percent_item_total.rb', line 7 def self.description Spree.t(:flat_percent) end |
Instance Method Details
#compute(object) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/spree/calculator/flat_percent_item_total.rb', line 11 def compute(object) computed_amount = (object.amount * preferred_flat_percent / 100).round(2) # We don't want to cause the promotion adjustments to push the order into a negative total. if computed_amount > object.amount object.amount else computed_amount end end |