philippines_withholdingtax 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/philippines_withholdingtax.rb +75 -0
- data/lib/tables/tables.rb +132 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6001bc5045abfcf8207b3a4e50665d98d337837b
|
4
|
+
data.tar.gz: ff23a7252a78cfe912125bd92e1394fe81c5c7fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8357a3561db84ac5fb7c191abf115db0683cfe84830f06083df8c3123cf2a39d67c1868357c288876fa8aab2163097bd49efc8b7b15628678c77bb64bfc4fe7f
|
7
|
+
data.tar.gz: f438e98f865d7537ea0e1da8925deb088937df4d000f5de44baafbe6de850f38bcf346737e5929c74de6a1af44336c1dd60e09ba7791504f98f65e6206d8301f
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class WithholdingTaxCalculator
|
2
|
+
# Calculate your Withholding Tax!
|
3
|
+
#
|
4
|
+
# Example:
|
5
|
+
# >> WithholdingTaxCalculator.new(payroll_period: "daily", 9000).call
|
6
|
+
# => 2469.19
|
7
|
+
#
|
8
|
+
# Arguments
|
9
|
+
# payroll_period: (string), possible values: ["daily", "monthly", "semimonthly", "monthly"]
|
10
|
+
# compensation_level: (number)
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
@payroll_period = options[:payroll_period]
|
14
|
+
@compensation_level = options[:compensation_level]
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
set_period
|
19
|
+
set_bracket
|
20
|
+
set_minimum_tax
|
21
|
+
set_percentage_on_excess
|
22
|
+
calculate_excess
|
23
|
+
calculate_tax_from_excess
|
24
|
+
return_withholding_tax
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def set_period
|
30
|
+
@period = case @payroll_period
|
31
|
+
when "daily" then DAILY
|
32
|
+
when "weekly" then WEEKLY
|
33
|
+
when "semimonthly" then SEMIMONTHLY
|
34
|
+
when "monthly" then MONTHLY
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_bracket
|
39
|
+
if @compensation_level >= @period[:bracket_6][:compensation_level]
|
40
|
+
@bracket = @period[:bracket_6]
|
41
|
+
elsif @compensation_level >= @period[:bracket_5][:compensation_level]
|
42
|
+
@bracket = @period[:bracket_5]
|
43
|
+
elsif @compensation_level >= @period[:bracket_4][:compensation_level]
|
44
|
+
@bracket = @period[:bracket_4]
|
45
|
+
elsif @compensation_level >= @period[:bracket_3][:compensation_level]
|
46
|
+
@bracket = @period[:bracket_3]
|
47
|
+
elsif @compensation_level >= @period[:bracket_2][:compensation_level]
|
48
|
+
@bracket = @period[:bracket_2]
|
49
|
+
elsif @compensation_level >= @period[:bracket_1][:compensation_level]
|
50
|
+
@bracket = @period[:bracket_1]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_minimum_tax
|
55
|
+
@minimum_tax = @bracket[:minimum_tax]
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_percentage_on_excess
|
59
|
+
@percentage_on_excess = @bracket[:percentage_on_excess]
|
60
|
+
end
|
61
|
+
|
62
|
+
def calculate_excess
|
63
|
+
@excess = @compensation_level - @bracket[:compensation_level]
|
64
|
+
end
|
65
|
+
|
66
|
+
def calculate_tax_from_excess
|
67
|
+
@tax_from_excess = @excess * @percentage_on_excess
|
68
|
+
end
|
69
|
+
|
70
|
+
def return_withholding_tax
|
71
|
+
@minimum_tax + @tax_from_excess
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
require 'tables/tables'
|
@@ -0,0 +1,132 @@
|
|
1
|
+
DAILY = {
|
2
|
+
bracket_1: {
|
3
|
+
compensation_level: 0,
|
4
|
+
minimum_tax: 0,
|
5
|
+
percentage_on_excess: 0
|
6
|
+
},
|
7
|
+
bracket_2: {
|
8
|
+
compensation_level: 685,
|
9
|
+
minimum_tax: 0,
|
10
|
+
percentage_on_excess: 0.2
|
11
|
+
},
|
12
|
+
bracket_3: {
|
13
|
+
compensation_level: 1096,
|
14
|
+
minimum_tax: 82.19,
|
15
|
+
percentage_on_excess: 0.25
|
16
|
+
},
|
17
|
+
bracket_4: {
|
18
|
+
compensation_level: 2192,
|
19
|
+
minimum_tax: 356.16,
|
20
|
+
percentage_on_excess: 0.3
|
21
|
+
},
|
22
|
+
bracket_5: {
|
23
|
+
compensation_level: 5479,
|
24
|
+
minimum_tax: 1342.47,
|
25
|
+
percentage_on_excess: 0.32
|
26
|
+
},
|
27
|
+
bracket_6: {
|
28
|
+
compensation_level: 21918,
|
29
|
+
minimum_tax: 6602.74,
|
30
|
+
percentage_on_excess: 0.35
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
WEEKLY = {
|
35
|
+
bracket_1: {
|
36
|
+
compensation_level: 0,
|
37
|
+
minimum_tax: 0,
|
38
|
+
percentage_on_excess: 0
|
39
|
+
},
|
40
|
+
bracket_2: {
|
41
|
+
compensation_level: 4808,
|
42
|
+
minimum_tax: 0,
|
43
|
+
percentage_on_excess: 0.2
|
44
|
+
},
|
45
|
+
bracket_3: {
|
46
|
+
compensation_level: 7692,
|
47
|
+
minimum_tax: 576.92,
|
48
|
+
percentage_on_excess: 0.25
|
49
|
+
},
|
50
|
+
bracket_4: {
|
51
|
+
compensation_level: 15385,
|
52
|
+
minimum_tax: 2500,
|
53
|
+
percentage_on_excess: 0.3
|
54
|
+
},
|
55
|
+
bracket_5: {
|
56
|
+
compensation_level: 38462,
|
57
|
+
minimum_tax: 9423.08,
|
58
|
+
percentage_on_excess: 0.32
|
59
|
+
},
|
60
|
+
bracket_6: {
|
61
|
+
compensation_level: 153846,
|
62
|
+
minimum_tax: 46346.15,
|
63
|
+
percentage_on_excess: 0.35
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
SEMIMONTHLY = {
|
68
|
+
bracket_1: {
|
69
|
+
compensation_level: 0,
|
70
|
+
minimum_tax: 0,
|
71
|
+
percentage_on_excess: 0
|
72
|
+
},
|
73
|
+
bracket_2: {
|
74
|
+
compensation_level: 10417,
|
75
|
+
minimum_tax: 0,
|
76
|
+
percentage_on_excess: 0.2
|
77
|
+
},
|
78
|
+
bracket_3: {
|
79
|
+
compensation_level: 16667,
|
80
|
+
minimum_tax: 1250.00,
|
81
|
+
percentage_on_excess: 0.25
|
82
|
+
},
|
83
|
+
bracket_4: {
|
84
|
+
compensation_level: 33333,
|
85
|
+
minimum_tax: 5416.67,
|
86
|
+
percentage_on_excess: 0.3
|
87
|
+
},
|
88
|
+
bracket_5: {
|
89
|
+
compensation_level: 83333,
|
90
|
+
minimum_tax: 20416.67,
|
91
|
+
percentage_on_excess: 0.32
|
92
|
+
},
|
93
|
+
bracket_6: {
|
94
|
+
compensation_level: 333333,
|
95
|
+
minimum_tax: 100416.67,
|
96
|
+
percentage_on_excess: 0.35
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
MONTHLY = {
|
101
|
+
bracket_1: {
|
102
|
+
compensation_level: 0,
|
103
|
+
minimum_tax: 0,
|
104
|
+
percentage_on_excess: 0
|
105
|
+
},
|
106
|
+
bracket_2: {
|
107
|
+
compensation_level: 20833,
|
108
|
+
minimum_tax: 0,
|
109
|
+
percentage_on_excess: 0.2
|
110
|
+
},
|
111
|
+
bracket_3: {
|
112
|
+
compensation_level: 33333,
|
113
|
+
minimum_tax: 2500,
|
114
|
+
percentage_on_excess: 0.25
|
115
|
+
},
|
116
|
+
bracket_4: {
|
117
|
+
compensation_level: 66667,
|
118
|
+
minimum_tax: 10833.33,
|
119
|
+
percentage_on_excess: 0.3
|
120
|
+
},
|
121
|
+
bracket_5: {
|
122
|
+
compensation_level: 166667,
|
123
|
+
minimum_tax: 40833.33,
|
124
|
+
percentage_on_excess: 0.32
|
125
|
+
},
|
126
|
+
bracket_6: {
|
127
|
+
compensation_level: 666667,
|
128
|
+
minimum_tax: 200833.33,
|
129
|
+
percentage_on_excess: 0.35
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: philippines_withholdingtax
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rei Ramos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Calculates withholding tax from given compensation level. Effective January
|
14
|
+
1, 2018 to December 31, 2022
|
15
|
+
email: reiallenramos@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/philippines_withholdingtax.rb
|
21
|
+
- lib/tables/tables.rb
|
22
|
+
homepage: http://rubygems.org/gems
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.6.11
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Withholding Tax calculator as specified by BIR
|
46
|
+
test_files: []
|