Class: Spree::TaxCalculator::Default
- Inherits:
-
Object
- Object
- Spree::TaxCalculator::Default
- Includes:
- Spree::Tax::TaxHelpers
- Defined in:
- app/models/spree/tax_calculator/default.rb
Overview
Default implementation for tax calculations. Will go through all line items and shipments and calculate their tax based on tax rates in the DB.
The class used for 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 ⇒ Spree::Tax::OrderTax
Calculate taxes for an order.
-
#initialize(order) ⇒ Spree::TaxCalculator::Default
constructor
Create a new tax calculator.
Constructor Details
#initialize(order) ⇒ Spree::TaxCalculator::Default
Create a new tax calculator.
18 19 20 |
# File 'app/models/spree/tax_calculator/default.rb', line 18 def initialize(order) @order = order end |
Instance Method Details
#calculate ⇒ Spree::Tax::OrderTax
Calculate taxes for an order.
25 26 27 28 29 30 31 32 |
# File 'app/models/spree/tax_calculator/default.rb', line 25 def calculate Spree::Tax::OrderTax.new( order_id: order.id, order_taxes: order_rates, line_item_taxes: line_item_rates, shipment_taxes: shipment_rates ) end |