docs(agents): record the PO duplicate check and filed-label rules

This commit is contained in:
DEls 2026-10-28 23:18:24 +02:00
parent 844918da0d
commit 824271cdd0

View file

@ -7,3 +7,22 @@ This version has breaking changes — APIs, conventions, and file structure may
This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
<!-- END:nextjs-agent-rules -->
## PO email intake
Purchase orders that arrive by email in `ai@megainfra.co.za` are filed into the dashboard by the
n8n workflow **MEGA - PO Email Intake (Microsoft Outlook)** (`gpKjNsXoqNUzsMb4`).
Two rules that must not be dropped:
1. **Check for a duplicate before filing anything.** Two checks: the same document at the same
site (file hash + site → archive the mail, file nothing), and the PO number already in the
system (read from the attachment filename or subject, e.g. `MEGCPO9524.pdf` → tag
`PO Duplicate` and leave it for a human). The app re-checks both after OCR in
`/api/purchase-orders/process-batch` (`po_number_conflict`).
2. **Move processed mail out of the inbox.** A successful filing is tagged `PO Ingested` and
moved to Archive; `PO Duplicate` and `PO Needs Review` stay in the inbox for review and are
skipped on later runs.
Full runbook and workflow source: `docs/n8n/po-email-intake.md` and
`docs/n8n/po-email-intake.workflow.js`.