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