train-tax-calculator 1.1.1 → 2.0.0

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: 4a8224a7ca2446e1de50cfb235832791681bea69
4
- data.tar.gz: 608f725e4d94a3b7cb22fa64a974b857863141fe
3
+ metadata.gz: 839bd13a6da77f5d694a0611933fe07e14f4a810
4
+ data.tar.gz: 286eaeb2f6f966b33a2a3a7383ff3fc65cadb07c
5
5
  SHA512:
6
- metadata.gz: a8dfc35abafb0705391b5f87672a6af12c0d8da71ae32eba0a52868b7d52e00f6e68ce2933d20161f2ac297ce77f6d762393280629354b1c68bcea4ab13e33f2
7
- data.tar.gz: 721b76230f9a7bc4214818522cc2de0be2416608ba45042ebd36c09d3d9414f7c30a2af3781fd7a86d7139176cca89af34678870e325891c2135de1e5f926bf4
6
+ metadata.gz: d7d9668a4c15c34e5ba54c0451c0a922a29815e8a1a5c7567099a3eb93984ad6350914aa14e483f67d1ef6edce227c070d152624478caf92c1b741b33f24e890
7
+ data.tar.gz: ea1ed4e3e76b75af761a0557b00584accbbd8a65cf7b8dabd4ac2c3bbe525f6b8b49542d656e0743f06f6d5f9681b50c2ded85c74e10b3e963bd0e2da5bade98
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- train-tax-calculator (1.1.0)
4
+ train-tax-calculator (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -30,35 +30,8 @@ If using IRB, require the library first.
30
30
  require 'train/tax/calculator'
31
31
  ```
32
32
 
33
- Get Withholding Tax
34
- ```ruby
35
- Train::Tax::Calculator.withholding_tax(15_000)
36
- ```
37
-
38
- Get Net Income
39
- ```ruby
40
- Train::Tax::Calculator.net_income(15_000)
41
- ```
42
-
43
- Get SSS contribution
44
- ```ruby
45
- sss = Train::Tax::Calculator.for_sss(15_000) # where 15_000 is the basic salary
46
-
47
- # employee share
48
- sss[:es]
49
-
50
- # employer share
51
- sss[:er]
52
- ```
53
-
54
- Get Pagibig contribution
55
- ```ruby
56
- Train::Tax::Calculator.for_pagibig(15_000) # where 15_000 is the basic salary
57
- ```
58
-
59
- Get Philhealth contribution
60
- ```ruby
61
- Train::Tax::Calculator.for_philhealth(15_000) # where 15_000 is the basic salary
33
+ ```Get Tax Details
34
+ Train::Tax::Calculator.(15_000) # returns a hash with basic tax information
62
35
  ```
63
36
 
64
37
  ## Development
@@ -1,7 +1,7 @@
1
1
  module Train
2
2
  module Tax
3
3
  module Calculator
4
- VERSION = "1.1.1"
4
+ VERSION = "2.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -7,6 +7,29 @@ module Train
7
7
  module Tax
8
8
  module Calculator
9
9
 
10
+ class << self
11
+ def call(basic_salary)
12
+ hash = Hash.new
13
+
14
+ hash[:sss] = for_sss_es(basic_salary)
15
+ hash[:philhealth] = for_philhealth(basic_salary)
16
+ hash[:pagibig] = for_pagibig(basic_salary)
17
+ hash[:total_deductions] = hash[:sss] + hash[:philhealth] + hash[:pagibig]
18
+ hash[:withholding_tax] = withholding_tax(basic_salary)
19
+ hash[:net_income] = net_income(basic_salary)
20
+
21
+ hash
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ HIGHEST_BRACKET = 666_667.00
28
+ HIGHER_BRACKET = 166_667.00
29
+ HIGH_BRACKET = 66_667.00
30
+ LOW_BRACKET = 33_333.00
31
+ LOWEST_BRACKET = 20_833.00
32
+
10
33
  class << self
11
34
 
12
35
  def withholding_tax(basic_salary)
@@ -19,6 +42,34 @@ module Train
19
42
  def net_income(basic_salary)
20
43
  basic_salary - withholding_tax(basic_salary)
21
44
  end
45
+
46
+ def compute_withholding_for(income)
47
+ if income >= HIGHEST_BRACKET
48
+
49
+ 200_833.33 + ((income - HIGHEST_BRACKET) * 0.35)
50
+
51
+ elsif income >= HIGHER_BRACKET
52
+
53
+ 40_833.33 + ((income - HIGHER_BRACKET) * 0.32)
54
+
55
+ elsif income >= HIGH_BRACKET
56
+
57
+ 10_833.33 + ((income - HIGH_BRACKET) * 0.30)
58
+
59
+ elsif income >= LOW_BRACKET
60
+
61
+ 2_500.00 + ((income - LOW_BRACKET) * 0.25)
62
+
63
+ elsif income >= LOWEST_BRACKET
64
+
65
+ 0.00 + ((income - LOWEST_BRACKET) * 0.20)
66
+
67
+ else
68
+
69
+ 0.00
70
+
71
+ end
72
+ end
22
73
 
23
74
  def for_philhealth(basic_salary)
24
75
  Philhealth.compute(basic_salary)
@@ -39,43 +90,6 @@ module Train
39
90
  def for_sss_er(basic_salary)
40
91
  Sss.compute_employer_share(basic_salary)
41
92
  end
42
-
43
- end
44
-
45
- private
46
-
47
- HIGHEST_BRACKET = 666_667.00
48
- HIGHER_BRACKET = 166_667.00
49
- HIGH_BRACKET = 66_667.00
50
- LOW_BRACKET = 33_333.00
51
- LOWEST_BRACKET = 20_833.00
52
-
53
- def self.compute_withholding_for(income)
54
- if income >= HIGHEST_BRACKET
55
-
56
- 200_833.33 + ((income - HIGHEST_BRACKET) * 0.35)
57
-
58
- elsif income >= HIGHER_BRACKET
59
-
60
- 40_833.33 + ((income - HIGHER_BRACKET) * 0.32)
61
-
62
- elsif income >= HIGH_BRACKET
63
-
64
- 10_833.33 + ((income - HIGH_BRACKET) * 0.30)
65
-
66
- elsif income >= LOW_BRACKET
67
-
68
- 2_500.00 + ((income - LOW_BRACKET) * 0.25)
69
-
70
- elsif income >= LOWEST_BRACKET
71
-
72
- 0.00 + ((income - LOWEST_BRACKET) * 0.20)
73
-
74
- else
75
-
76
- 0.00
77
-
78
- end
79
93
  end
80
94
 
81
95
  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: 1.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez