MEGAINFRA-WEBAPP/AGENTS.md

1.6 KiB

This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in node_modules/next/dist/docs/ (resolved from this file's directory; in monorepos the next package may not be visible from the repo root) before writing any code. Heed deprecation notices.

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.

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.