Commit graph

10 commits

Author SHA1 Message Date
Ysterbaard
3290803e0b feat: add JEI_payment_batches schema migration script 2026-09-18 18:22:22 +02:00
Mavis
922cd01dd4 chore: rename JEI invoice PDFs to invoice numbers + dedupe
- 22 files renamed to <invoice_no>.pdf (154923.pdf, 151778.pdf, etc.)
- 5 duplicate files moved to invoices/_non_jei/
- 7 files left as-is (multi-invoice PDFs or unscannable:
  1.Invoice_29.05.pdf, Invoice.pdf, JEI Drilling Invoices.pdf,
  JEI SA Invoice 147842.pdf, JEI SA Proforma 148931.pdf,
  newdoc10018920260413143327_001.pdf, Supplier Invoice.pdf,
  Supplier Invoices.pdf)
2026-09-18 17:55:12 +02:00
Mavis
006a324081 feat: OCR scanned PDFs and capture all 11 missing stock codes
- Installed Tesseract OCR via winget
- Added scripts/ocr_invoices.py to OCR all PDFs via PyMuPDF
- Updated extract_invoices.py to fall back to OCR text for scanned pages
- Fixed stock-code regex to match "qty + code" pairs only (avoids spurious
  matches like bare TCT in invoice headers)
- Added merge step to combine multi-page proformas into single invoice records
- All 11 previously-missing codes now in PB:
  JEITCS12, JEITCS18, JEITCS22, JEITCL22, JEITCL92,
  JEICS17, JEICS19, JEICS27, JEICS30, JEICS34, JEICS14-P1
- Only JEITCS50 remains unlisted (genuinely never ordered)

PB now: 19 invoices, 158 stock codes, 281 line items
2026-09-18 06:12:30 +02:00
Mavis
236f5b7bf0 fix: cleanup 6x duplicate lines + bogus JEISA000 stock code
- Removed 424 duplicate invoice lines from re-running the import
- Deleted JEISA000 stock code (it was actually your Account Ref)
- Made create_line idempotent in import_to_pb.py so re-runs skip existing
- Removed debug prints from extract_invoices.py
2026-09-18 00:41:26 +02:00
Mavis
44f9b6957e fix: bypass Next.js fetch-cache for PB SDK calls
Next.js patches the global fetch with a cache layer that was returning
stale PB responses (showing description_goods as the code itself because
the snapshot was from before the import fixed the descriptions).

Wrap the SDK with a custom fetch using cache: no-store so every page
request gets fresh data from PocketBase.
2026-09-17 23:59:13 +02:00
Mavis
b18cb13a6c feat: capture stock-code descriptions from PDF line text
- Two PDF layouts supported: description-before-stock-code and description-after
- Clean up trailing inch-quote artifacts and multiple-comma noise
- Importer PATCHes existing records when new description is better
- Stock codes tab now shows real goods descriptions, not just codes
2026-09-17 23:49:54 +02:00
Mavis
22ddfe82bf fix: avoid PB SDK filter=undefined serialization (caused 400 errors)
The PB JS SDK serializes `filter: undefined` as the literal string
undefined in the URL, which PB rejects with 400 Bad Request.
Switched to conditionally including filter only when non-empty.
2026-09-17 23:17:58 +02:00
Mavis
b95599fe83 fix: dashboard autocancellation - single invoice fetch + clearer error 2026-09-17 23:11:55 +02:00
Mavis
cc4906fba5 chore: tidy .gitignore and update NOTES.md with build discoveries 2026-09-17 23:08:38 +02:00
Mavis
22854074ca feat: working JEI invoice tracker with PB import + UI on port 6002
- Next.js 14 + Tailwind + TypeScript scaffolded
- PocketBase v0.39.8 collections: JEI_invoices, JEI_invoice_lines, JEI_stock_codes
  (30 fields total, locked to superuser)
- PDF extraction: scripts/extract_invoices.py parses 33 PDFs -> 38 records
- Import script: scripts/import_to_pb.py idempotent push to PB
- Imported: 24 invoices, 70+ stock codes, 118 invoice lines
- Pages: /, /invoices, /invoices/[id], /stock-codes, /stock-codes/[code]
- All 5 pages verified returning 200 with real data on port 6002
2026-09-17 23:07:56 +02:00