Module: Train::Tax::Calculator::WithholdingTax

Defined in:
lib/train/tax/calculator/withholding_tax.rb

Constant Summary collapse

LOOKUP_TABLE =
[
  { lowest:       0.00, highest:  20_833.00, base:       0.00, excess: 0.00 },
  { lowest:  20_833.00, highest:  33_333.00, base:       0.00, excess: 0.20 },
  { lowest:  33_333.00, highest:  66_667.00, base:   2_500.00, excess: 0.25 },
  { lowest: 66_667.00, highest: 166_667.00, base:  10_833.33, excess: 0.30 },
  { lowest: 166_667.00, highest: 666_667.00, base:  40_833.33, excess: 0.32 },
  { lowest: 666_667.00, highest: Float::INFINITY, base: 200_833.33, excess: 0.35 },
]

Class Method Summary collapse

Class Method Details

.compute(basic_salary) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/train/tax/calculator/withholding_tax.rb', line 15

def self.compute(basic_salary)
  taxable_income = compute_taxable_income_for(basic_salary)
  tax_bracket = get_tax_bracket_for(taxable_income)
  withholding_tax = ((taxable_income - tax_bracket[:lowest]) * tax_bracket[:excess]) + tax_bracket[:base]

  withholding_tax.round(2)
end