feat(api): expose last_wash timestamp on /numberplatescans (TRU-78) (#401)
Resolves TRU-78 (DRIFT 17: License plate scan - show 'last washed' timestamp on landing page / DHL use case). The POS landing page already surfaces license plate scans via `GET /numberplatescans`, but it has no way to tell the operator **when a plate was last washed**. With DHL trailers going in and out several times a day, the front-desk needs that hint to decide whether a trailer needs another wash before pick-up. ## Changes - **`orders_o::getLastWashTimestampForPlate(string $reg_1): ?string`** — new helper that returns the `created_at` (MySQL DATETIME) of the most recent non-deleted order for the plate that has at least one non-deleted order item. Mirrors the contract used by `customer_vehicles_o::getLastOrderByPlate()` so the timestamp is always backed by a real wash. - **`GET /numberplatescans`** now enriches each scan row with a `last_wash` key (string or `null`). No breaking change to the existing payload; new field is additive. - **New Pest test** `services/nginx/app/tests/Unit/Orders/OrderLastWashTimestampForPlateTest.php` — static-analysis assertions for the helper definition and the route wiring (matches the style of `OrderBookingsCountsRouteWiringTest`). ## Frontend companion https://github.com/copenhagentruckwash/pleno-vue/pull/335 renders this `last_wash` in the inline details of each scan row on the POS landing page (`PosLastScannedLicensePlatesV2.vue`), with an "Aldrig vasket" / "Never washed" fallback when the API returns `null`. ## Risk - `getLastWashTimestampForPlate` does one extra indexed read per scan row (`SELECT id FROM orders WHERE reg_1 = ? AND deleted_at IS NULL`). The existing `isPlateSeenBefore` call already does the same, so the route's per-row query count is unchanged in shape. - The new field is additive and ignored by older clients, so this can roll forward without a coordinated client release. Co-authored-by: openclaw bugfix <openclaw@copenhagentruckwash.local>
This commit is contained in:
co-authored by
openclaw bugfix
parent
52d43fc16c
commit
64c5cd45db
@@ -120,11 +120,21 @@ class plateScansRoute
|
||||
'type' => (int)$tmp_scan_vehicle['type'],
|
||||
];
|
||||
}
|
||||
// TRU-78 / DRIFT 17: enrich each scan with the
|
||||
// timestamp of the most recent completed wash for
|
||||
// that plate so the POS landing page can show
|
||||
// "last washed" at a glance when DHL trailers are
|
||||
// being picked up.
|
||||
$plate_value = (string)$scan['plate'];
|
||||
$tmp_scan_last_wash = [
|
||||
'last_wash' => (new orders_o())->getLastWashTimestampForPlate($plate_value),
|
||||
];
|
||||
// Return the object as an array
|
||||
return [
|
||||
...$scan,
|
||||
...$tmp_scan_customer,
|
||||
...$tmp_scan_seen_before,
|
||||
...$tmp_scan_last_wash,
|
||||
];
|
||||
},
|
||||
$number_plate_scans->forceRestrictFilters(
|
||||
|
||||
Reference in New Issue
Block a user