Class: Spree::TaxCalculator::ShippingRate
- Inherits:
-
Object
- Object
- Spree::TaxCalculator::ShippingRate
- Includes:
- Spree::Tax::TaxHelpers
- Defined in:
- app/models/spree/tax_calculator/shipping_rate.rb
Overview
Default implementation for tax calculations on shipping rates.
The class used for shipping rate tax calculation is configurable, so that the calculation can easily be pushed to third-party services. Users looking to provide their own calculator should adhere to the API of this class.
Instance Method Summary collapse
-
#calculate(shipping_rate) ⇒ Array<Spree::Tax::ItemTax>
Calculate taxes for a shipping rate.
-
#initialize(order) ⇒ Spree::TaxCalculator::ShippingRate
constructor
Create a new tax calculator.
Constructor Details
#initialize(order) ⇒ Spree::TaxCalculator::ShippingRate
Create a new tax calculator.
20 21 22 |
# File 'app/models/spree/tax_calculator/shipping_rate.rb', line 20 def initialize(order) @order = order end |
Instance Method Details
#calculate(shipping_rate) ⇒ Array<Spree::Tax::ItemTax>
Calculate taxes for a shipping rate.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/spree/tax_calculator/shipping_rate.rb', line 30 def calculate(shipping_rate) rates_for_item(shipping_rate).map do |rate| amount = rate.compute_amount(shipping_rate) Spree::Tax::ItemTax.new( item_id: shipping_rate.id, label: rate.adjustment_label(amount), tax_rate: rate, amount: amount ) end end |