Sha256: 0c9032a931839111d702d273ad007ce9ed53b16a7bf8ff36ee06af420bac8d2c
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Spree module TaxCalculator # 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. # # @see Spree::Stock::Estimator class ShippingRate include Spree::Tax::TaxHelpers # Create a new tax calculator. # # @param [Spree::Order] order the order to calculate taxes on # @return [Spree::TaxCalculator::ShippingRate] def initialize(order) @order = order end # Calculate taxes for a shipping rate. # # @param [Spree::ShippingRate] shipping_rate the shipping rate to # calculate taxes on # @return [Array<Spree::Tax::ItemTax>] the calculated taxes for the # shipping rate 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: ) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems