fix(FE): fix perhitungan sapronak

This commit is contained in:
randy-ar
2025-12-31 13:18:22 +07:00
parent 1a8d794a66
commit 15b3151c5f
@@ -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
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total?.qty_masuk)}
{total?.qty_masuk ? formatNumber(total?.qty_masuk) : '-'}
</div>
)
: '',
@@ -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
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total?.qty_keluar)}
{total?.qty_keluar ? formatNumber(total?.qty_keluar) : '-'}
</div>
)
: '',
@@ -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
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total?.qty_pakai)}
{total?.qty_pakai ? formatNumber(total?.qty_pakai) : '-'}
</div>
)
: '',
@@ -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
? () => (
<div className='font-semibold text-gray-900'>
{formatCurrency(total?.harga_beli_per_qty)}
{total?.harga_beli_per_qty
? formatCurrency(total?.harga_beli_per_qty)
: '-'}
</div>
)
: '',
@@ -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
? () => (
<div className='font-semibold text-gray-900'>
{formatCurrency(total?.total_harga)}
{total?.total_harga ? formatCurrency(total?.total_harga) : '-'}
</div>
)
: '',
@@ -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: '',
},
];