diff --git a/src/screens/Picking/PickingContext.tsx b/src/screens/Picking/PickingContext.tsx index 83dafdce..029a9339 100644 --- a/src/screens/Picking/PickingContext.tsx +++ b/src/screens/Picking/PickingContext.tsx @@ -70,6 +70,8 @@ type PickingContextType = { revalidateCurrentTask: (callback?: (task: PickTask | undefined) => void) => void; /** Advances to the next task in the list */ goToNextTask: () => void; + /** Whether the move-to-staging step should be skipped because the pick task's facility does not track internal transactions */ + skipStagingStep: boolean; }; const PickingContext = React.createContext(undefined); @@ -82,6 +84,8 @@ export function PickingProvider({ children }: { children: React.ReactNode }) { const homeRoute = HOME_ROUTE_BY_ENTRY_POINT[entryPoint]; const allTasksCount = tasks.length; const currentTask = allTasksCount > 0 && currentTaskIndex < allTasksCount ? tasks[currentTaskIndex] : undefined; + // Move to staging only applies to facilities that track internal transactions. + const skipStagingStep = currentTask?.internalTransactionsEnabled === false; const startSession = async (deliveryType: DeliveryType, ordersCount: number): Promise => { setEntryPoint('BATCH'); @@ -220,6 +224,23 @@ export function PickingProvider({ children }: { children: React.ReactNode }) { return; } + if (skipStagingStep) { + Alert.alert( + 'No Additional Tasks', + 'No new pick tasks were created. This location does not track internal transactions, so staging is not required.', + [ + { + text: 'OK', + onPress: () => { + resetSession(); + resetToRoutes([{ name: 'Drawer', params: { screen: 'Dashboard' } }, { name: homeRoute }]); + } + } + ] + ); + return; + } + Alert.alert('No Additional Tasks', 'No new pick tasks were created. Proceeding to staging location drop.', [ { text: 'OK', @@ -317,7 +338,8 @@ export function PickingProvider({ children }: { children: React.ReactNode }) { dropCurrentTask, dropCurrentTaskAtStagingLocation, revalidateCurrentTask, - goToNextTask + goToNextTask, + skipStagingStep }} > {children} diff --git a/src/screens/Picking/PickingMoveToStaging.tsx b/src/screens/Picking/PickingMoveToStaging.tsx index 84820361..9dc20b88 100644 --- a/src/screens/Picking/PickingMoveToStaging.tsx +++ b/src/screens/Picking/PickingMoveToStaging.tsx @@ -31,8 +31,16 @@ export default function PickingMoveToStagingScreen() { return; } + // Tasks whose facility does not track internal transactions don't need to be staged. + const stagingEligibleTasks = response.data.filter((task) => task.internalTransactionsEnabled !== false); + + if (stagingEligibleTasks.length === 0) { + Alert.alert('Staging Not Required', 'The picked items for this container do not require a move to staging.'); + return; + } + // Navigate to the staging screen with the fetched tasks - navigate('PickingStagingDrop', { tasks: response.data }); + navigate('PickingStagingDrop', { tasks: stagingEligibleTasks }); }) ); diff --git a/src/screens/Picking/PickingPickOutboundContainerScreen.tsx b/src/screens/Picking/PickingPickOutboundContainerScreen.tsx index 27dbc6ad..2706fef3 100644 --- a/src/screens/Picking/PickingPickOutboundContainerScreen.tsx +++ b/src/screens/Picking/PickingPickOutboundContainerScreen.tsx @@ -31,7 +31,9 @@ export default function PickingPickOutboundContainerScreen() { revalidateCurrentTask, goToNextTask, revalidateTasksForRequisition, - homeRoute + homeRoute, + skipStagingStep, + resetSession } = usePickingContext(); const { params } = useRoute(); const parsedQuantityPicked = params?.quantityPicked ? Number(params.quantityPicked) : undefined; @@ -79,7 +81,9 @@ export default function PickingPickOutboundContainerScreen() { allTasksCount, goToNextTask, homeRoute, - omitStagingLocationStep + omitStagingLocationStep, + skipStagingStep, + resetSession }); } }, @@ -95,7 +99,15 @@ export default function PickingPickOutboundContainerScreen() { return; } - revalidateTaskAndProceed({ revalidateCurrentTask, currentTaskIndex, allTasksCount, goToNextTask, homeRoute }); + revalidateTaskAndProceed({ + revalidateCurrentTask, + currentTaskIndex, + allTasksCount, + goToNextTask, + homeRoute, + skipStagingStep, + resetSession + }); }); setOutboundContainerId(EMPTY_STRING); diff --git a/src/screens/Picking/PickingPickQuantityScreen.tsx b/src/screens/Picking/PickingPickQuantityScreen.tsx index 723ba768..ea161d41 100644 --- a/src/screens/Picking/PickingPickQuantityScreen.tsx +++ b/src/screens/Picking/PickingPickQuantityScreen.tsx @@ -19,8 +19,17 @@ import { usePickingContext } from './PickingContext'; import styles from './styles'; export default function PickingPickQuantityScreen() { - const { tasks, currentTask, currentTaskIndex, allTasksCount, shortPickTask, goToNextTask, homeRoute } = - usePickingContext(); + const { + tasks, + currentTask, + currentTaskIndex, + allTasksCount, + shortPickTask, + goToNextTask, + homeRoute, + skipStagingStep, + resetSession + } = usePickingContext(); const dispatch = useDispatch(); const isFocused = useIsFocused(); @@ -111,7 +120,9 @@ export default function PickingPickQuantityScreen() { allTasksCount, goToNextTask, homeRoute, - omitStagingLocationStep + omitStagingLocationStep, + skipStagingStep, + resetSession }); }, reasonCode?.name diff --git a/src/screens/Picking/lib.ts b/src/screens/Picking/lib.ts index 1892a6d5..01c6d57a 100644 --- a/src/screens/Picking/lib.ts +++ b/src/screens/Picking/lib.ts @@ -9,6 +9,9 @@ type PickingFlowNavigation = { /** Screen the session started from, reset to when it ends so finished screens are unreachable */ homeRoute: string; omitStagingLocationStep?: boolean; + /** Whether the move-to-staging step should be skipped because the facility does not track internal transactions */ + skipStagingStep?: boolean; + resetSession?: () => void; }; function returnHome(homeRoute: string) { @@ -33,7 +36,9 @@ export function proceedToNextOrComplete({ allTasksCount, goToNextTask, homeRoute, - omitStagingLocationStep + omitStagingLocationStep, + skipStagingStep, + resetSession }: PickingFlowNavigation) { if (currentTaskIndex + 1 < allTasksCount) { goToNextTask(); @@ -46,6 +51,23 @@ export function proceedToNextOrComplete({ return; } + if (skipStagingStep) { + Alert.alert( + 'All Picks Complete', + 'You have completed all picks. This location does not track internal transactions, so staging is not required.', + [ + { + text: 'OK', + onPress: () => { + resetSession?.(); + returnHome(homeRoute); + } + } + ] + ); + return; + } + Alert.alert('All Picks Complete', 'You have completed all picks. Proceeding to staging location drop.', [ { text: 'OK', @@ -65,7 +87,9 @@ export function revalidateTaskAndProceed({ allTasksCount, goToNextTask, homeRoute, - omitStagingLocationStep + omitStagingLocationStep, + skipStagingStep, + resetSession }: PickingFlowNavigation & { revalidateCurrentTask: (callback: (revalidatedTask: PickTask | undefined) => void) => void; }) { @@ -82,6 +106,13 @@ export function revalidateTaskAndProceed({ return; } - proceedToNextOrComplete({ currentTaskIndex, allTasksCount, goToNextTask, homeRoute }); + proceedToNextOrComplete({ + currentTaskIndex, + allTasksCount, + goToNextTask, + homeRoute, + skipStagingStep, + resetSession + }); }); } diff --git a/src/types/picking.ts b/src/types/picking.ts index 269cbb70..ec27553c 100644 --- a/src/types/picking.ts +++ b/src/types/picking.ts @@ -58,6 +58,8 @@ export type PickTask = { deliveryTypeCode?: DeliveryTypeCode; facility?: Location; + /** Whether the task's facility tracks internal transactions (mirrors facility.supports(TRACK_INTERNAL_TRANSACTIONS)) */ + internalTransactionsEnabled?: boolean; location?: Location; outboundContainer?: Container | null; stagingLocation?: Location | null;