|
|
@@ -86,9 +86,9 @@ const PickExecutionForm: React.FC<PickExecutionFormProps> = ({ |
|
|
const [handlers, setHandlers] = useState<Array<{ id: number; name: string }>>( |
|
|
const [handlers, setHandlers] = useState<Array<{ id: number; name: string }>>( |
|
|
[] |
|
|
[] |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const calculateRemainingAvailableQty = useCallback((lot: LotPickData) => { |
|
|
const calculateRemainingAvailableQty = useCallback((lot: LotPickData) => { |
|
|
return lot.availableQty || 0; |
|
|
|
|
|
|
|
|
return (lot.availableQty + lot.requiredQty ) || 0; |
|
|
}, []); |
|
|
}, []); |
|
|
|
|
|
|
|
|
const calculateRequiredQty = useCallback((lot: LotPickData) => { |
|
|
const calculateRequiredQty = useCallback((lot: LotPickData) => { |
|
|
@@ -189,7 +189,7 @@ const PickExecutionForm: React.FC<PickExecutionFormProps> = ({ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 2. Check actualPickQty cannot exceed available quantity |
|
|
// 2. Check actualPickQty cannot exceed available quantity |
|
|
if (ap > availableQty) { |
|
|
|
|
|
|
|
|
if (ap > maxActual) { |
|
|
newErrors.actualPickQty = t("Actual pick qty cannot exceed available qty"); |
|
|
newErrors.actualPickQty = t("Actual pick qty cannot exceed available qty"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -202,20 +202,22 @@ const PickExecutionForm: React.FC<PickExecutionFormProps> = ({ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 4. Total (actualPickQty + missQty + badItemQty + badPackageQty) cannot exceed lot available qty |
|
|
// 4. Total (actualPickQty + missQty + badItemQty + badPackageQty) cannot exceed lot available qty |
|
|
if (total > availableQty) { |
|
|
|
|
|
|
|
|
if (total > maxActual) { |
|
|
const errorMsg = t( |
|
|
const errorMsg = t( |
|
|
"Total qty (actual pick + miss + bad) cannot exceed available qty: {available}", |
|
|
"Total qty (actual pick + miss + bad) cannot exceed available qty: {available}", |
|
|
{ available: availableQty } |
|
|
|
|
|
|
|
|
{ available: maxActual } |
|
|
); |
|
|
); |
|
|
newErrors.actualPickQty = errorMsg; |
|
|
newErrors.actualPickQty = errorMsg; |
|
|
newErrors.missQty = errorMsg; |
|
|
newErrors.missQty = errorMsg; |
|
|
newErrors.badItemQty = 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); |
|
|
setErrors(newErrors); |
|
|
return Object.keys(newErrors).length === 0; |
|
|
return Object.keys(newErrors).length === 0; |
|
|
@@ -274,7 +276,9 @@ const PickExecutionForm: React.FC<PickExecutionFormProps> = ({ |
|
|
|
|
|
|
|
|
const remainingAvailableQty = calculateRemainingAvailableQty(selectedLot); |
|
|
const remainingAvailableQty = calculateRemainingAvailableQty(selectedLot); |
|
|
const requiredQty = calculateRequiredQty(selectedLot); |
|
|
const requiredQty = calculateRequiredQty(selectedLot); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const availableQty = selectedLot?.availableQty || 0; |
|
|
|
|
|
const maxActual = requiredQty + availableQty; |
|
|
return ( |
|
|
return ( |
|
|
<Dialog open={open} onClose={handleClose} maxWidth="sm" fullWidth> |
|
|
<Dialog open={open} onClose={handleClose} maxWidth="sm" fullWidth> |
|
|
<DialogTitle> |
|
|
<DialogTitle> |
|
|
|