lib/train/tax/calculator/withholding_tax.rb in train-tax-calculator-2.2.1 vs lib/train/tax/calculator/withholding_tax.rb in train-tax-calculator-2.2.2
- old
+ new
@@ -1,20 +1,20 @@
module Train::Tax::Calculator
module WithholdingTax
- TRAIN_TAX_TABLE = [
+ 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.000, 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: +1.00/0.00, base: 200_833.33, excess: 0.35 },
+ { lowest: 666_667.00, highest: Float::INFINITY, base: 200_833.33, excess: 0.35 },
]
- def self.compute(deductions, basic_salary)
- taxable_income = basic_salary - deductions
+ def self.compute(basic_salary)
+ taxable_income = basic_salary - Deductions.get(basic_salary)
- tax_bracket = TRAIN_TAX_TABLE.select do |bracket|
+ tax_bracket = LOOKUP_TABLE.select do |bracket|
taxable_income >= bracket[:lowest] &&
taxable_income < bracket[:highest]
end.first
withholding_tax = tax_bracket[:base] + ((taxable_income - tax_bracket[:lowest]) * tax_bracket[:excess])