Browse Source

update po

master
cyril.tsui 1 week ago
parent
commit
4debf50835
5 changed files with 63 additions and 9 deletions
  1. +12
    -0
      src/app/api/po/index.ts
  2. +18
    -7
      src/components/PoDetail/PoDetail.tsx
  3. +30
    -1
      src/components/PoDetail/PoInputGrid.tsx
  4. +1
    -1
      src/i18n/zh/inventory.json
  5. +2
    -0
      src/i18n/zh/purchaseOrder.json

+ 12
- 0
src/app/api/po/index.ts View File

@@ -30,11 +30,23 @@ export interface PurchaseOrderLine {
processed: number; processed: number;
receivedQty: number; receivedQty: number;
uom: Uom; uom: Uom;
stockUom: StockUomForPoLine;
price: number; price: number;
status: string; status: string;
stockInLine: StockInLine[]; stockInLine: StockInLine[];
} }


export interface StockUomForPoLine {
id: number;
stockUomCode: string;
stockUomDesc: string;
stockQty: number;
stockRatioN: number;
stockRatioD: number;
purchaseRatioN: number;
purchaseRatioD: number;
}

export interface StockInLine { export interface StockInLine {
id: number; id: number;
stockInId: number; stockInId: number;


+ 18
- 7
src/components/PoDetail/PoDetail.tsx View File

@@ -249,16 +249,23 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
if (result) { if (result) {
setPurchaseOrder(result); setPurchaseOrder(result);
setRows(result.pol || []); setRows(result.pol || []);
if (result.pol && result.pol.length > 0 && result.id !== selectedPoId) {
setSelectedRow(result.pol[0]);
setStockInLine(result.pol[0].stockInLine);
setProcessedQty(result.pol[0].processed);
if (result.pol && result.pol.length > 0) {
if (result.id === selectedPoId) {
const polIndex = result.pol.findIndex((p) => p.id === selectedRow?.id)
// setSelectedRow(result.pol[polIndex]);
setStockInLine(result.pol[polIndex].stockInLine);
setProcessedQty(result.pol[polIndex].processed);
} else {
// setSelectedRow(result.pol[0]);
setStockInLine(result.pol[0].stockInLine);
setProcessedQty(result.pol[0].processed);
}
} }
} }
} catch (error) { } catch (error) {
console.error("Failed to fetch PO detail:", error); console.error("Failed to fetch PO detail:", error);
} }
}, []);
}, [selectedRow]);
const handlePoSelect = useCallback( const handlePoSelect = useCallback(
async (selectedPo: PoResult) => { async (selectedPo: PoResult) => {
@@ -470,6 +477,8 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
<TableCell align="right">{integerFormatter.format(row.qty)}</TableCell> <TableCell align="right">{integerFormatter.format(row.qty)}</TableCell>
<TableCell align="right">{integerFormatter.format(processedQty)}</TableCell> <TableCell align="right">{integerFormatter.format(processedQty)}</TableCell>
<TableCell align="left">{row.uom?.code}</TableCell> <TableCell align="left">{row.uom?.code}</TableCell>
<TableCell align="right">{decimalFormatter.format(row.stockUom.stockQty)}</TableCell>
<TableCell align="left">{row.stockUom.stockUomCode}</TableCell>
{/* <TableCell align="right"> {/* <TableCell align="right">
{decimalFormatter.format(totalWeight)} {weightUnit} {decimalFormatter.format(totalWeight)} {weightUnit}
</TableCell> */} </TableCell> */}
@@ -491,7 +500,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
<TableCell align="center"> <TableCell align="center">
<TextField <TextField
id="dnQty" id="dnQty"
label="輸入來貨數量"
label="輸入採購來貨數量"
type="text" // Use type="text" to allow validation in the change handler type="text" // Use type="text" to allow validation in the change handler
variant="outlined" variant="outlined"
defaultValue={polInputList[rowIndex]?.dnQty ?? ''} defaultValue={polInputList[rowIndex]?.dnQty ?? ''}
@@ -770,6 +779,8 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
<TableCell align="right">{t("qty")}</TableCell> <TableCell align="right">{t("qty")}</TableCell>
<TableCell align="right">{t("processed")}</TableCell> <TableCell align="right">{t("processed")}</TableCell>
<TableCell align="left">{t("uom")}</TableCell> <TableCell align="left">{t("uom")}</TableCell>
<TableCell align="right">{t("Stock In Qty")}</TableCell>
<TableCell align="left">{t("Stock UoM")}</TableCell>
{/* <TableCell align="right">{t("total weight")}</TableCell> */} {/* <TableCell align="right">{t("total weight")}</TableCell> */}
{/* <TableCell align="right">{`${t("price")} (HKD)`}</TableCell> */} {/* <TableCell align="right">{`${t("price")} (HKD)`}</TableCell> */}
<TableCell align="left" sx={{ width: '75px' }}>{t("status")}</TableCell> <TableCell align="left" sx={{ width: '75px' }}>{t("status")}</TableCell>
@@ -793,7 +804,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
<Grid container xs={12} justifyContent="start"> <Grid container xs={12} justifyContent="start">
<Grid item xs={12}> <Grid item xs={12}>
<Typography variant="h6"> <Typography variant="h6">
{selectedRow ? `已選擇: ${selectedRow?.itemNo ? selectedRow.itemNo : 'N/A'} - ${selectedRow?.itemName ? selectedRow?.itemName : 'N/A'}` : "未選擇貨品"}
{selectedRow ? `已選擇貨品: ${selectedRow?.itemNo ? selectedRow.itemNo : 'N/A'} - ${selectedRow?.itemName ? selectedRow?.itemName : 'N/A'}` : "未選擇貨品"}
</Typography> </Typography>
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>


+ 30
- 1
src/components/PoDetail/PoInputGrid.tsx View File

@@ -460,6 +460,11 @@ const closeNewModal = useCallback(() => {
} }
// flex: 0.4, // flex: 0.4,
}, },
{
field: "productLotNo",
headerName: t("productLotNo"),
width: 125,
},
// { // {
// field: "itemName", // field: "itemName",
// headerName: t("itemName"), // headerName: t("itemName"),
@@ -487,6 +492,30 @@ const closeNewModal = useCallback(() => {
return params.row.uom.code; return params.row.uom.code;
}, },
}, },
{
field: "stockQty",
headerName: t("Stock In Qty"),
// flex: 0.5,
width: 125,
type: "number",
// editable: true,
// replace with tooltip + content
renderCell: (params) => {
const baseQty = (params.row.acceptedQty ?? 0) * (itemDetail.stockUom.purchaseRatioN ?? 1) / (itemDetail.stockUom.purchaseRatioD ?? 1)
console.log(baseQty)
const stockQty = baseQty * (itemDetail.stockUom.stockRatioD ?? 1) / (itemDetail.stockUom.stockRatioN ?? 1)
return decimalFormatter.format(stockQty)
}
},
{
field: "stockUom",
headerName: t("Stock UoM"),
width: 120,
// flex: 0.5,
renderCell: (params) => {
return itemDetail.stockUom.stockUomCode;
},
},
// { // {
// field: "weight", // field: "weight",
// headerName: t("weight"), // headerName: t("weight"),
@@ -684,7 +713,7 @@ const closeNewModal = useCallback(() => {
}, },
}, },
], ],
[t, handleStart, handleQC, handleEscalation, session?.user?.abilities, handleStockIn, handlePutAway, handleDelete, handleReject],
[t, handleStart, handleQC, handleEscalation, session?.user?.abilities, handleStockIn, handlePutAway, handleDelete, handleReject, itemDetail],
); );


