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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/train/tax/calculator.rb +2 -45
- data/lib/train/tax/calculator/version.rb +1 -1
- data/lib/train/tax/calculator/withholding_tax.rb +27 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4a162b90d20cf329a2ab7e4fb698c96812bda2c
|
4
|
+
data.tar.gz: 0bae54b30eacaa90bb845b8865ec34c20e2425f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 343cbd2bb9a9cb9bc6ec42daa774b12afd5c163b202504682895f27b9d92adea6afdbf58b2045fde4c0f9397fde61fe8045b35363f1ce080bf8729e5234e25ab
|
7
|
+
data.tar.gz: da8535ad40bb339de5c84a87e48cc31a03d75518af99503b428cef3edca481a299ab61dec74fe8364776b6d9556fc1fda3fe51a90da29c7de2dcb883263114b2
|
data/Gemfile.lock
CHANGED
data/lib/train/tax/calculator.rb
CHANGED
@@ -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] =
|
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
|
@@ -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.
|
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-
|
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: []
|