Route Picking / Delivery Sheet
Route picking is the handoff between invoiced sales orders and the transport workflow. The document groups invoices by delivery route, lets sales/warehouse staff order the stops, checks products and lots, confirms loading, and sends the delivery invoices to B1 for stock deduction.
The key idea is that invoice rows stay attached to the delivery sheet, while product checking and batch/lot selection are stored on the delivery document. After the sheet is confirmed, invoice add/remove/sort is locked and the work moves to transport/warehouse actions.
App Entry Points
| App | Target |
|---|---|
| Mobile | ShippingList -> ShippingDetail |
| POS Terminal | shippingRoute -> ShippingRouteDetailForm |
End-To-End State Flow
Create And Invoice Management
Important details:
- Route is required before the document can be created.
branchIdandwhGrpCodemust exist; otherwise the app blocks creation.- Available invoice options exclude canceled invoices and invoices already assigned to a delivery.
- Adding an invoice calls
addInvoiceToDelivery(...); removing callsdeleteInvoiceFromDelivery(...). - Sorting is saved through
sortDeliveryInvoices(...). - Once confirmed, the sheet can no longer add, remove, or sort invoices unless another operational flow unlocks/reworks it.
- If a confirmed sheet becomes empty while still active, Mobile has an auto-delete guard for empty active delivery detail.
Product Checking, Lots, And B1
Product checking starts after the sheet is confirmed and assigned into transport (toTransportation = 1). If it is not assigned to transport, product actions show “ยังไม่ถูกจัดขึ้นขนส่ง”.
B1 send behavior:
Loading And Assignment Flow
Loading status means:
| Value | Meaning |
|---|---|
| empty | goods loading is not confirmed |
LOADING_DOCK | goods are arranged at the dock |
LOADED | goods are loaded onto the vehicle |
Status Reference
| Field | Value | Meaning |
|---|---|---|
deliveryStatus | empty | preparing delivery sheet |
deliveryStatus | FINISHED | sales finished preparing the sheet |
deliveryStatus | CHECKLOCATION | warehouse checked products/lots |
deliveryStatus | PENDING_FOR_B1 | waiting for B1 stock deduction |
deliveryStatus | SOME_DELIVERY_FAIL | at least one invoice failed stock deduction |
deliveryStatus | DONE | stock deduction completed |
status | DELETED | delivery sheet is deleted/locked |
Permissions And Guards
| Action | Guard |
|---|---|
| See Terminal menu | shippingRoute, deptCode -2, 1, 2, 3, 4, 7, 29, 21, 8, 9, 12, 22, 27, 28, 13, 16, 14, 30, main branch only |
| Create route sheet | canCreateShippingRoute(...), main branch, route selected, branchId and whGrpCode present |
| Add/remove/sort invoice | document not deleted, not confirmed, current user is owner |
| Delete invoice row | same as edit, plus toB1 !== 1 |
| Confirm route sheet | document not deleted, not confirmed, current user is owner |
| Accept work | confirmed, toTransportation = 1, no acceptedBy, dept allowed by ACCEPT_DEPTS |
| Check products/lots | dept 2, 8, 22, user 999997, or accepted worker |
| Confirm dock / loaded | dept allowed by LOAD_DOCK_DEPTS |
| Assign worker | loadingStatus = LOADING_DOCK and dept allowed by ASSIGN_DEPTS |
| Send to B1 | dept 2, 8, 12, 22, 28 and status is CHECKLOCATION, PENDING_FOR_B1, or SOME_DELIVERY_FAIL |
| Request invoice cancel | dept 12, 22, 28, delivery not DONE, no discount/credit-note usage, invoice not sent to B1 |
Mobile vs POS Terminal
| Topic | Mobile | POS Terminal |
|---|---|---|
| Screen shape | ShippingList -> ShippingDetail | shippingRoute -> ShippingRouteDetailForm |
| List behavior | dedicated stack/list screen with status filter | split-pane list card in HomeScreen |
| Detail behavior | full-screen detail, bottom/header actions | right-side detail panel, header actions from onHeaderActionsChange |
| Available invoices | getShippingInvoicesWithoutDelivery(...) | getShippingRouteAvailableInvoices(...) through split menu data |
| B1 progress | modal with batch status | modal with batch status |
| Product lots | BatchLotSheet / BatchLotEditorModal | batch picker/editor inside shipping detail form |
Developer Handoff Map
| Area | Code |
|---|---|
| Mobile list | apps/mobile/src/screens/shippingStack/shippingListScreen/index.tsx |
| Mobile detail | apps/mobile/src/screens/shippingStack/shippingDetailScreen/index.tsx |
| Mobile rules/helpers | apps/mobile/src/screens/shippingStack/shippingDetailScreen/helpers.ts |
| Terminal detail | apps/pos-terminal/src/screens/HomeScreen/ShippingRouteDetailForm.tsx |
| Terminal split services | apps/pos-terminal/src/services/splitMenuData.ts |
| Delivery APIs | apps/mobile/src/services/deliveries.ts, apps/pos-terminal/src/services/deliveries.ts |
| Shipping queries | apps/mobile/src/services/shipping.ts, apps/pos-terminal/src/services/shipping.ts |
| Transport follow-up | apps/*/src/services/transport.ts, TransportDetailForm |