const addRow = useCallback(() => { const addRow = useCallback(() => {


+ 1
- 1
src/i18n/zh/inventory.json View File

@@ -10,7 +10,7 @@
"fg": "成品", "fg": "成品",
"Available Qty": "可用數量 (倉存單位)", "Available Qty": "可用數量 (倉存單位)",
"Sales UoM": "銷售單位", "Sales UoM": "銷售單位",
"Stock UoM": "存單位",
"Stock UoM": "存單位",
"Available Qty Per Smallest Unit": "可用數量 (基本單位)", "Available Qty Per Smallest Unit": "可用數量 (基本單位)",
"Base UoM": "基本單位", "Base UoM": "基本單位",
"Lot No": "批號", "Lot No": "批號",


+ 2
- 0
src/i18n/zh/purchaseOrder.json View File

@@ -32,6 +32,8 @@
"Item Detail": "貨品詳情", "Item Detail": "貨品詳情",
"qty": "訂單數量", "qty": "訂單數量",
"uom": "計量單位", "uom": "計量單位",
"Stock UoM": "庫存單位",
"Stock In Qty": "入庫數量",
"total weight": "總重量", "total weight": "總重量",
"weight unit": "重量單位", "weight unit": "重量單位",
"price": "訂單貨值", "price": "訂單貨值",


Loading…
Cancel
Save