Module: Workarea::Pricing::TaxApplication

Extended by:
ActiveSupport::Concern
Includes:
GuardNegativePrice
Included in:
ItemTaxApplier, TaxApplier
Defined in:
app/models/workarea/pricing/tax_application.rb

Instance Method Summary collapse

Methods included from GuardNegativePrice

#guard_negative_price

Instance Method Details

#calculate_tax_amount(amount, percentage) ⇒ Object



15
16
17
18
# File 'app/models/workarea/pricing/tax_application.rb', line 15

def calculate_tax_amount(amount, percentage)
  return 0.to_m unless percentage.present?
  guard_negative_price { amount * percentage }
end

#calculate_tax_amounts(taxable_amount, rate) ⇒ Object



7
8
9
10
11
12
13
# File 'app/models/workarea/pricing/tax_application.rb', line 7

def calculate_tax_amounts(taxable_amount, rate)
  {
    'country_amount' => calculate_tax_amount(taxable_amount, rate.country_percentage),
    'region_amount' => calculate_tax_amount(taxable_amount, rate.region_percentage),
    'postal_code_amount' => calculate_tax_amount(taxable_amount, rate.postal_code_percentage)
  }
end