Class: Workarea::Pricing::TaxApplier

Inherits:
Object
  • Object
show all
Includes:
TaxApplication
Defined in:
app/models/workarea/pricing/tax_applier.rb

Instance Method Summary collapse

Methods included from TaxApplication

#calculate_tax_amount, #calculate_tax_amounts

Methods included from GuardNegativePrice

#guard_negative_price

Constructor Details

#initialize(shipping, adjustments_to_tax) ⇒ TaxApplier

Returns a new instance of TaxApplier.



6
7
8
9
10
# File 'app/models/workarea/pricing/tax_applier.rb', line 6

def initialize(shipping, adjustments_to_tax)
  @shipping = shipping
  @adjustments_to_tax = adjustments_to_tax
  @adjustments_by_parent = adjustments_to_tax.grouped_by_parent
end

Instance Method Details

#applyObject



16
17
18
19
# File 'app/models/workarea/pricing/tax_applier.rb', line 16

def apply
  @adjustments_to_tax.each { |a| assign_item_tax(a) }
  assign_shipping_tax if @shipping.shipping_service.present?
end

#shipping_totalObject



12
13
14
# File 'app/models/workarea/pricing/tax_applier.rb', line 12

def shipping_total
  @shipping_total ||= @shipping.price_adjustments.adjusting('shipping').sum
end