|
|
|
@@ -228,6 +228,16 @@ const isCheckedStatus = (status: string | undefined): boolean => |
|
|
|
const isRejectedStatus = (status: string | undefined): boolean => |
|
|
|
String(status || "").toLowerCase() === "rejected"; |
|
|
|
|
|
|
|
const isPendingSolStatus = (status: string | undefined): boolean => { |
|
|
|
const s = String(status || "").toLowerCase(); |
|
|
|
return ( |
|
|
|
s === "pending" || |
|
|
|
s === "partially_completed" || |
|
|
|
s === "partially_complete" || |
|
|
|
s === "" |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
function safeDisplayTargetDate(targetDate: string | number[]): string { |
|
|
|
try { |
|
|
|
if (Array.isArray(targetDate) && targetDate.length >= 3) { |
|
|
|
@@ -346,7 +356,7 @@ function mapHierarchicalToPickOrders(data: unknown): PickOrderTopRow[] { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** FP-MTMS Version Checklist | Functions Ref. No. 28 | v1.0.2 | 2026-08-03 */ |
|
|
|
/** FP-MTMS Version Checklist | Functions Ref. No. 28 | v1.0.3 | 2026-08-13 */ |
|
|
|
const WorkbenchPickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
|
const { t } = useTranslation("pickOrder"); |
|
|
|
const { data: session } = useSession() as { data: SessionWithTokens | null }; |
|
|
|
@@ -1221,8 +1231,35 @@ const WorkbenchPickExecution: React.FC<Props> = ({ filterArgs }) => { |
|
|
|
releaseProcessedQr(latest); |
|
|
|
return; |
|
|
|
} |
|
|
|
const expectedPool = activeForUom.length > 0 ? activeForUom : allForUom; |
|
|
|
let expectedRow = pickExpectedRowForSubstitution(expectedPool) || allForUom[0]; |
|
|
|
// Align DO/JO: when no active suggested lot, bind to pending noLot / unavailable |
|
|
|
// rows instead of a completed row that still has lotNo. |
|
|
|
let expectedRow: LotRow | undefined; |
|
|
|
if (activeForUom.length > 0) { |
|
|
|
expectedRow = pickExpectedRowForSubstitution(activeForUom) || allForUom[0]; |
|
|
|
} else { |
|
|
|
const switchable = allForUom.find( |
|
|
|
(r) => |
|
|
|
r.stockOutLineId > 0 && |
|
|
|
isPendingSolStatus(r.status) && |
|
|
|
!isCompletedStatus(r.status) && |
|
|
|
!isCheckedStatus(r.status) && |
|
|
|
(isNoLotWorkbenchRow(r) || |
|
|
|
isRejectedStatus(r.status) || |
|
|
|
isInventoryLotLineUnavailable(r) || |
|
|
|
isLotAvailabilityExpired(r)), |
|
|
|
); |
|
|
|
expectedRow = |
|
|
|
switchable || |
|
|
|
allForUom.find( |
|
|
|
(r) => |
|
|
|
r.stockOutLineId > 0 && |
|
|
|
isPendingSolStatus(r.status) && |
|
|
|
!isCompletedStatus(r.status) && |
|
|
|
!isCheckedStatus(r.status), |
|
|
|
) || |
|
|
|
pickExpectedRowForSubstitution(allForUom) || |
|
|
|
allForUom[0]; |
|
|
|
} |
|
|
|
if (!expectedRow) { |
|
|
|
setError(t("Scanned item is not found in current line")); |
|
|
|
startTransition(() => { |
|
|
|
|