Class: Spree::Tax::ShippingRateTaxer

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/tax/shipping_rate_taxer.rb

Overview

Used to build shipping rate taxes

Instance Method Summary collapse

Instance Method Details

#tax(shipping_rate) ⇒ Spree::ShippingRate

Build shipping rate taxes for a shipping rate Modifies the passed-in shipping rate with associated shipping rate taxes.

Parameters:

  • shipping_rate (Spree::ShippingRate)

    The shipping rate to add taxes to. This parameter will be modified.

Returns:



12
13
14
15
16
17
18
19
20
21
# File 'app/models/spree/tax/shipping_rate_taxer.rb', line 12

def tax(shipping_rate)
  taxes = Spree::Config.shipping_rate_tax_calculator_class.new(shipping_rate.order).calculate(shipping_rate)
  taxes.each do |tax|
    shipping_rate.taxes.build(
      amount: tax.amount,
      tax_rate: tax.tax_rate
    )
  end
  shipping_rate
end