train-tax-calculator 2.2.5 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/train/tax/calculator/version.rb +1 -1
- data/lib/train/tax/calculator/withholding_tax.rb +23 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5496be38bad6b255da10420e3dbdecaffa3040f
|
4
|
+
data.tar.gz: de7e01ddd593002e62393481379ddb6556fa4f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0ae7884e6eed0f4ad5ac9f70a63c5afd425e995c93b4553c88111d884b50516b07fa1355785708d8cbf6f628fba1792ed1817fb12bdd3514847ce78c2838aff
|
7
|
+
data.tar.gz: 27bfce9f6de3e042024dca59b208ced8de9ecb29e7db8c8b77bd49b986c9cc54943adc3496afbe8110e7baad06b19ccce13f6aa94b6fdec70cb667b5f63d006c
|
data/Gemfile.lock
CHANGED
@@ -13,22 +13,33 @@ module Train::Tax::Calculator
|
|
13
13
|
]
|
14
14
|
|
15
15
|
def self.compute(basic_salary)
|
16
|
-
taxable_income =
|
17
|
-
|
18
|
-
if basic_salary > 90_000
|
19
|
-
monthly_taxable = ((basic_salary - 90_000) / 12.00)
|
20
|
-
taxable_income = taxable_income + monthly_taxable
|
21
|
-
end
|
22
|
-
|
23
|
-
tax_bracket = LOOKUP_TABLE.select do |bracket|
|
24
|
-
taxable_income >= bracket[:lowest] &&
|
25
|
-
taxable_income < bracket[:highest]
|
26
|
-
end.first
|
27
|
-
|
16
|
+
taxable_income = compute_taxable_income_for(basic_salary)
|
17
|
+
tax_bracket = get_tax_bracket_for(taxable_income)
|
28
18
|
withholding_tax = ((taxable_income - tax_bracket[:lowest]) * tax_bracket[:excess]) + tax_bracket[:base]
|
19
|
+
|
29
20
|
withholding_tax.round(2)
|
30
21
|
end
|
31
22
|
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.compute_taxable_income_for(basic_salary)
|
26
|
+
initial_net = basic_salary - Deductions.get(basic_salary)
|
27
|
+
|
28
|
+
if basic_salary > 90_000
|
29
|
+
additional_tax = ((basic_salary - 90_000) / 12.00)
|
30
|
+
return initial_net + additional_tax
|
31
|
+
end
|
32
|
+
|
33
|
+
initial_net
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.get_tax_bracket_for(taxable_income)
|
37
|
+
LOOKUP_TABLE.select do |bracket|
|
38
|
+
taxable_income >= bracket[:lowest] &&
|
39
|
+
taxable_income < bracket[:highest]
|
40
|
+
end.first
|
41
|
+
end
|
42
|
+
|
32
43
|
end
|
33
44
|
end
|
34
45
|
|