Skip to content

Commit

Permalink
fix: Add total setahun pajak dan penghasilan
Browse files Browse the repository at this point in the history
  • Loading branch information
pipinfitriadi committed Feb 5, 2024
1 parent f0c0b21 commit bce9e70
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,15 @@ <h1 class="text-center">Kalkulator Pajak</h1>
<td class="text-end"></td>
<td class="text-end"></td>
</tr>
<tr class="table-warning">
<td>Desember</td>
<td class="text-end"></td>
<td class="text-end"></td>
</tr>
</tbody>
<tfoot class="table-warning table-group-divider">
<tfoot class="table-success table-group-divider">
<tr>
<th>Desember</th>
<th>Total Setahun</th>
<th class="text-end"></th>
<th class="text-end"></th>
</tr>
Expand Down Expand Up @@ -331,10 +336,12 @@ <h1 class="text-center">Kalkulator Pajak</h1>
'KI-2': 121500000,
'KI-3': 126000000
},
pajakCols = document.querySelectorAll('tbody td:nth-child(2)'),
pajakDesCol = document.querySelector('tfoot th:nth-child(2)'),
penghasilanNettCols = document.querySelectorAll('tbody td:last-child'),
penghasilanNettDesCol = document.querySelector('tfoot th:last-child');
pajakCols = document.querySelectorAll('tbody tr:not(:last-child) td:nth-child(2)'),
pajakDesCol = document.querySelector('tbody tr:last-child td:nth-child(2)'),
pajakTotalCol = document.querySelector('tfoot th:nth-child(2)'),
penghasilanNettCols = document.querySelectorAll('tbody tr:not(:last-child) td:last-child'),
penghasilanNettDesCol = document.querySelector('tbody tr:last-child td:last-child'),
penghasilanTotalCol = document.querySelector('tfoot th:last-child');

form.onsubmit = function(event) {
event.preventDefault();
Expand Down Expand Up @@ -389,20 +396,22 @@ <h1 class="text-center">Kalkulator Pajak</h1>
pajakDes >= 0 ?
`Rp${pajakDes.toLocaleString(LOCALE_STRING)}` :
`
<button type="button" class="text-danger fw-bold btn position-relative">
<button type="button" class="text-danger btn position-relative">
-Rp${Math.abs(pajakDes).toLocaleString(LOCALE_STRING)}
<span class="position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">
Kelebihan Bayar!
</span>
</button>
`
);
pajakTotalCol.textContent = `Rp${(pajakJanNov * 11 + pajakDes).toLocaleString(LOCALE_STRING)}`;

penghasilanNettCols.forEach(
(elem) =>
elem.textContent = `Rp${penghasilanNettJanNov.toLocaleString(LOCALE_STRING)}`
);
penghasilanNettDesCol.textContent = `Rp${(pajakDes >= 0 ? penghasilanNettDes : penghasilanBruto).toLocaleString(LOCALE_STRING)}`;
penghasilanNettDesCol.textContent = `Rp${penghasilanNettDes.toLocaleString(LOCALE_STRING)}`;
penghasilanTotalCol.textContent = `Rp${(penghasilanNettJanNov * 11 + penghasilanNettDes).toLocaleString(LOCALE_STRING)}`;

table.classList.remove('visually-hidden');

Expand Down

0 comments on commit bce9e70

Please sign in to comment.