Class: Spree::Calculator::Shipping::FlatPercentItemTotal
- Inherits:
-
ShippingCalculator
- Object
- ActiveRecord::Base
- Base
- Spree::Calculator
- ShippingCalculator
- Spree::Calculator::Shipping::FlatPercentItemTotal
- Defined in:
- app/models/spree/calculator/shipping/flat_percent_item_total.rb
Instance Method Summary collapse
Methods inherited from ShippingCalculator
Methods inherited from Spree::Calculator
#available?, #compute, description, #description, #to_s
Methods inherited from Base
Methods included from Spree::Core::Permalinks
#generate_permalink, #save_permalink
Instance Method Details
#compute_from_price(price) ⇒ Object
18 19 20 |
# File 'app/models/spree/calculator/shipping/flat_percent_item_total.rb', line 18 def compute_from_price(price) price * BigDecimal(preferred_flat_percent.to_s) / 100.0 end |
#compute_package(package) ⇒ Object
11 12 13 14 15 16 |
# File 'app/models/spree/calculator/shipping/flat_percent_item_total.rb', line 11 def compute_package(package) value = compute_from_price(total(package.contents)) preferred_currency = package.order.currency currency_exponent = ::Money::Currency.find(preferred_currency).exponent value.round(currency_exponent) end |