train-tax-calculator 2.3.2 → 3.0.0

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
- SHA1:
3
- metadata.gz: 7c5d1b04541403c09932b612d8e6c4058516fbb1
4
- data.tar.gz: c4277e81825638187ccf6c7d7b14e81a49aa0d87
2
+ SHA256:
3
+ metadata.gz: 7150b7306d59ca9d3782235a380e862ae66921c8c66fd6ec6e3adf774801e4a8
4
+ data.tar.gz: 13b7fb6317928c6c7d784afee0c47e8735668aaf14edd1886f41c8f3cff23c82
5
5
  SHA512:
6
- metadata.gz: 2aa89eab832f3c88737556bcf3c831dfcd47d9b0da12974fa02620078efc16d7c65e25b389cc4e4c2a74bfa7497e78c1096ce868e51e1ff89250c203c23bc11e
7
- data.tar.gz: 448b45e7c142b531e48b8cbd714dbf2b90800544f1e6eb09b6f67a4acafdb428f2cacbb6ec6aa337762d1dd5dfd9cccb0dcbcda0af08f10d0fa17b82a200bcc0
6
+ metadata.gz: 035e457a7e4e4fe5fe179999aa1603f40bdb1bee7e4d34c5c094cc91c7fcba762bcf18d1a5a472b4fd9f3fc6799e325ec8d919bab69a5580b57c4ae778bcce99
7
+ data.tar.gz: 3de1b8c5975c85a06543fc266e370b3247e8d7881f428b0178c58205c4e1d5e20b40ad180848b395317355bf2dd91a0d292e730298bb1f99c3b01aaaac5e7527
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- train-tax-calculator (2.3.0)
4
+ train-tax-calculator (2.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -38,4 +38,4 @@ DEPENDENCIES
38
38
  train-tax-calculator!
39
39
 
40
40
  BUNDLED WITH
41
- 1.16.1
41
+ 1.16.2
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Add this line to your application's Gemfile:
6
6
 
7
7
  ```ruby
8
- gem 'train-tax-calculator'
8
+ gem 'train-tax-calculator', '~> 3.0'
9
9
  ```
10
10
 
11
11
  And then execute:
@@ -14,11 +14,11 @@ module Train
14
14
 
15
15
  hash = Hash.new
16
16
 
17
- hash[:sss] = Sss.compute_employee_share(basic_salary)
18
- hash[:pagibig] = Pagibig.compute(basic_salary)
19
- hash[:philhealth] = Philhealth.compute(basic_salary)
20
- hash[:total_deductions] = Deductions.compute(basic_salary)
21
- hash[:withholding_tax] = WithholdingTax.compute(basic_salary)
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.compute(basic_salary)
7
- new(basic_salary).compute
8
- end
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
@@ -1,8 +1,12 @@
1
1
  module Train::Tax::Calculator
2
2
  module Pagibig
3
3
 
4
- def self.compute(salary)
5
- 100.00
4
+ def self.call(salary)
5
+ {
6
+ employee_share: 100.00,
7
+ employer_share: 100.00,
8
+ total_share: 200.00,
9
+ }
6
10
  end
7
11
 
8
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
@@ -1,7 +1,7 @@
1
1
  module Train
2
2
  module Tax
3
3
  module Calculator
4
- VERSION = "2.3.2"
4
+ VERSION = "3.0.0"
5
5
  end
6
6
  end
7
7
  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.compute(basic_salary)
14
- taxable_income = compute_taxable_income_for(basic_salary)
15
- tax_bracket = get_tax_bracket_for(taxable_income)
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
- def self.compute_taxable_income_for(basic_salary)
24
- initial_net = basic_salary - Deductions.compute(basic_salary)
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
- initial_net
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
- def self.get_tax_bracket_for(taxable_income)
35
- LOOKUP_TABLE.select do |bracket|
36
- taxable_income >= bracket[:lowest] &&
37
- taxable_income < bracket[:highest]
38
- end.first
39
- end
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: 2.3.2
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-02-08 00:00:00.000000000 Z
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.6.12
120
+ rubygems_version: 2.7.3
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: TRAIN Tax Calculator for PH 2018