train-tax-calculator 2.0.2 → 2.1.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: e75c2fa63da77c900496e7560a2d6527c4b44060
4
- data.tar.gz: 668c9b05b5f7bedc7b5ad3342f4b45106fd0c793
3
+ metadata.gz: b91e87ac4c47739dda0ba2f96eb062a7a3673ba3
4
+ data.tar.gz: cdd6e712c3a7f441e4e5bc14360caa4742c46b01
5
5
  SHA512:
6
- metadata.gz: 697bc9288a0cd1556a3c94199eb96e7f10dc0558ef46e53de365c17eae16947ff278cbe219146ae71ff8a861eec710f712ee43588cf58f814e1dcec88bcff9b2
7
- data.tar.gz: dbc755e9e52d489f6aabc6e6b943a5bc09820da4b116bee82921900c11fb37d32e19686cbea8f4c8b2943faf3622a652494d92dd880884aaba6b12ab02f85f29
6
+ metadata.gz: 44121856e0b75c4be125af628dc4e1c2b1676d8e5f0bf0ef210dfbd38699081cc39c328f8fd4e35e1ba600bbaa16f23573630d13662a29473aa1a4e4c32614be
7
+ data.tar.gz: 468ca0cadcd0f6d3069099b009b8d5470e700a9a45c9914b3005e38e9afae1edeab74e7fb31a17a87974cecb74e2ec8ba8c0e0d3de49962c5583af9785563b25
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- train-tax-calculator (2.0.1)
4
+ train-tax-calculator (2.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,35 @@
1
+ module Train
2
+ module Tax
3
+ module Calculator
4
+ class Deductions
5
+
6
+ def self.get(basic_salary)
7
+ new(basic_salary).get
8
+ end
9
+
10
+ def initialize(basic_salary)
11
+ @basic_salary = basic_salary
12
+ end
13
+
14
+ def get
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)
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,7 +1,7 @@
1
1
  module Train
2
2
  module Tax
3
3
  module Calculator
4
- VERSION = "2.0.2"
4
+ VERSION = "2.1.0"
5
5
  end
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@ require "train/tax/calculator/version"
2
2
  require "train/tax/calculator/philhealth"
3
3
  require "train/tax/calculator/pagibig"
4
4
  require "train/tax/calculator/sss"
5
+ require "train/tax/calculator/deductions"
5
6
 
6
7
  module Train
7
8
  module Tax
@@ -10,12 +11,12 @@ module Train
10
11
  def self.call(basic_salary)
11
12
  hash = Hash.new
12
13
 
13
- hash[:sss] = for_sss_es(basic_salary)
14
- hash[:philhealth] = for_philhealth(basic_salary)
15
- hash[:pagibig] = for_pagibig(basic_salary)
16
- hash[:total_deductions] = hash[:sss] + hash[:philhealth] + hash[:pagibig]
17
- hash[:withholding_tax] = withholding_tax(basic_salary)
18
- hash[:net_income] = basic_salary - hash[:withholding_tax]
14
+ hash[:sss] = Sss.compute_employee_share(basic_salary)
15
+ hash[:pagibig] = Pagibig.compute(basic_salary)
16
+ hash[:philhealth] = Philhealth.compute(basic_salary)
17
+ hash[:total_deductions] = Deductions.get(basic_salary)
18
+ hash[:withholding_tax] = withholding_tax(hash[:total_deductions], basic_salary)
19
+ hash[:net_income] = basic_salary - hash[:withholding_tax]
19
20
 
20
21
  hash
21
22
  end
@@ -30,10 +31,8 @@ module Train
30
31
 
31
32
  class << self
32
33
 
33
- def withholding_tax(basic_salary)
34
- deductions = for_philhealth(basic_salary) + for_pagibig(basic_salary) + for_sss_es(basic_salary)
34
+ def withholding_tax(deductions, basic_salary)
35
35
  taxable_income = basic_salary - deductions
36
-
37
36
  compute_withholding_for(taxable_income).round(2)
38
37
  end
39
38
 
@@ -65,27 +64,7 @@ module Train
65
64
  end
66
65
  end
67
66
 
68
- def for_philhealth(basic_salary)
69
- Philhealth.compute(basic_salary)
70
- end
71
-
72
- def for_pagibig(basic_salary)
73
- Pagibig.compute(basic_salary)
74
- end
75
-
76
- def for_sss(basic_salary)
77
- Sss.compute(basic_salary)
78
- end
79
-
80
- def for_sss_es(basic_salary)
81
- Sss.compute_employee_share(basic_salary)
82
- end
83
-
84
- def for_sss_er(basic_salary)
85
- Sss.compute_employer_share(basic_salary)
86
- end
87
67
  end
88
-
89
68
  end
90
69
  end
91
70
  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.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez
@@ -76,6 +76,7 @@ files:
76
76
  - bin/console
77
77
  - bin/setup
78
78
  - lib/train/tax/calculator.rb
79
+ - lib/train/tax/calculator/deductions.rb
79
80
  - lib/train/tax/calculator/pagibig.rb
80
81
  - lib/train/tax/calculator/philhealth.rb
81
82
  - lib/train/tax/calculator/sss.rb