mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix(FE-284): adjust data types for sapronak calculation
This commit is contained in:
@@ -37,88 +37,88 @@ const ClosingSapronakCalculationTable = ({
|
||||
): ColumnDef<RowSapronakCalculation>[] => [
|
||||
{
|
||||
header: 'Tanggal',
|
||||
accessorKey: 'tanggal',
|
||||
accessorKey: 'date',
|
||||
cell: (props) =>
|
||||
props.row.original.tanggal
|
||||
? formatDate(props.row.original.tanggal, 'DD MMM YYYY')
|
||||
props.row.original.date
|
||||
? formatDate(props.row.original.date, 'DD MMM YYYY')
|
||||
: '-',
|
||||
footer: 'Total',
|
||||
},
|
||||
{
|
||||
header: 'No. Referensi',
|
||||
accessorKey: 'no_referensi',
|
||||
cell: (props) => (props.row.original.no_referensi as string) || '-',
|
||||
accessorKey: 'reference_number',
|
||||
cell: (props) => (props.row.original.reference_number as string) || '-',
|
||||
footer: '',
|
||||
},
|
||||
{
|
||||
header: 'QTY Masuk',
|
||||
accessorKey: 'qty_masuk',
|
||||
accessorKey: 'qty_in',
|
||||
cell: (props) =>
|
||||
props.row.original.qty_masuk
|
||||
? formatNumber(props.row.original.qty_masuk as number)
|
||||
props.row.original.qty_in
|
||||
? formatNumber(props.row.original.qty_in as number)
|
||||
: '-',
|
||||
footer: total
|
||||
? () => (
|
||||
<div className='font-semibold text-gray-900'>
|
||||
{total?.qty_masuk ? formatNumber(total?.qty_masuk) : '-'}
|
||||
{total?.qty_in ? formatNumber(total?.qty_in) : '-'}
|
||||
</div>
|
||||
)
|
||||
: '',
|
||||
},
|
||||
{
|
||||
header: 'QTY Keluar',
|
||||
accessorKey: 'qty_keluar',
|
||||
accessorKey: 'qty_out',
|
||||
cell: (props) =>
|
||||
props.row.original.qty_keluar
|
||||
? formatNumber(props.row.original.qty_keluar as number)
|
||||
props.row.original.qty_out
|
||||
? formatNumber(props.row.original.qty_out as number)
|
||||
: '-',
|
||||
footer: total
|
||||
? () => (
|
||||
<div className='font-semibold text-gray-900'>
|
||||
{total?.qty_keluar ? formatNumber(total?.qty_keluar) : '-'}
|
||||
{total?.qty_out ? formatNumber(total?.qty_out) : '-'}
|
||||
</div>
|
||||
)
|
||||
: '',
|
||||
},
|
||||
{
|
||||
header: 'QTY Pakai',
|
||||
accessorKey: 'qty_pakai',
|
||||
accessorKey: 'qty_used',
|
||||
cell: (props) =>
|
||||
props.row.original.qty_pakai
|
||||
? formatNumber(props.row.original.qty_pakai as number)
|
||||
props.row.original.qty_used
|
||||
? formatNumber(props.row.original.qty_used as number)
|
||||
: '-',
|
||||
footer: total
|
||||
? () => (
|
||||
<div className='font-semibold text-gray-900'>
|
||||
{total?.qty_pakai ? formatNumber(total?.qty_pakai) : '-'}
|
||||
{total?.qty_used ? formatNumber(total?.qty_used) : '-'}
|
||||
</div>
|
||||
)
|
||||
: '',
|
||||
},
|
||||
{
|
||||
header: 'Uraian',
|
||||
accessorKey: 'uraian',
|
||||
cell: (props) => (props.row.original.uraian as string) || '-',
|
||||
accessorKey: 'description',
|
||||
cell: (props) => (props.row.original.description as string) || '-',
|
||||
footer: '',
|
||||
},
|
||||
{
|
||||
header: 'Kategori Produk',
|
||||
accessorKey: 'kategori_produk',
|
||||
cell: (props) => (props.row.original.kategori_produk as string) || '-',
|
||||
accessorKey: 'product_category',
|
||||
cell: (props) => (props.row.original.product_category as string) || '-',
|
||||
footer: '',
|
||||
},
|
||||
{
|
||||
header: 'Harga Beli/Qty (Rp)',
|
||||
accessorKey: 'harga_beli_per_qty',
|
||||
accessorKey: 'unit_price',
|
||||
cell: (props) =>
|
||||
props.row.original.harga_beli_per_qty
|
||||
? formatCurrency(props.row.original.harga_beli_per_qty as number)
|
||||
props.row.original.unit_price
|
||||
? formatCurrency(props.row.original.unit_price as number)
|
||||
: '-',
|
||||
footer: total
|
||||
? () => (
|
||||
<div className='font-semibold text-gray-900'>
|
||||
{total?.harga_beli_per_qty
|
||||
? formatCurrency(total?.harga_beli_per_qty)
|
||||
{total?.avg_unit_price
|
||||
? formatCurrency(total?.avg_unit_price)
|
||||
: '-'}
|
||||
</div>
|
||||
)
|
||||
@@ -126,32 +126,32 @@ const ClosingSapronakCalculationTable = ({
|
||||
},
|
||||
{
|
||||
header: 'Total Harga (Rp)',
|
||||
accessorKey: 'total_harga',
|
||||
accessorKey: 'total_amount',
|
||||
cell: (props) =>
|
||||
props.row.original.total_harga
|
||||
? formatCurrency(props.row.original.total_harga as number)
|
||||
props.row.original.total_amount
|
||||
? formatCurrency(props.row.original.total_amount as number)
|
||||
: '-',
|
||||
footer: total
|
||||
? () => (
|
||||
<div className='font-semibold text-gray-900'>
|
||||
{total?.total_harga ? formatCurrency(total?.total_harga) : '-'}
|
||||
{total?.total_amount ? formatCurrency(total?.total_amount) : '-'}
|
||||
</div>
|
||||
)
|
||||
: '',
|
||||
},
|
||||
{
|
||||
header: 'Keterangan',
|
||||
accessorKey: 'keterangan',
|
||||
cell: (props) => (props.row.original.keterangan as string) || '-',
|
||||
accessorKey: 'notes',
|
||||
cell: (props) => (props.row.original.notes as string) || '-',
|
||||
footer: '',
|
||||
},
|
||||
];
|
||||
|
||||
// Memoize columns untuk setiap kategori
|
||||
const docBroilerColumns = useMemo(
|
||||
const docColumns = useMemo(
|
||||
() =>
|
||||
isResponseSuccess(sapronakCalculation)
|
||||
? createColumns(sapronakCalculation.data?.doc_broiler?.total)
|
||||
? createColumns(sapronakCalculation.data?.doc?.total)
|
||||
: createColumns(),
|
||||
[sapronakCalculation]
|
||||
);
|
||||
@@ -172,10 +172,18 @@ const ClosingSapronakCalculationTable = ({
|
||||
[sapronakCalculation]
|
||||
);
|
||||
|
||||
const pulletColumns = useMemo(
|
||||
() =>
|
||||
isResponseSuccess(sapronakCalculation)
|
||||
? createColumns(sapronakCalculation.data?.pullet?.total)
|
||||
: createColumns(),
|
||||
[sapronakCalculation]
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-4'>
|
||||
<Card
|
||||
title='DOC Broiler'
|
||||
title='DOC'
|
||||
collapsible
|
||||
defaultCollapsed={false}
|
||||
className={{
|
||||
@@ -186,10 +194,10 @@ const ClosingSapronakCalculationTable = ({
|
||||
<Table<RowSapronakCalculation>
|
||||
data={
|
||||
isResponseSuccess(sapronakCalculation)
|
||||
? (sapronakCalculation.data?.doc_broiler?.rows ?? [])
|
||||
? (sapronakCalculation.data?.doc?.rows ?? [])
|
||||
: []
|
||||
}
|
||||
columns={docBroilerColumns}
|
||||
columns={docColumns}
|
||||
className={{
|
||||
containerClassName: 'my-4',
|
||||
}}
|
||||
@@ -242,6 +250,29 @@ const ClosingSapronakCalculationTable = ({
|
||||
renderFooter={isResponseSuccess(sapronakCalculation)}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title='Pullet'
|
||||
variant='bordered'
|
||||
collapsible
|
||||
defaultCollapsed={true}
|
||||
className={{
|
||||
wrapper: 'w-full',
|
||||
}}
|
||||
>
|
||||
<Table<RowSapronakCalculation>
|
||||
data={
|
||||
isResponseSuccess(sapronakCalculation)
|
||||
? (sapronakCalculation.data?.pullet?.rows ?? [])
|
||||
: []
|
||||
}
|
||||
columns={pulletColumns}
|
||||
className={{
|
||||
containerClassName: 'my-4',
|
||||
}}
|
||||
renderFooter={isResponseSuccess(sapronakCalculation)}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Vendored
+17
-16
@@ -147,25 +147,25 @@ export type ClosingProductionData = {
|
||||
|
||||
export type RowSapronakCalculation = {
|
||||
id: number;
|
||||
tanggal: string;
|
||||
no_referensi: string;
|
||||
qty_masuk: number;
|
||||
qty_keluar: number;
|
||||
qty_pakai: number;
|
||||
uraian: string;
|
||||
kategori_produk: string;
|
||||
harga_beli_per_qty: number;
|
||||
total_harga: number;
|
||||
keterangan: string;
|
||||
date: string;
|
||||
reference_number: string;
|
||||
qty_in: number;
|
||||
qty_out: number;
|
||||
qty_used: number;
|
||||
description: string;
|
||||
product_category: string;
|
||||
unit_price: number;
|
||||
total_amount: number;
|
||||
notes: string;
|
||||
};
|
||||
|
||||
export type TotalSapronakCalculation = {
|
||||
label: string;
|
||||
qty_masuk: number;
|
||||
qty_keluar: number;
|
||||
qty_pakai: number;
|
||||
harga_beli_per_qty: number;
|
||||
total_harga: number;
|
||||
qty_in: number;
|
||||
qty_out: number;
|
||||
qty_used: number;
|
||||
avg_unit_price: number;
|
||||
total_amount: number;
|
||||
};
|
||||
|
||||
export type ClosingSapronakCalculationItem = {
|
||||
@@ -174,9 +174,10 @@ export type ClosingSapronakCalculationItem = {
|
||||
};
|
||||
|
||||
export type ClosingSapronakCalculation = {
|
||||
doc_broiler: ClosingSapronakCalculationItem;
|
||||
doc: ClosingSapronakCalculationItem;
|
||||
ovk: ClosingSapronakCalculationItem;
|
||||
pakan: ClosingSapronakCalculationItem;
|
||||
pullet: ClosingSapronakCalculationItem;
|
||||
};
|
||||
|
||||
// ====== OVERHEAD ======
|
||||
|
||||
Reference in New Issue
Block a user