MEGAINFRA-WEBAPP/src
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
..
app fix(purchasing): restore PO-number normalization in process-batch 2026-09-11 14:29:06 +02:00
components feat(purchasing): create the PO row at upload with a placeholder number 2026-09-11 14:14:19 +02:00
hooks Initial commit: MEGA INFRASTRUCTURE dashboard + Coolify Dockerfile 2026-08-09 01:37:40 +02:00
lib fix(purchasing): restore the 30-day PO dedup window with a real timestamp 2026-09-11 14:17:42 +02:00
mcp feat(mcp): read-only stdio MCP server exposing six tools 2026-08-29 20:25:39 +02:00