No description
PHI 179 was refused: "Machine lines total R5265 but the invoice subtotal is R13730". Three separate faults, each of which only this invoice exposed. 1. The parser read ONE line per machine. A machine hired over more than one period is printed as one heading followed by a repeating block per charge, and PHI 179 is a single CT01 crane truck billed on 4, 16 and 18 Sep at R5 265 + R3 200 + R5 265. The parser only ever looked at the first block, so two thirds of the invoice went missing and the arithmetic check — which did its job — rejected it. extractLines() now walks y-banded rows and emits one line per money row, all carrying the machine's code. A machine billed once still yields exactly one line, which is what PHI 168/169 do. The banding matters: pdfjs splits one printed row across two y positions (the TOTAL sits ~2pt above the rest), so the fixed +-12pt window the old code used was never a row, it was a coincidence. 2. siteFromDescription required the description to START with "Hire Plant" or "Plant Hire". PHI 179 reads "Crane Truck Hire Sep 2026 Cosmo" — it leads with the machine type — so the regex returned "" and the invoice linked to no site at all. The month/year pair is the part every description shares, so that is the anchor now. 3. Even read correctly the site is "Cosmo", where every other invoice says "Cosmo City". Sites are DERIVED from the invoice wording, so saving the abbreviation would create a second "Cosmo" and split this customer across two rows on /sites. resolveSiteName() folds a shorter whole-word prefix onto a site already in the register, one direction only, so a genuinely new site is still recorded as new. Also: a problem invoice stored its PDF with no way to open it. The inbox reported the failure but not the document behind it, and /api/invoices/:id/ document only serves imported invoices — the one case you most want to inspect. New GET /api/invoices/intake/:id/document, plus a PDF link on each inbox row. Verified: PHI 179 reconciles in full (R13 730 + R2 059.50 VAT = R15 789.50, three lines, each balancing). PHI 168 and PHI 169 still reproduce their hand extraction field for field, including line count. 40 tests, typecheck clean. |
||
|---|---|---|
| .mavis/canvas-assets | ||
| app | ||
| components | ||
| data/source | ||
| docs | ||
| lib | ||
| public | ||
| scripts | ||
| worker | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| COOLIFY.md | ||
| Dockerfile | ||
| HANDOFF-PROMPT-2.md | ||
| HANDOFF-PROMPT-3.md | ||
| HANDOFF-PROMPT-4.md | ||
| HANDOFF-PROMPT.md | ||
| next.config.ts | ||
| package-lock.json | ||
| package.json | ||
| postcss.config.mjs | ||
| proxy.ts | ||
| tsconfig.json | ||