- 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
28 lines
872 B
Python
28 lines
872 B
Python
"""Quick test of pair_re against sample lines."""
|
|
import re
|
|
|
|
pair_re = re.compile(
|
|
r"(\d+(?:[,.]\d+)?)\s+("
|
|
r"JEI[A-Z0-9][A-Z0-9\-/\.]*"
|
|
r"|DRILL\-[A-Z0-9\-/\.]+"
|
|
r"|T\d{2}\-\d{6,}"
|
|
r"|HM\d{2}[A-Z\-]*"
|
|
r"|JM\d{3}[A-Z\.\-\d]*"
|
|
r"|PILOT\d*/?[A-Z0-9]*"
|
|
r")\b"
|
|
)
|
|
|
|
tests = [
|
|
"2.00 JEITCS12 TURBO TOUGH, 12MM X 40MM TCT (6MM PILOT) 12.75 25.50",
|
|
"10.00 JEICS17 TURBO STEEL, M2-AL CUTTER, 17MM X 1 inch 5.57 55.70",
|
|
"5.00 JEITCS16 TURBO TOUGH, 16MM X 40MM TCT (6MM PILOT) 12.90 64.50",
|
|
"30.00 JEITCS14-P1 TURBO STEEL, 14MM X 1 inch 5.13 153.90",
|
|
"100.00 JEIPILOT1 PILOT PIN 1.40 140.00",
|
|
"TCT INVOICE 2.00 JEITCS12 25.50", # Header + line item
|
|
]
|
|
for t in tests:
|
|
m = pair_re.search(t)
|
|
if m:
|
|
print("OK qty=%s code=%s | %s" % (m.group(1), m.group(2), t[:70]))
|
|
else:
|
|
print("NO | %s" % t[:70])
|