-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessTax.php
291 lines (231 loc) · 6.52 KB
/
processTax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Process Tax Page</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<?php
//assuming computation is monthly
$bs = $_POST['sal'];
$ben = $_POST['ben'];
$earnings = $bs + $ben;
//choice to deduct nssf
$nssf = $_POST['nssf'];
//choose the rate
$rate = $_POST['rate'];
//choice to deduct nhif_amount
$nhif = $_POST['nhif'];
//get nssf amount
function getNSSF($nssf, $rate, $earnings)
{
if ($nssf == 'yes') {
if ($rate == 'old') {
$nssf_amount = 200;
} else {
switch ($earnings) {
case 18000: {
$nssf_amount = 200;
break;
}
case 6000: {
$nssf_amount = $earnings * .12;
break;
}
default: {
$nssf_amount = 0;
break;
}
}
}
} else {
$nssf_amount = 0;
}
return $nssf_amount;
}
//get taxable income
$ti = $earnings - getNSSF($nssf, $rate, $earnings);
//get gross tax
function getGross($ti)
{
switch ($ti) {
case 47059: {
$gross = $ti * .3;
break;
}
case 35473: {
$gross = $ti * .25;
break;
}
case 23886: {
$gross = $ti * .2;
break;
}
case 12299: {
$gross = $ti * .15;
break;
}
default: {
$gross = $ti * .1;
break;
}
}
return $gross;
}
//get net tax
$paye = getGross($ti) - 2400;
//get nhif amount
function getNHIF($earnings)
{
if ($nhif = 'yes') {
switch ($earnings) {
case 100000: {
$nhif_amount = 1700;
break;
}
case 90000: {
$nhif_amount = 1600;
break;
}
case 80000: {
$nhif_amount = 1500;
break;
}
case 70000: {
$nhif_amount = 1400;
break;
}
case 60000: {
$nhif_amount = 1300;
break;
}
case 50000: {
$nhif_amount = 1200;
break;
}
case 45000: {
$nhif_amount = 1100;
break;
}
case 40000: {
$nhif_amount = 1000;
break;
}
case 35000: {
$nhif_amount = 950;
break;
}
case 30000: {
$nhif_amount = 900;
break;
}
case 25000: {
$nhif_amount = 850;
break;
}
case 20000: {
$nhif_amount = 750;
break;
}
case 15000: {
$nhif_amount = 600;
break;
}
case 12000: {
$nhif_amount = 500;
break;
}
case 8000: {
$nhif_amount = 400;
break;
}
case 6000: {
$nhif_amount = 300;
break;
}
case 1000: {
$nhif_amount = 150;
break;
}
default: {
$nhif_amount = 0;
break;
}
}
} else {
$nhif_amount = 0;
}
return $nhif_amount;
}
//get net pay
$netpay = $ti - (getNHIF($earnings) + $paye);
?>
<table class='table'>
<tbody>
<tr>
<th>INCOME BEFORE PENSION DEDUCTION</th>
<td><?php echo $earnings; ?></td>
</tr>
<br>
<tr>
<th>DEDUCTIBLE NSSF PENSION CONTRIBUTION</th>
<td><?php echo getNSSF($nssf, $rate, $earnings); ?></td>
</tr>
<br>
<tr>
<th>INCOME AFTER PENSION DEDUCTIONS</th>
<td><?php echo $ti; ?></td>
</tr>
<br>
<tr>
<th>BENEFITS IN KIND</th>
<td><?php echo $ben; ?></td>
</tr>
<br>
<tr>
<th>TAXABLE INCOME</th>
<td><?php echo $ti; ?></td>
</tr>
<br>
<tr>
<th>TAX ON TAXABLE INCOME</th>
<td><?php echo getGross($ti); ?></td>
</tr>
<br>
<tr>
<th>PERSONAL RELIEF</th>
<td><?php echo 2400; ?></td>
</tr>
<br>
<tr>
<th>TAX NET OFF RELIEF</th>
<td><?php echo $paye; ?></td>
</tr>
<br>
<tr>
<th>PAYE</th>
<td><?php echo $paye; ?></td>
</tr>
<br>
<tr>
<th>CHARGEABLE INCOME</th>
<td><?php echo $ti; ?></td>
</tr>
<br>
<tr>
<th>NHIF CONTRIBUTION</th>
<td><?php echo getNHIF($earnings); ?></td>
</tr>
<br>
<tr>
<th>NET PAY</th>
<td><?php echo $netpay; ?></td>
</tr>
<br>
</tbody>
</table>
</body>
</html>