Class: Workarea::Pricing::Calculators::TaxCalculator
- Inherits:
-
Object
- Object
- Workarea::Pricing::Calculators::TaxCalculator
- Includes:
- Workarea::Pricing::Calculator
- Defined in:
- app/models/workarea/pricing/calculators/tax_calculator.rb
Instance Method Summary collapse
- #adjust ⇒ Object
- #adjust_not_shipped_items_tax ⇒ Object
- #adjust_shipped_items_tax ⇒ Object
- #not_shipped_items_price_adjustments ⇒ Object
-
#price_adjustments_for(shipping) ⇒ PriceAdjustmentSet
deprecated
Deprecated.
As of v3.5, this class supports applying tax directly to
- #shipped_items_price_adjustments ⇒ Object
Methods included from Workarea::Pricing::Calculator
Instance Method Details
#adjust ⇒ Object
7 8 9 10 |
# File 'app/models/workarea/pricing/calculators/tax_calculator.rb', line 7 def adjust adjust_shipped_items_tax adjust_not_shipped_items_tax end |
#adjust_not_shipped_items_tax ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/models/workarea/pricing/calculators/tax_calculator.rb', line 21 def adjust_not_shipped_items_tax return unless payment&.address.present? ItemTaxApplier.new( payment.address, not_shipped_items_price_adjustments ).apply end |
#adjust_shipped_items_tax ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/models/workarea/pricing/calculators/tax_calculator.rb', line 12 def adjust_shipped_items_tax shippings.each do |tmp_shipping| next unless tmp_shipping.address.present? adjustments_to_tax = price_adjustments_for(tmp_shipping) TaxApplier.new(tmp_shipping, adjustments_to_tax).apply end end |
#not_shipped_items_price_adjustments ⇒ Object
36 37 38 39 40 |
# File 'app/models/workarea/pricing/calculators/tax_calculator.rb', line 36 def not_shipped_items_price_adjustments PriceAdjustmentSet.new( order.items.reject(&:shipping?).flat_map(&:price_adjustments) ) end |
#price_adjustments_for(shipping) ⇒ PriceAdjustmentSet
Deprecated.
As of v3.5, this class supports applying tax directly to
items when they do not require shipping. As a result tax calculation is split on this distinction and this method is no longer sufficient. Instead modify the appropriate method to change the set of price adjustments to consider for tax calculation.
50 51 52 |
# File 'app/models/workarea/pricing/calculators/tax_calculator.rb', line 50 def price_adjustments_for(shipping) shipped_items_price_adjustments end |
#shipped_items_price_adjustments ⇒ Object
30 31 32 33 34 |
# File 'app/models/workarea/pricing/calculators/tax_calculator.rb', line 30 def shipped_items_price_adjustments PriceAdjustmentSet.new( order.items.select(&:shipping?).flat_map(&:price_adjustments) ) end |