From 79ccf5ae6f70af4b64ae744c8892e118476f85b9 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Tue, 8 Sep 2026 17:43:38 +0800 Subject: [PATCH] =?UTF-8?q?=20PO=20=E6=94=B6=E8=B2=A8=20UI=20and=20?= =?UTF-8?q?=E8=B6=85=E9=87=8F=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(main)/po/edit/page.tsx | 4 +-- src/components/PoDetail/PoDetail.tsx | 37 ++++++++++++++++++---- src/components/PoDetail/PoInputGrid.tsx | 2 +- src/components/PoDetail/QcStockInModal.tsx | 2 +- src/components/PoSearch/PoSearch.tsx | 11 ++++--- src/components/Qc/QcStockInModal.tsx | 2 +- src/i18n/en/purchaseOrder.json | 2 +- src/i18n/zh/purchaseOrder.json | 2 +- 8 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/app/(main)/po/edit/page.tsx b/src/app/(main)/po/edit/page.tsx index e7f0667d..5eeabac3 100644 --- a/src/app/(main)/po/edit/page.tsx +++ b/src/app/(main)/po/edit/page.tsx @@ -16,11 +16,11 @@ type Props = {} & SearchParams; const PoEdit: React.FC = async ({ searchParams }) => { const type = "purchaseOrder"; const { t } = await getServerI18n(type); - console.log(searchParams["id"]); + //console.log(searchParams["id"]); const id = isString(searchParams["id"]) ? parseInt(searchParams["id"]) : undefined; - console.log(id); + //console.log(id); if (!id) { notFound(); } diff --git a/src/components/PoDetail/PoDetail.tsx b/src/components/PoDetail/PoDetail.tsx index 1b1fb889..36bffeb5 100644 --- a/src/components/PoDetail/PoDetail.tsx +++ b/src/components/PoDetail/PoDetail.tsx @@ -253,7 +253,7 @@ interface PolInputResult { dnQty: string, } -/** FP-MTMS Version Checklist | Functions Ref. No. 56 | v1.0.1 | 2026-08-12 */ +/** FP-MTMS Version Checklist | Functions Ref. No. 56 | v1.0.2 | 2026-09-07 */ const PoDetail: React.FC = ({ po, warehouse, printerCombo }) => { const cameras = useContext(CameraContext); const { data: session } = useSession(); @@ -678,11 +678,29 @@ const PoDetail: React.FC = ({ po, warehouse, printerCombo }) => { }, 200); }; - const exceedOrderBy10Percent = orderQty > 0 && acceptedQty > orderQty * 1.1; - if (exceedOrderBy10Percent) { + const sils = row.stockInLine ?? []; + const alreadyM18 = sils.reduce( + (acc, sil) => acc + Number(sil.purchaseAcceptedQty ?? 0), + 0, + ); + const alreadyStock = sils.reduce( + (acc, sil) => acc + Number(sil.acceptedQty ?? 0), + 0, + ); + const stockDemand = Number(row.stockUom?.stockQty ?? 0); + const thisBatchStock = + orderQty > 0 && stockDemand > 0 + ? acceptedQty * (stockDemand / orderQty) + : acceptedQty; + const exceedByOrderUnit = + orderQty > 0 && alreadyM18 + acceptedQty > orderQty * 1.1; + const exceedByStockUnit = + stockDemand > 0 && + alreadyStock + thisBatchStock > stockDemand * 1.1; + if (exceedByOrderUnit || exceedByStockUnit) { submitDialogWithWarning(doSubmit, t, { title: t("Confirm submit"), - html: t("This batch quantity exceeds order quantity. Do you still want to submit?"), + html: t("qtyExceedsOrderConfirm"), confirmButtonText: t("Submit"), }); } else { @@ -834,6 +852,11 @@ const PoDetail: React.FC = ({ po, warehouse, printerCombo }) => {