-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
83 lines (80 loc) · 2.78 KB
/
script.js
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
var apgadajamie = document.getElementById('apgadajamie');
var neapliekamais = document.getElementById('neapliekamais');
var bruto = document.getElementById('bruto');
var button = document.getElementById('aprekinat');
var socIemaksa = document.getElementById('vsao');
var iedzIenNod = document.getElementById('iin');
var apgadIemaksa = document.getElementById('apgPers');
var neapliekMIn = document.getElementById('neapMin');
var showSum = document.getElementById('neto');
var vsao, neapMin, sum, iin, procenti23, procenti20;
button.addEventListener('click', aprekinat);
function aprekinat() {
//aprēķina vsao
vsao = bruto.value * 0.105;
if (neapliekamais.value > 350) {
neapliekamais.value = 350;
}
//aprēķina ienākuma nodokli
if (bruto.value <= 1667) {
iin = (bruto.value - vsao) - ((20 / 100) * (bruto.value - vsao));
}
//ienākuma nodoklis ja bruto>1667
else {
procenti23 = (bruto.value - 1667) * 0.23;
console.log(procenti23);
procenti20 = (bruto.value - (bruto.value - 1667) - vsao) * 0.20;
console.log(procenti20);
iin = bruto.value - vsao - procenti23 - procenti20;
}
//apŗēķina "uz rokas"
if ((bruto.value - vsao) - neapliekamais.value >= apgadajamie.value * 250) {
neapMin = neapliekamais.value - (neapliekamais.value - ((20 / 100) * neapliekamais.value));
sum = iin + (apgadajamie.value * 50) + neapMin;
} else {
sum = bruto.value - vsao;
}
//izvada summu
document.querySelector('.summary').style.display = 'block';
showSum.style.cssText = "color:magenta; font-size:24px; text-decoration: underline";
showSum.innerText = parseFloat(sum).toFixed(2) + " EUR";
//output vsao
socIemaksa.innerText = parseFloat(vsao).toFixed(2);
console.log(socIemaksa.value);
//output iin
if (bruto.value <= 1667) {
x = parseFloat(((bruto.value - vsao) - neapliekamais.value) * 0.2 - (apgadajamie.value * 50)).toFixed(2);
if (x > 0) {
iedzIenNod.innerText = x;
} else {
iedzIenNod.innerText = 0;
}
} else {
x = parseFloat(((1667 - vsao) - neapliekamais.value) * 0.2 - (apgadajamie.value * 50) + procenti23).toFixed(2);
if (x > 0) {
iedzIenNod.innerText = x;
}
else {
iedzIenNod.innerText = 0;
}
}
//output apgādājamos
apgadIemaksa.innerText = apgadajamie.value * 250;
//output neapliekamo minimumu
neapliekMIn.innerText = neapliekamais.value;
}
$(document).ready(function () {
$('#apgadajamie').prop('disabled', true);
$('#plus-btn').click(function () {
$('#apgadajamie').val(parseInt($('#apgadajamie').val()) + 1);
if ($('#apgadajamie').val() > 10) {
$('#apgadajamie').val(10);
}
});
$('#minus-btn').click(function () {
$('#apgadajamie').val(parseInt($('#apgadajamie').val()) - 1);
if ($('#apgadajamie').val() < 0) {
$('#apgadajamie').val(0);
}
});
});