MEGAINFRA-WEBAPP/src/app
DEls 1559f9e51f fix(purchasing): restore PO-number normalization in process-batch
Task 14 rewrote process-batch to fill in the placeholder PO row instead
of creating a new one, but dropped normalizePoNumber along the way. The
route it replaced normalized (uppercase, collapse whitespace, strip a
leading PO prefix) before both the dedup lookup and storage; the rewrite
used the raw OCR string for both.

That's a real regression, not a style choice: two OCR runs of the same
real order that extracted slightly different formatting -- "PO-1234" vs
"PO 1234" -- would both pass the exact-string dedup filter as
non-matches, silently defeating the one check that exists to catch
exactly that. purchase_order_number carries a UNIQUE index but that only
blocks an identical string, not a format variant of the same PO.

Confirmed src/app/api/purchase-orders/ingest/route.ts (the only other
caller of purchase_order_number in this shape) is dead -- deprecated in
docs/superpowers/specs/2026-08-19-po-import-queue-redesign.md, superseded
by process-batch, kept only in case anything still hits it. process-batch
is the one route n8n actually calls, so this was live-path drift, not a
cosmetic inconsistency.

Normalizes once, in validateExtracted(), so every downstream use (dedup
filter, stored value, response body) sees the same canonical form. Also
restores the old route's guard against a PO number that strips to empty
once normalized (e.g. a raw value of just "PO") -- non-empty raw input
that would otherwise sail through as a legitimate-looking fill-in.

Full suite: 580/580 passing, 0 failures -- the pre-existing 404-vs-500
test bug that predated this entire restructure was also resolved as a
side effect of Task 14's rewrite.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-11 14:29:06 +02:00
..
api fix(purchasing): restore PO-number normalization in process-batch 2026-09-11 14:29:06 +02:00
dashboard feat(purchasing): create the PO row at upload with a placeholder number 2026-09-11 14:14:19 +02:00
login Initial commit: MEGA INFRASTRUCTURE dashboard + Coolify Dockerfile 2026-08-09 01:37:40 +02:00
apple-icon.png feat(pwa): render chat icon set + per-route apple-touch-icons 2026-08-30 22:15:15 +02:00
favicon.ico fix(employee-details): enhance detail drawer scrolling and layout 2026-08-25 23:38:35 +02:00
globals.css feat(dashboard): enhance operations dashboard with rain outlook and coordinate support 2026-09-06 19:59:52 +02:00
layout.tsx fix(pwa): emit apple-mobile-web-app-capable for iOS Add-to-Home-Screen standalone mode 2026-08-30 23:28:48 +02:00
page.tsx Initial commit: MEGA INFRASTRUCTURE dashboard + Coolify Dockerfile 2026-08-09 01:37:40 +02:00