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 Card from '@/components/Card';
import Table from '@/components/Table'; import Table from '@/components/Table';
import { formatCurrency, formatNumber } from '@/lib/helper'; import { formatCurrency, formatDate, formatNumber } from '@/lib/helper';
import { import {
RowSapronakCalculation, RowSapronakCalculation,
TotalSapronakCalculation, TotalSapronakCalculation,
@@ -38,23 +38,29 @@ const ClosingSapronakCalculationTable = ({
{ {
header: 'Tanggal', header: 'Tanggal',
accessorKey: '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', footer: 'Total',
}, },
{ {
header: 'No. Referensi', header: 'No. Referensi',
accessorKey: 'no_referensi', accessorKey: 'no_referensi',
cell: (props) => (props.getValue() as string) || '-', cell: (props) => (props.row.original.no_referensi as string) || '-',
footer: '', footer: '',
}, },
{ {
header: 'QTY Masuk', header: 'QTY Masuk',
accessorKey: '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 footer: total
? () => ( ? () => (
<div className='font-semibold text-gray-900'> <div className='font-semibold text-gray-900'>
{formatNumber(total?.qty_masuk)} {total?.qty_masuk ? formatNumber(total?.qty_masuk) : '-'}
</div> </div>
) )
: '', : '',
@@ -62,11 +68,14 @@ const ClosingSapronakCalculationTable = ({
{ {
header: 'QTY Keluar', header: 'QTY Keluar',
accessorKey: '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 footer: total
? () => ( ? () => (
<div className='font-semibold text-gray-900'> <div className='font-semibold text-gray-900'>
{formatNumber(total?.qty_keluar)} {total?.qty_keluar ? formatNumber(total?.qty_keluar) : '-'}
</div> </div>
) )
: '', : '',
@@ -74,11 +83,14 @@ const ClosingSapronakCalculationTable = ({
{ {
header: 'QTY Pakai', header: 'QTY Pakai',
accessorKey: '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 footer: total
? () => ( ? () => (
<div className='font-semibold text-gray-900'> <div className='font-semibold text-gray-900'>
{formatNumber(total?.qty_pakai)} {total?.qty_pakai ? formatNumber(total?.qty_pakai) : '-'}
</div> </div>
) )
: '', : '',
@@ -86,23 +98,28 @@ const ClosingSapronakCalculationTable = ({
{ {
header: 'Uraian', header: 'Uraian',
accessorKey: 'uraian', accessorKey: 'uraian',
cell: (props) => (props.getValue() as string) || '-', cell: (props) => (props.row.original.uraian as string) || '-',
footer: '', footer: '',
}, },
{ {
header: 'Kategori Produk', header: 'Kategori Produk',
accessorKey: 'kategori_produk', accessorKey: 'kategori_produk',
cell: (props) => (props.getValue() as string) || '-', cell: (props) => (props.row.original.kategori_produk as string) || '-',
footer: '', footer: '',
}, },
{ {
header: 'Harga Beli/Qty (Rp)', header: 'Harga Beli/Qty (Rp)',
accessorKey: 'harga_beli_per_qty', 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 footer: total
? () => ( ? () => (
<div className='font-semibold text-gray-900'> <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> </div>
) )
: '', : '',
@@ -110,11 +127,14 @@ const ClosingSapronakCalculationTable = ({
{ {
header: 'Total Harga (Rp)', header: 'Total Harga (Rp)',
accessorKey: 'total_harga', 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 footer: total
? () => ( ? () => (
<div className='font-semibold text-gray-900'> <div className='font-semibold text-gray-900'>
{formatCurrency(total?.total_harga)} {total?.total_harga ? formatCurrency(total?.total_harga) : '-'}
</div> </div>
) )
: '', : '',
@@ -122,7 +142,7 @@ const ClosingSapronakCalculationTable = ({
{ {
header: 'Keterangan', header: 'Keterangan',
accessorKey: 'keterangan', accessorKey: 'keterangan',
cell: (props) => (props.getValue() as string) || '-', cell: (props) => (props.row.original.keterangan as string) || '-',
footer: '', footer: '',
}, },
]; ];