From f8f781708342c3f9bf4ce2c189e020f3d067f090 Mon Sep 17 00:00:00 2001 From: adambalcerzak Date: Mon, 6 Jul 2026 17:08:36 +0200 Subject: [PATCH] OBLS-505 Inconsistency in move to staging behavior when split 1 task and cancel 2nd --- .../Picking/PickingPickQuantityScreen.tsx | 9 ++++++-- src/screens/Picking/lib.ts | 21 ++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/screens/Picking/PickingPickQuantityScreen.tsx b/src/screens/Picking/PickingPickQuantityScreen.tsx index 416eb92f..c092ce5b 100644 --- a/src/screens/Picking/PickingPickQuantityScreen.tsx +++ b/src/screens/Picking/PickingPickQuantityScreen.tsx @@ -18,7 +18,7 @@ import { usePickingContext } from './PickingContext'; import styles from './styles'; export default function PickingPickQuantityScreen() { - const { currentTask, currentTaskIndex, allTasksCount, shortPickTask, goToNextTask } = usePickingContext(); + const { tasks, currentTask, currentTaskIndex, allTasksCount, shortPickTask, goToNextTask } = usePickingContext(); const dispatch = useDispatch(); const isFocused = useIsFocused(); @@ -98,8 +98,13 @@ export default function PickingPickQuantityScreen() { return; } + // Skip staging if any other task was short picked without a reason code. + const omitStagingLocationStep = tasks.some( + (task, index) => + index !== currentTaskIndex && task.quantityPicked < task.quantityRequired && !task.reasonCode + ); // Skip revalidation: task is closed server-side, and GET /pick-tasks/:id 404s if the requisition is canceled. - proceedToNextOrComplete(currentTaskIndex, allTasksCount, goToNextTask); + proceedToNextOrComplete(currentTaskIndex, allTasksCount, goToNextTask, omitStagingLocationStep); }, reasonCode?.name ); diff --git a/src/screens/Picking/lib.ts b/src/screens/Picking/lib.ts index 2bcb9e8a..02751cc6 100644 --- a/src/screens/Picking/lib.ts +++ b/src/screens/Picking/lib.ts @@ -2,13 +2,32 @@ import { Alert } from 'react-native'; import { navigate, resetToRoutes } from '../../NavigationService'; import { PickTask } from '../../types/picking'; -export function proceedToNextOrComplete(currentTaskIndex: number, allTasksCount: number, goToNextTask: () => void) { +export function proceedToNextOrComplete( + currentTaskIndex: number, + allTasksCount: number, + goToNextTask: () => void, + omitStagingLocationStep?: boolean +) { if (currentTaskIndex + 1 < allTasksCount) { goToNextTask(); navigate('PickingPickLocation'); return; } + if (omitStagingLocationStep) { + Alert.alert( + 'Short Pick Without Reason Code', + 'You have completed all picks with a short pick without a reason code. This task will remain available to pick. You will be redirected to the Pick Type screen.', + [ + { + text: 'OK', + onPress: () => navigate('PickingPickType') + } + ] + ); + return; + } + Alert.alert('All Picks Complete', 'You have completed all picks. Proceeding to staging location drop.', [ { text: 'OK',