JEI_Import_Documents-App/recon/POST_FIX_REPORT.md
Mavis 5f73d2ea71 feat: Fedex import flow, orders + invoice APIs, payment bundles
- /fedex: batch create, document upload/replace/delete, save shipment, imported list
- /api/orders, /api/invoices, /api/pb-file, /api/pb/refresh-token, /api/stock-codes
- /api/payments/bundle: generate + download-all remittance bundles
- shared app/components/DocCell.tsx and app/lib/{invoice-docs,pb-fetch,pb-token}.ts
- recon: invoice reconciliation reports and PowerShell fix-plan scripts
- .gitignore: exclude one-off scripts/_* debugging artefacts, recon/pdfs+txts, data backups
2026-10-18 17:27:40 +02:00

4 KiB

JEI Invoice Fix — Post-Fix Report

Date: 2026-10-12 Status: All applied successfully

Summary of actions

Action Count Detail
Invoice line records deleted (duplicate rows) 86 17 invoices affected
Invoice line records added (missing lines) 2 151346 (HM107), 161453 (SERIAL)
Stock codes added to master JEI_stock_codes 2 HM107, SERIAL
Invoice PDF replaced 1 165709 stub (600 B) -> real PDF (283 KB)
Touched invoices 17 one per duplicate-flagged invoice

All 86 deletes preserved exactly one JEI_invoice_lines record per physical line on the source PDF (matched by stock code + quantity, with a fuzzy qty-only fallback for code-variant items like HM40 ↔ HM40.EX16).

Per-invoice outcome

Invoice Before (records / distinct line_no) After (records / distinct line_no) Action
151778 57 / 50 50 / 49 7 deleted
151779 87 / 66 66 / 58 21 deleted
155655 5 / 3 3 / 3 2 deleted
155743 9 / 5 5 / 3 4 deleted
156092 7 / 4 4 / 2 3 deleted
156703 11 / 6 6 / 5 5 deleted
160107 3 / 2 2 / 2 1 deleted
160453 17 / 9 9 / 6 8 deleted
161454 11 / 6 6 / 6 5 deleted
161611 15 / 8 8 / 7 7 deleted
162609 3 / 2 2 / 2 1 deleted
162923 21 / 11 11 / 8 10 deleted
163374 5 / 3 3 / 3 2 deleted
163841 5 / 3 3 / 2 2 deleted
163842 7 / 4 4 / 3 3 deleted
151346 11 / 6 7 / 6 5 deleted, 1 added (HM107)
161453 1 / 1 2 / 2 1 added (SERIAL)

For every invoice above, DB records count now equals the PDF line entry count (the underlying physical-line data is now accurate).

A few invoices still have a few line_no values shared across two different items (e.g. 151778 line 1 holds both JEIETCL28 and JEITCS12, 151346 line 4 holds both T35-2299008 and HM57). That's a pre-existing parser quirk — no data was lost, the lines just share a line_no. The DB record count matches the PDF line count exactly.

Specifically untouched (per user)

Record Status
154923-A (invoice record + 2 lines) Untouched — kept as separate child invoice
154923-B (invoice record + 1 line) Untouched — kept as separate child invoice

User confirmed these were intentionally split from parent 154923 because the payment was made in two parts.

New stock codes in master

Code description_goods
HM107 CARBON BRUSH (1), HM100
SERIAL SERIAL NUMBER REGISTRATION

165709 PDF replacement

Field Before After
pdf_file invoice_bz2wi3hg_h9q3kl2rgo.pdf 13_32_47_717_asset_20261012_133247_717_2646651ee030_f6d94428_in_v_ci877409722884_q7c83qvzrz.pdf
File size 600 B (stub) 283 KB (real iText-generated PDF)
Content (blank) full invoice 165709 — JEIETCSK-50 qty 5, £750 net, £89.95 carriage, £839.95 total

Recon after fix

Re-running the recon across all 39 invoices:

  • All 39 invoice-level header totals (Total Net, Carriage, Total VAT, Order/Invoice Total) match the source PDF to the cent.
  • All 17 affected invoices have DB record count == PDF line entry count.
  • 9 remaining discrepancies are entirely unfixable without OCR:
    • 7 image-only PDFs (no text layer): 149943, 157610, 157611, 157925, 157926, 158876, 162154
    • 2 intentional splits with no PDF: 154923-A, 154923-B

Files

Path Purpose
recon/recon_invoices.ps1 Re-runnable recon driver (now compares db_records not distinct_line_nos)
recon/fix_plan_dryrun.ps1 Re-generates the fix plan as fix_plan.json + fix_plan.txt
recon/fix_plan_apply.ps1 Applies the fix plan (deletes + adds + 165709 upload)
recon/fix_plan.json Plan as JSON, last run: 17 invoices, 86 deletes, 2 adds
recon/fix_plan.txt Plan as human-readable text
recon/RECON_REPORT.md The original recon report (pre-fix)
recon/recon_report.csv Post-fix recon CSV — only 9 rows with notes now