From 15b3151c5fd294dbbb1a8dd35b6f6f1c66c290dd Mon Sep 17 00:00:00 2001 From: randy-ar Date: Wed, 31 Dec 2025 13:18:22 +0700 Subject: [PATCH] fix(FE): fix perhitungan sapronak --- .../ClosingSapronakCalculationTable.tsx | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/components/pages/closing/ClosingSapronakCalculationTable.tsx b/src/components/pages/closing/ClosingSapronakCalculationTable.tsx index b6703549..1ec3c971 100644 --- a/src/components/pages/closing/ClosingSapronakCalculationTable.tsx +++ b/src/components/pages/closing/ClosingSapronakCalculationTable.tsx @@ -3,7 +3,7 @@ import Card from '@/components/Card'; import Table from '@/components/Table'; -import { formatCurrency, formatNumber } from '@/lib/helper'; +import { formatCurrency, formatDate, formatNumber } from '@/lib/helper'; import { RowSapronakCalculation, TotalSapronakCalculation, @@ -38,23 +38,29 @@ const ClosingSapronakCalculationTable = ({ { header: 'Tanggal', accessorKey: 'tanggal', - cell: (props) => (props.getValue() as string) || '-', + cell: (props) => + props.row.original.tanggal + ? formatDate(props.row.original.tanggal, 'DD MMM YYYY') + : '-', footer: 'Total', }, { header: 'No. Referensi', accessorKey: 'no_referensi', - cell: (props) => (props.getValue() as string) || '-', + cell: (props) => (props.row.original.no_referensi as string) || '-', footer: '', }, { header: 'QTY Masuk', accessorKey: 'qty_masuk', - cell: (props) => formatNumber(props.getValue() as number), + cell: (props) => + props.row.original.qty_masuk + ? formatNumber(props.row.original.qty_masuk as number) + : '-', footer: total ? () => (
- {formatNumber(total?.qty_masuk)} + {total?.qty_masuk ? formatNumber(total?.qty_masuk) : '-'}
) : '', @@ -62,11 +68,14 @@ const ClosingSapronakCalculationTable = ({ { header: 'QTY Keluar', accessorKey: 'qty_keluar', - cell: (props) => formatNumber(props.getValue() as number), + cell: (props) => + props.row.original.qty_keluar + ? formatNumber(props.row.original.qty_keluar as number) + : '-', footer: total ? () => (
- {formatNumber(total?.qty_keluar)} + {total?.qty_keluar ? formatNumber(total?.qty_keluar) : '-'}
) : '', @@ -74,11 +83,14 @@ const ClosingSapronakCalculationTable = ({ { header: 'QTY Pakai', accessorKey: 'qty_pakai', - cell: (props) => formatNumber(props.getValue() as number), + cell: (props) => + props.row.original.qty_pakai + ? formatNumber(props.row.original.qty_pakai as number) + : '-', footer: total ? () => (
- {formatNumber(total?.qty_pakai)} + {total?.qty_pakai ? formatNumber(total?.qty_pakai) : '-'}
) : '', @@ -86,23 +98,28 @@ const ClosingSapronakCalculationTable = ({ { header: 'Uraian', accessorKey: 'uraian', - cell: (props) => (props.getValue() as string) || '-', + cell: (props) => (props.row.original.uraian as string) || '-', footer: '', }, { header: 'Kategori Produk', accessorKey: 'kategori_produk', - cell: (props) => (props.getValue() as string) || '-', + cell: (props) => (props.row.original.kategori_produk as string) || '-', footer: '', }, { header: 'Harga Beli/Qty (Rp)', accessorKey: 'harga_beli_per_qty', - cell: (props) => formatCurrency(props.getValue() as number), + cell: (props) => + props.row.original.harga_beli_per_qty + ? formatCurrency(props.row.original.harga_beli_per_qty as number) + : '-', footer: total ? () => (
- {formatCurrency(total?.harga_beli_per_qty)} + {total?.harga_beli_per_qty + ? formatCurrency(total?.harga_beli_per_qty) + : '-'}
) : '', @@ -110,11 +127,14 @@ const ClosingSapronakCalculationTable = ({ { header: 'Total Harga (Rp)', accessorKey: 'total_harga', - cell: (props) => formatCurrency(props.getValue() as number), + cell: (props) => + props.row.original.total_harga + ? formatCurrency(props.row.original.total_harga as number) + : '-', footer: total ? () => (
- {formatCurrency(total?.total_harga)} + {total?.total_harga ? formatCurrency(total?.total_harga) : '-'}
) : '', @@ -122,7 +142,7 @@ const ClosingSapronakCalculationTable = ({ { header: 'Keterangan', accessorKey: 'keterangan', - cell: (props) => (props.getValue() as string) || '-', + cell: (props) => (props.row.original.keterangan as string) || '-', footer: '', }, ];