diff --git a/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx b/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx index 5ff744d..9d99c65 100644 --- a/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx +++ b/src/components/FinishedGoodSearch/GoodPickExecutionForm.tsx @@ -86,9 +86,9 @@ const PickExecutionForm: React.FC = ({ const [handlers, setHandlers] = useState>( [] ); - + const calculateRemainingAvailableQty = useCallback((lot: LotPickData) => { - return lot.availableQty || 0; + return (lot.availableQty + lot.requiredQty ) || 0; }, []); const calculateRequiredQty = useCallback((lot: LotPickData) => { @@ -189,7 +189,7 @@ const PickExecutionForm: React.FC = ({ } // 2. Check actualPickQty cannot exceed available quantity - if (ap > availableQty) { + if (ap > maxActual) { newErrors.actualPickQty = t("Actual pick qty cannot exceed available qty"); } @@ -202,20 +202,22 @@ const PickExecutionForm: React.FC = ({ } // 4. Total (actualPickQty + missQty + badItemQty + badPackageQty) cannot exceed lot available qty - if (total > availableQty) { + if (total > maxActual) { const errorMsg = t( "Total qty (actual pick + miss + bad) cannot exceed available qty: {available}", - { available: availableQty } + { available: maxActual } ); newErrors.actualPickQty = errorMsg; newErrors.missQty = errorMsg; newErrors.badItemQty = errorMsg; } - - // 5. At least one field must have a value - if (ap === 0 && miss === 0 && totalBad === 0) { - newErrors.actualPickQty = t("Enter pick qty or issue qty"); + if (selectedLot?.stockOutLineStatus === 'pending' && ap >0 && miss === 0 && totalBad === 0) { + newErrors.actualPickQty = t("if need just edit number, please scan the lot again"); } + // 5. At least one field must have a value + //if (ap === 0 && miss === 0 && totalBad === 0) { + // newErrors.actualPickQty = t("Enter pick qty or issue qty"); + // } setErrors(newErrors); return Object.keys(newErrors).length === 0; @@ -274,7 +276,9 @@ const PickExecutionForm: React.FC = ({ const remainingAvailableQty = calculateRemainingAvailableQty(selectedLot); const requiredQty = calculateRequiredQty(selectedLot); - + + const availableQty = selectedLot?.availableQty || 0; + const maxActual = requiredQty + availableQty; return ( diff --git a/src/i18n/zh/pickOrder.json b/src/i18n/zh/pickOrder.json index 6d9d881..ceb43c2 100644 --- a/src/i18n/zh/pickOrder.json +++ b/src/i18n/zh/pickOrder.json @@ -17,6 +17,8 @@ "Select Remark": "選擇備註", "Just Complete": "已完成", "Skip": "跳過", + "if need just edit number, please scan the lot again": "如果需要只修改數量,請重新掃描批次。", + "Total qty (actual pick + miss + bad) cannot exceed available qty: {available}": "總數量(實際提料 + 遺失 + 不良)不能超過可用數量:{{available}}", "Confirm Assignment": "確認分配", "Required Date": "所需日期", "Store": "位置",