mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
fix(FE): adjust data types for project flock and product stock inventory
This commit is contained in:
@@ -112,6 +112,15 @@ const InventoryProductTable = () => {
|
|||||||
accessorFn: (row) => row.product_category.name,
|
accessorFn: (row) => row.product_category.name,
|
||||||
header: 'Kategori',
|
header: 'Kategori',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
accessorFn: (row) => row.total_stock,
|
||||||
|
header: 'Stok',
|
||||||
|
cell: (props) => {
|
||||||
|
return props.row.original.total_stock
|
||||||
|
? formatCurrency(props.row.original.total_stock)
|
||||||
|
: '-';
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.uom.name,
|
accessorFn: (row) => row.uom.name,
|
||||||
header: 'Satuan',
|
header: 'Satuan',
|
||||||
|
|||||||
@@ -8,20 +8,9 @@ import { useMemo } from 'react';
|
|||||||
|
|
||||||
const InventoryProductDetail = ({
|
const InventoryProductDetail = ({
|
||||||
inventoryProduct,
|
inventoryProduct,
|
||||||
refresh,
|
|
||||||
}: {
|
}: {
|
||||||
inventoryProduct?: InventoryProduct;
|
inventoryProduct?: InventoryProduct;
|
||||||
refresh?: () => void;
|
|
||||||
}) => {
|
}) => {
|
||||||
const totalStok = useMemo(() => {
|
|
||||||
return (
|
|
||||||
inventoryProduct?.product_warehouses?.reduce(
|
|
||||||
(total, warehouse) => total + (warehouse.current_stock || 0),
|
|
||||||
0
|
|
||||||
) || 0
|
|
||||||
);
|
|
||||||
}, [inventoryProduct]);
|
|
||||||
|
|
||||||
const stockLogs = useMemo(() => {
|
const stockLogs = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
inventoryProduct?.product_warehouses?.flatMap(
|
inventoryProduct?.product_warehouses?.flatMap(
|
||||||
@@ -105,7 +94,11 @@ const InventoryProductDetail = ({
|
|||||||
<tr>
|
<tr>
|
||||||
<td className='font-semibold'>Total Stok</td>
|
<td className='font-semibold'>Total Stok</td>
|
||||||
<td>:</td>
|
<td>:</td>
|
||||||
<td>{formatNumber(totalStok)}</td>
|
<td>
|
||||||
|
{inventoryProduct?.total_stock
|
||||||
|
? formatNumber(inventoryProduct?.total_stock)
|
||||||
|
: '-'}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ const ProjectFlockDetail = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{` ${formatCurrency(
|
{` ${formatCurrency(
|
||||||
projectFlock.project_budgets.reduce(
|
(projectFlock.project_budgets ?? []).reduce(
|
||||||
(acc, curr) => acc + curr.price * curr.qty,
|
(acc, curr) => acc + curr.price * curr.qty,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
@@ -236,7 +236,7 @@ const ProjectFlockDetail = ({
|
|||||||
|
|
||||||
{/* Card List Project Budgets */}
|
{/* Card List Project Budgets */}
|
||||||
{openBudgets &&
|
{openBudgets &&
|
||||||
projectFlock.project_budgets.map((budget) => (
|
(projectFlock.project_budgets ?? []).map((budget) => (
|
||||||
<Card
|
<Card
|
||||||
key={budget.id}
|
key={budget.id}
|
||||||
variant='bordered'
|
variant='bordered'
|
||||||
|
|||||||
Vendored
+1
@@ -18,6 +18,7 @@ export type BaseInventoryProduct = {
|
|||||||
suppliers: Supplier[];
|
suppliers: Supplier[];
|
||||||
flags: string[];
|
flags: string[];
|
||||||
product_warehouses?: ProductWarehouseStock[];
|
product_warehouses?: ProductWarehouseStock[];
|
||||||
|
total_stock?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ProductWarehouseStock = {
|
export type ProductWarehouseStock = {
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ export type BaseProjectFlock = {
|
|||||||
kandangs: (Kandang & {
|
kandangs: (Kandang & {
|
||||||
project_flock_kandang_id: number;
|
project_flock_kandang_id: number;
|
||||||
})[];
|
})[];
|
||||||
project_budgets: ProjectFlockBudget[];
|
project_budgets?: ProjectFlockBudget[];
|
||||||
approval: BaseApproval;
|
approval: BaseApproval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user