train-tax-calculator 2.3.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/train/tax/calculator.rb +5 -5
- data/lib/train/tax/calculator/deductions.rb +4 -24
- data/lib/train/tax/calculator/pagibig.rb +6 -2
- data/lib/train/tax/calculator/philhealth.rb +12 -6
- data/lib/train/tax/calculator/sss.rb +22 -12
- data/lib/train/tax/calculator/version.rb +1 -1
- data/lib/train/tax/calculator/withholding_tax.rb +18 -17
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7150b7306d59ca9d3782235a380e862ae66921c8c66fd6ec6e3adf774801e4a8
|
4
|
+
data.tar.gz: 13b7fb6317928c6c7d784afee0c47e8735668aaf14edd1886f41c8f3cff23c82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 035e457a7e4e4fe5fe179999aa1603f40bdb1bee7e4d34c5c094cc91c7fcba762bcf18d1a5a472b4fd9f3fc6799e325ec8d919bab69a5580b57c4ae778bcce99
|
7
|
+
data.tar.gz: 3de1b8c5975c85a06543fc266e370b3247e8d7881f428b0178c58205c4e1d5e20b40ad180848b395317355bf2dd91a0d292e730298bb1f99c3b01aaaac5e7527
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/train/tax/calculator.rb
CHANGED
@@ -14,11 +14,11 @@ module Train
|
|
14
14
|
|
15
15
|
hash = Hash.new
|
16
16
|
|
17
|
-
hash[:sss] = Sss.
|
18
|
-
hash[:pagibig] = Pagibig.
|
19
|
-
hash[:philhealth] = Philhealth.
|
20
|
-
hash[:total_deductions] = Deductions.
|
21
|
-
hash[:withholding_tax] = WithholdingTax.
|
17
|
+
hash[:sss] = Sss.(basic_salary)
|
18
|
+
hash[:pagibig] = Pagibig.(basic_salary)
|
19
|
+
hash[:philhealth] = Philhealth.(basic_salary)
|
20
|
+
hash[:total_deductions] = Deductions.(basic_salary)
|
21
|
+
hash[:withholding_tax] = WithholdingTax.(basic_salary)
|
22
22
|
hash[:net_income] = (basic_salary - hash[:withholding_tax]).round(2)
|
23
23
|
|
24
24
|
hash
|
@@ -3,30 +3,10 @@ module Train
|
|
3
3
|
module Calculator
|
4
4
|
class Deductions
|
5
5
|
|
6
|
-
def self.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def initialize(basic_salary)
|
11
|
-
@basic_salary = basic_salary
|
12
|
-
end
|
13
|
-
|
14
|
-
def compute
|
15
|
-
sss + pagibig + philhealth
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def sss
|
21
|
-
Sss.compute_employee_share(@basic_salary)
|
22
|
-
end
|
23
|
-
|
24
|
-
def pagibig
|
25
|
-
Pagibig.compute(@basic_salary)
|
26
|
-
end
|
27
|
-
|
28
|
-
def philhealth
|
29
|
-
Philhealth.compute(@basic_salary)
|
6
|
+
def self.call(salary)
|
7
|
+
Sss.(salary)[:employee_share] +
|
8
|
+
Pagibig.(salary)[:employee_share] +
|
9
|
+
Philhealth.(salary)[:employee_share]
|
30
10
|
end
|
31
11
|
|
32
12
|
end
|
@@ -4,19 +4,25 @@ module Train::Tax::Calculator
|
|
4
4
|
# 2.75%
|
5
5
|
MULTIPLIER = 0.0275
|
6
6
|
|
7
|
+
def self.call(salary)
|
8
|
+
contribution = compute(salary)
|
9
|
+
|
10
|
+
{
|
11
|
+
employee_share: contribution,
|
12
|
+
employer_share: contribution,
|
13
|
+
total_share: contribution * 2.0,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
7
19
|
def self.compute(salary)
|
8
20
|
if salary <= 10_000.00
|
9
|
-
|
10
21
|
137.50
|
11
|
-
|
12
22
|
elsif salary <= 39_999.99
|
13
|
-
|
14
23
|
((salary * MULTIPLIER) / 2).round(2)
|
15
|
-
|
16
24
|
else
|
17
|
-
|
18
25
|
550.00
|
19
|
-
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
@@ -35,6 +35,28 @@ module Train::Tax::Calculator
|
|
35
35
|
1_000.00 => { er: 83.70, ee: 36.30 },
|
36
36
|
}
|
37
37
|
|
38
|
+
def self.call(salary)
|
39
|
+
{
|
40
|
+
employee_share: employee_share(salary),
|
41
|
+
employer_share: employer_share(salary),
|
42
|
+
total_share: total_share(salary),
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def self.employer_share(salary)
|
49
|
+
compute(salary)[:er]
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.employee_share(salary)
|
53
|
+
compute(salary)[:ee]
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.total_share(salary)
|
57
|
+
employer_share(salary) + employee_share(salary)
|
58
|
+
end
|
59
|
+
|
38
60
|
def self.compute(salary)
|
39
61
|
result = 0.00
|
40
62
|
|
@@ -48,17 +70,5 @@ module Train::Tax::Calculator
|
|
48
70
|
result
|
49
71
|
end
|
50
72
|
|
51
|
-
def self.compute_employer_share(salary)
|
52
|
-
compute(salary)[:er]
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.compute_employee_share(salary)
|
56
|
-
compute(salary)[:ee]
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.compute_total_share(salary)
|
60
|
-
compute_employer_share(salary) + compute_employee_share(salary)
|
61
|
-
end
|
62
|
-
|
63
73
|
end
|
64
74
|
end
|
@@ -10,9 +10,10 @@ module Train::Tax::Calculator
|
|
10
10
|
{ lowest: 666_667.00, highest: Float::INFINITY, base: 200_833.33, excess: 0.35 },
|
11
11
|
]
|
12
12
|
|
13
|
-
def self.
|
14
|
-
taxable_income =
|
15
|
-
tax_bracket
|
13
|
+
def self.call(basic_salary)
|
14
|
+
taxable_income = taxable_income_for(basic_salary)
|
15
|
+
tax_bracket = tax_bracket_for(taxable_income)
|
16
|
+
|
16
17
|
withholding_tax = ((taxable_income - tax_bracket[:lowest]) * tax_bracket[:excess]) + tax_bracket[:base]
|
17
18
|
|
18
19
|
withholding_tax.round(2)
|
@@ -20,23 +21,23 @@ module Train::Tax::Calculator
|
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if basic_salary > 90_000
|
27
|
-
additional_tax = ((basic_salary - 90_000) / 12.00)
|
28
|
-
return initial_net + additional_tax
|
29
|
-
end
|
24
|
+
def self.taxable_income_for(basic_salary)
|
25
|
+
initial_net = basic_salary - Deductions.(basic_salary)
|
30
26
|
|
31
|
-
|
27
|
+
if basic_salary > 90_000
|
28
|
+
additional_tax = ((basic_salary - 90_000) / 12.00)
|
29
|
+
return initial_net + additional_tax
|
32
30
|
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
initial_net
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.tax_bracket_for(taxable_income)
|
36
|
+
LOOKUP_TABLE.select do |bracket|
|
37
|
+
taxable_income >= bracket[:lowest] &&
|
38
|
+
taxable_income < bracket[:highest]
|
39
|
+
end.first
|
40
|
+
end
|
40
41
|
|
41
42
|
end
|
42
43
|
end
|
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:
|
4
|
+
version: 3.0.0
|
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-
|
14
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.7.3
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: TRAIN Tax Calculator for PH 2018
|