From 961d09a7984ce4df5faec511fc29b727ac44b39a Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Fri, 10 Jul 2026 00:51:17 +0200 Subject: [PATCH] fix(collection-map): use ISO 8601 UTC bounds for assigned_at day filter --- src/app/(app)/collection-map/page.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/(app)/collection-map/page.tsx b/src/app/(app)/collection-map/page.tsx index 76f245d..ed58557 100644 --- a/src/app/(app)/collection-map/page.tsx +++ b/src/app/(app)/collection-map/page.tsx @@ -339,8 +339,13 @@ export default function CollectionMapPage() { setLoading(true); try { const pb = getPocketBase(); - const dayStart = `${date} 00:00:00`; - const dayEnd = `${date} 23:59:59`; + // Build a UTC ISO 8601 day window. `assigned_at` is stored at + // "YYYY-MM-DDT00:00:00.000Z" (see /api/v1/collection-map/items/[id]/assign), + // so the bounds need the same "T" and trailing "Z" or string + // comparison puts `T` (0x54) before the space (0x20) and the bound + // excludes every real row. + const dayStart = `${date}T00:00:00.000Z`; + const dayEnd = `${date}T23:59:59.999Z`; // Union of: // (a) assigned items whose assigned_at lands on the picked date, // (b) un-dated pool items (collection_pool + empty assigned_at) so @@ -394,7 +399,7 @@ export default function CollectionMapPage() { // Also collect items whose suppliers have NO coordinates — show in // the sidebar so the operator knows they exist but can't be mapped. const unmappedRows = (await pb.collection("order_items").getFullList({ - filter: `(item_status = "assigned" || item_status = "collection_pool") && ((assigned_at >= "${dayStart}" && assigned_at <= "${dayEnd}") || assigned_at = "" || assigned_at = null)`, + filter: `(item_status = "assigned" || item_status = "collection_pool") && ((assigned_at >= "${date}T00:00:00.000Z" && assigned_at <= "${date}T23:59:59.999Z") || assigned_at = "" || assigned_at = null)`, expand: "purchase_order.supplier", fields: "id,purchase_order", $autoCancel: false,