updates on the deliveries page and status updates as well

This commit is contained in:
2026-08-27 10:34:48 +05:30
parent cf4f4ecd9c
commit 4bcf604539
7 changed files with 256 additions and 158 deletions

View File

@@ -151,21 +151,34 @@ plan against their GPS trail, and what the day earned. Per-stop actual distance
the trail by each stop's share of the plan — the feed carries no per-stop odometer, so it is an
estimate and the panel says so.
## Status Lifecycle & Backend Status Pairs
The platform manages two distinct layers of state: the initial **PickupBooking** (before pickup) and the subsequent **Consignment** (after pickup). `Converted_To_Consignment` acts solely as an internal backend handoff marker and is **never shown literally** in the UI.
### Status Derivation Matrix
| Phase | Backend State / Combination | Frontend Display Status | Deliveries Page Tab | Badge Tone |
| :--- | :--- | :--- | :--- | :--- |
| **Booking** | `status = Pending_Pickup` | **Pending** | `Pending` | `neutral` (grey) |
| **Booking** | `status = Miler_Assigned` | **Pending** (Deliveries) / **Assigned** (Orders) | `Pending` | `info` (blue) |
| **Booking** | `status = Pickup_Scheduled` + `reachedat == null` | **Accepted** | `Accepted` | `info` (blue) |
| **Booking** | `status = Pickup_Scheduled` + `reachedat != null` | **Arrived** | `Arrived` | `info` (cyan) |
| **Handoff** | `status = Converted_To_Consignment` | *(Switches to `consignmentstatus`)* | — | — |
| **Consignment** | `consignmentstatus = Collected_By_Miler` | **Picked** | `Picked` | `accent` (purple) |
| **Consignment** | `consignmentstatus = Out_for_Delivery` | **Active / Out for Delivery** | `Active` | `warning` (teal/yellow) |
| **Consignment** | `consignmentstatus = Inwarded_At_Hub` / `At_Hub` | **Inwarded At Hub** | `Active` | `info` (blue) |
| **Consignment** | `consignmentstatus = Outwarded_From_Hub` | **Outwarded From Hub** | `Active` | `warning` (teal) |
| **Consignment** | `consignmentstatus = In_Transit_To_Hub` | **In Transit To Hub** | `Active` | `warning` (teal) |
| **Consignment** | `consignmentstatus = Delivered` | **Delivered** | `Delivered` | `success` (green) |
| **Consignment** | `consignmentstatus = Cancelled` / `Returned` / `Failed` | **Cancelled** | `Cancelled` | `destructive` (red) |
| **Consignment** | `consignmentstatus = Skipped` / `RTO` | **Skipped** | `Skipped` | `destructive` (red) |
## Things that look wrong but are not
- **A delivery can read "Active" while the booking says `Converted_To_Consignment`.** A booking's
status freezes the moment it is picked up; the lifecycle continues on the consignment. The
Deliveries table lets the consignment's status win and labels the row so you can tell where the
value came from.
- **The Picked tab is empty on hyperlocal traffic.** A matching 3-digit pickup/delivery pincode
prefix goes straight to `Out_for_Delivery` at pickup, so those parcels never rest in "picked".
- **Update Status refuses half its own options.** The write is consignment-scoped, and Pending,
Accepted, Arrived, Picked and Skipped describe states a consignment cannot be in. Those are
refused with the reason rather than guessed at.
- **Assigned means different things on Orders and Deliveries.** Orders tracks the *operator's*
workflow, so assigning a rider counts as Assigned. Deliveries tracks the *rider's* engagement, so
it waits for the rider to accept. This is deliberate, and the two taxonomies live in
`orderStatusGroups.js` and `queries.js` respectively.
- **`Converted_To_Consignment` is a handoff marker, not a display state.** A booking's status freezes the moment it is picked up; the lifecycle continues on the consignment. The frontend automatically reads `consignmentstatus` from that point on.
- **The Picked tab is empty on hyperlocal traffic when the collection flag is off.** A matching 3-digit pickup/delivery pincode prefix goes straight to `Out_for_Delivery` at pickup, so those parcels transition directly from Arrived to Active.
- **Update Status refuses half its own options.** The write is consignment-scoped, and Pending, Accepted, Arrived, Picked and Skipped describe states a consignment cannot be in. Those are refused with the reason rather than guessed at.
- **Assigned means different things on Orders and Deliveries.** Orders tracks the *operator's* workflow, so assigning a rider counts as Assigned. Deliveries tracks the *rider's* engagement, so it waits for the rider to accept. This is deliberate, and the two taxonomies live in `orderStatusGroups.js` and `queries.js` respectively.
## Batches, dates and the one rule about time