train-tax-calculator 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 954f065606cfde335995e52a05b4a8ac08e8e95f
4
- data.tar.gz: acaa12454f0d1a5179b7aef2971caa158afd2a4a
3
+ metadata.gz: f4a162b90d20cf329a2ab7e4fb698c96812bda2c
4
+ data.tar.gz: 0bae54b30eacaa90bb845b8865ec34c20e2425f1
5
5
  SHA512:
6
- metadata.gz: 1ca631c3e7e1ce7b7c0f9692c5938fb03dcdcaad1f5c792068d9f9b600785026d44edc3276895bb161396cc3c68043812a4efe94449dbd3c483041cb5ed305b8
7
- data.tar.gz: 3bf3cb78f53a82178c88cb151228ba331298d5206778efc646e3db5d6f8b484a3e13651d68cd906a65fda03ab836b428355dfd9875e7856fd45daea1cef14f58
6
+ metadata.gz: 343cbd2bb9a9cb9bc6ec42daa774b12afd5c163b202504682895f27b9d92adea6afdbf58b2045fde4c0f9397fde61fe8045b35363f1ce080bf8729e5234e25ab
7
+ data.tar.gz: da8535ad40bb339de5c84a87e48cc31a03d75518af99503b428cef3edca481a299ab61dec74fe8364776b6d9556fc1fda3fe51a90da29c7de2dcb883263114b2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- train-tax-calculator (2.1.0)
4
+ train-tax-calculator (2.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -3,6 +3,7 @@ require "train/tax/calculator/philhealth"
3
3
  require "train/tax/calculator/pagibig"
4
4
  require "train/tax/calculator/sss"
5
5
  require "train/tax/calculator/deductions"
6
+ require "train/tax/calculator/withholding_tax"
6
7
 
7
8
  module Train
8
9
  module Tax
@@ -15,56 +16,12 @@ module Train
15
16
  hash[:pagibig] = Pagibig.compute(basic_salary)
16
17
  hash[:philhealth] = Philhealth.compute(basic_salary)
17
18
  hash[:total_deductions] = Deductions.get(basic_salary)
18
- hash[:withholding_tax] = withholding_tax(hash[:total_deductions], basic_salary)
19
+ hash[:withholding_tax] = WithholdingTax.compute(hash[:total_deductions], basic_salary)
19
20
  hash[:net_income] = basic_salary - hash[:withholding_tax]
20
21
 
21
22
  hash
22
23
  end
23
24
 
24
- private
25
-
26
- HIGHEST_BRACKET = 666_667.00
27
- HIGHER_BRACKET = 166_667.00
28
- HIGH_BRACKET = 66_667.00
29
- LOW_BRACKET = 33_333.00
30
- LOWEST_BRACKET = 20_833.00
31
-
32
- class << self
33
-
34
- def withholding_tax(deductions, basic_salary)
35
- taxable_income = basic_salary - deductions
36
- compute_withholding_for(taxable_income).round(2)
37
- end
38
-
39
- def compute_withholding_for(income)
40
- if income >= HIGHEST_BRACKET
41
-
42
- 200_833.33 + ((income - HIGHEST_BRACKET) * 0.35)
43
-
44
- elsif income >= HIGHER_BRACKET
45
-
46
- 40_833.33 + ((income - HIGHER_BRACKET) * 0.32)
47
-
48
- elsif income >= HIGH_BRACKET
49
-
50
- 10_833.33 + ((income - HIGH_BRACKET) * 0.30)
51
-
52
- elsif income >= LOW_BRACKET
53
-
54
- 2_500.00 + ((income - LOW_BRACKET) * 0.25)
55
-
56
- elsif income >= LOWEST_BRACKET
57
-
58
- 0.00 + ((income - LOWEST_BRACKET) * 0.20)
59
-
60
- else
61
-
62
- 0.00
63
-
64
- end
65
- end
66
-
67
- end
68
25
  end
69
26
  end
70
27
  end
@@ -1,7 +1,7 @@
1
1
  module Train
2
2
  module Tax
3
3
  module Calculator
4
- VERSION = "2.2.0"
4
+ VERSION = "2.2.1"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,27 @@
1
+ module Train::Tax::Calculator
2
+ module WithholdingTax
3
+
4
+ TRAIN_TAX_TABLE = [
5
+ { lowest: 0.00, highest: 20_833.00, base: 0.00, excess: 0.00 },
6
+ { lowest: 20_833.00, highest: 33_333.00, base: 0.00, excess: 0.20 },
7
+ { lowest: 33_333.00, highest: 66_667.00, base: 2_500.00, excess: 0.25 },
8
+ { lowest: 66_667.000, highest: 166_667.00, base: 10_833.33, excess: 0.30 },
9
+ { lowest: 166_667.00, highest: 666_667.00, base: 40_833.33, excess: 0.32 },
10
+ { lowest: 666_667.00, highest: +1.00/0.00, base: 200_833.33, excess: 0.35 },
11
+ ]
12
+
13
+ def self.compute(deductions, basic_salary)
14
+ taxable_income = basic_salary - deductions
15
+
16
+ tax_bracket = TRAIN_TAX_TABLE.select do |bracket|
17
+ taxable_income >= bracket[:lowest] &&
18
+ taxable_income < bracket[:highest]
19
+ end.first
20
+
21
+ withholding_tax = tax_bracket[:base] + ((taxable_income - tax_bracket[:lowest]) * tax_bracket[:excess])
22
+ withholding_tax.round(2)
23
+ end
24
+
25
+ end
26
+ end
27
+
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.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2018-02-06 00:00:00.000000000 Z
14
+ date: 2018-02-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -81,6 +81,7 @@ files:
81
81
  - lib/train/tax/calculator/philhealth.rb
82
82
  - lib/train/tax/calculator/sss.rb
83
83
  - lib/train/tax/calculator/version.rb
84
+ - lib/train/tax/calculator/withholding_tax.rb
84
85
  - train-tax-calculator.gemspec
85
86
  homepage: https://markjoelchavez.com
86
87
  licenses: []