-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
206 lines (199 loc) · 8.42 KB
/
index.html
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
<!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, shrink-to-fit=no">
<meta name="description" content="Zambian Salary and PAYE Calculator">
<meta name="author" content="eddycodes">
<title>Zambian Salaray and PAYE Calculator</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
<section>
<div class="container pt-3">
<div class="row">
<div class="col-sm-12">
<h1>Salary and PAYE Calculator</h1>
</div>
</div>
</div>
</section>
<div id="app">
<div class="container pt-3">
<div class="row">
<div class="col-sm-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Enter your salary details</h5>
<div class="mb-3 row">
<label for="basic-pay" class="col-sm-4">Basic Pay</label>
<div class="col-sm-8">
<input type="number" class="form-control" ref="basicPay" v-model="basicPay">
</div>
</div>
<div class="mb-3 row">
<label for="allowances" class="col-sm-4">Allowances</label>
<div class="col-sm-8">
<input type="number" class="form-control" ref="allowances" v-model="allowances">
</div>
</div>
<div class="mb-3 row">
<label for="bonuses" class="col-sm-4">Bonuses</label>
<div class="col-sm-8">
<input type="number" class="form-control" ref="bonuses" v-model="bonuses">
</div>
</div>
<div class="mb-3 row">
<label for="gratuity" class="col-sm-4">Gratuity/Leave Pay</label>
<div class="col-sm-8">
<input type="number" class="form-control" ref="gratuity" v-model="gratuity">
</div>
</div>
<div class="mb-3 row">
<label for="gratuity" class="col-sm-4">Loans and Advances</label>
<div class="col-sm-8">
<input type="number" class="form-control" ref="loans" v-model="loans">
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Net pay breakdown</h5>
<div class="row">
<div class="col-sm-6">
<p>Gross Pay</p>
</div>
<div class="col-sm-6">
<p>{{ grossPay | thousandSeparator }}</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<p>Napsa</p>
</div>
<div class="col-sm-6">
<p>{{ napsa | thousandSeparator }}</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<p>NHIS</p>
</div>
<div class="col-sm-6">
<p>{{ nhis | thousandSeparator }}</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<p>Tax</p>
</div>
<div class="col-sm-6">
<p>{{ tax | thousandSeparator }}</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<p>Total Deductions</p>
</div>
<div class="col-sm-6">
<p>{{ totalDeductions | thousandSeparator }}</p>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<p>Net Pay</p>
</div>
<div class="col-sm-6">
<p>{{ netPay | thousandSeparator }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
<script>
new Vue({
el: '#app',
data: {
basicPay: '',
allowances: '',
bonuses: '',
gratuity: '',
loans: ''
},
computed: {
grossPay() {
return [this.basicPay, this.allowances, this.bonuses, this.gratuity].map((value) => {
return value = value == '' ? 0 : parseFloat(value);
})
.reduce((totalSum, currentValue) => {
return totalSum + currentValue;
});
},
napsa() {
const napsaCeiling = 1221.80;
let napsa = 0.05 * (this.grossPay);
if (napsa >= napsaCeiling) {
napsa = napsaCeiling;
}
return napsa;
},
nhis() {
let basicPay = this.basicPay === '' ? 0 : parseFloat(this.basicPay);
return basicPay * 0.01;
},
tax() {
let tax = 0;
let band1 = 4500;
let band2 = 300;
let band3 = 2100;
if (this.grossPay <= band1) return tax;
let remaining = this.grossPay - band1;
if (remaining > band2) {
remaining -= band2;
tax += band2 * 0.25;
if (remaining > band3) {
remaining -= band3;
tax += band3 * 0.30;
if (remaining > 0) {
tax += remaining * 0.375;
}
} else {
tax += remaining * 0.30;
}
} else {
tax = remaining * 0.25;
}
return tax;
},
totalDeductions() {
return [this.napsa, this.tax, this.nhis, this.loans].map((value) => {
return value = value == '' ? 0 : parseFloat(value);
})
.reduce((totalSum, currentValue) => {
return totalSum + currentValue;
});
},
netPay() {
return this.grossPay - this.totalDeductions;
}
},
filters: {
thousandSeparator(value) {
if (value !== null) {
return value.toFixed(2).toString().replace(/,/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
}
});
</script>
</html>