train-tax-calculator 2.2.5 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a05ebcb7498b2fa7b1152d043f4b07dd42738ab
4
- data.tar.gz: 5709aeee64daa1bd1ba57904dd64872a83554766
3
+ metadata.gz: e5496be38bad6b255da10420e3dbdecaffa3040f
4
+ data.tar.gz: de7e01ddd593002e62393481379ddb6556fa4f45
5
5
  SHA512:
6
- metadata.gz: eef56521990386d7d56df369a1fbf04d0f574bf12e4d1cbd1eb27d532fc253a296d33deed94d15ba3f83e5325880951a18e0f05bf0f1c9a3fa9156b9fdd9064c
7
- data.tar.gz: 637b5e0b4c6c324063eb444bffa2ce4f7188e58bc1f957daf3d17e0f8c3fc5b0cca584e2b957d63a7da5ed2c348aed6f3f892b7a6142bbe6fa99785d4b99f7c6
6
+ metadata.gz: e0ae7884e6eed0f4ad5ac9f70a63c5afd425e995c93b4553c88111d884b50516b07fa1355785708d8cbf6f628fba1792ed1817fb12bdd3514847ce78c2838aff
7
+ data.tar.gz: 27bfce9f6de3e042024dca59b208ced8de9ecb29e7db8c8b77bd49b986c9cc54943adc3496afbe8110e7baad06b19ccce13f6aa94b6fdec70cb667b5f63d006c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- train-tax-calculator (2.2.4)
4
+ train-tax-calculator (2.2.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  module Train
2
2
  module Tax
3
3
  module Calculator
4
- VERSION = "2.2.5"
4
+ VERSION = "2.2.6"
5
5
  end
6
6
  end
7
7
  end
@@ -13,22 +13,33 @@ module Train::Tax::Calculator
13
13
  ]
14
14
 
15
15
  def self.compute(basic_salary)
16
- taxable_income = basic_salary - Deductions.get(basic_salary)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-tax-calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez