Selaa lähdekoodia

update po

master
cyril.tsui 1 viikko sitten
vanhempi
commit
4debf50835
5 muutettua tiedostoa jossa 63 lisäystä ja 9 poistoa
  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 Näytä tiedosto

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

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

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


+ 18
- 7
src/components/PoDetail/PoDetail.tsx Näytä tiedosto

@@ -249,16 +249,23 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
if (result) {
setPurchaseOrder(result);
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) {
console.error("Failed to fetch PO detail:", error);
}
}, []);
}, [selectedRow]);
const handlePoSelect = useCallback(
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(processedQty)}</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">
{decimalFormatter.format(totalWeight)} {weightUnit}
</TableCell> */}
@@ -491,7 +500,7 @@ const PoDetail: React.FC<Props> = ({ po, qc, warehouse }) => {
<TableCell align="center">
<TextField
id="dnQty"
label="輸入來貨數量"
label="輸入採購來貨數量"
type="text" // Use type="text" to allow validation in the change handler
variant="outlined"
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("processed")}</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("price")} (HKD)`}</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 item xs={12}>
<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>
</Grid>
<Grid item xs={12}>


+ 30
- 1
src/components/PoDetail/PoInputGrid.tsx Näytä tiedosto

@@ -460,6 +460,11 @@ const closeNewModal = useCallback(() => {
}
// flex: 0.4,
},
{
field: "productLotNo",
headerName: t("productLotNo"),
width: 125,
},
// {
// field: "itemName",
// headerName: t("itemName"),
@@ -487,6 +492,30 @@ const closeNewModal = useCallback(() => {
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",
// 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(() => {


+ 1
- 1
src/i18n/zh/inventory.json Näytä tiedosto

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


+ 2
- 0
src/i18n/zh/purchaseOrder.json Näytä tiedosto

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


Ladataan…
Peruuta
Tallenna