✨ feat(noc): implementasi perhitungan total nominal diterima pada pembayaran
- Hitung total nominal diterima dari semua data yang difilter (bukan hanya halaman aktif) - Tampilkan total dalam format currency Indonesia (IDR) di footer tabel - Integrasi backend (NocController) dan frontend (Blade + JS) secara real-time - Update otomatis via event listener DataTable saat data berubah atau difilter - Validasi dan parsing currency string dengan aman, casting ke float untuk akurasi - Tambahkan field totalNominalDiterima pada response JSON DataTable - Footer tabel dengan styling TailwindCSS (text-green-600, font-bold) untuk highlight - UX lebih transparan: user langsung melihat total pembayaran yang diterima - Performa terjaga: minimal DOM manipulation, native Intl.NumberFormat, efisien pada filter
This commit is contained in:
@@ -296,6 +296,13 @@
|
||||
];
|
||||
})->sortBy('updated_at', 1)->values();
|
||||
|
||||
// Calculate total nominal diterima from all filtered data (not just current page)
|
||||
$totalNominalDiterima = $data->sum(function ($item) {
|
||||
// Extract numeric value from formatted currency string
|
||||
$nominal = str_replace(['Rp', '.', ',00'], '', $item['nominal_diterima']);
|
||||
return (float) $nominal;
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
@@ -310,6 +317,7 @@
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'totalNominalDiterima' => $totalNominalDiterima,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user