Extract structured data from accounting documents (invoices, POs, bank statements) into Excel tracking sheets with JSON backups. Handles digital PDFs, scanned PDFs, and images via automatic OCR.
Install system OCR dependencies before first use. See {baseDir}/references/ocr-setup.md for full guide.
bash
# Ubuntu / Debian
sudo apt install tesseract-ocr tesseract-ocr-vie poppler-utils
# Verify
uv run {baseDir}/scripts/ocr_utils.py check
bash
uv run {baseDir}/scripts/classify_document.py /path/to/document.pdf
Returns JSON with type (invoice / po / statement / other), confidence, and a ready-to-run extraction command.
bash
uv run {baseDir}/scripts/extract_invoice.py /path/to/invoice.pdf -o invoice_tracking.xlsx
Appends to the Excel tracking sheet. Use --dry-run to preview parsed data without writing.
bash
uv run {baseDir}/scripts/extract_statement.py /path/to/statement.pdf
Creates statement_{bank}_{date}.xlsx with transactions. Use -o to specify output path.
bash
uv run {baseDir}/scripts/extract_po.py /path/to/po.pdf -o po_tracking.xlsx
Tracks delivery dates and flags overdue/urgent POs.
bash
uv run {baseDir}/scripts/generate_templates.py all -o ~/accounting/
Creates blank tracking sheets: invoice_tracking.xlsx, po_tracking.xlsx, statement_template.xlsx.
FlagDescription--format excel|json|bothOutput format (default: both)--dry-runParse and validate only, print JSON to stdout--json-dir DIRDirectory for JSON backup files-o FILEOutput Excel file path
text
File → classify_document.py → route → extract_*.py → Excel + JSON
For a folder of mixed documents, classify first, then route:
bash
for f in /path/to/docs/*; do
uv run {baseDir}/scripts/classify_document.py "$f" --output-dir ~/accounting/
done
Then run the suggested extraction commands from each classification result.
All scripts share {baseDir}/scripts/ocr_utils.py which auto-selects the best extraction method:
Each result includes ocr_confidence and extraction_confidence percentages. Documents below 85% are automatically flagged needs_review.
Read these for field schemas, Vietnamese format details, and validation logic:
{baseDir}/references/invoice-fields.md — Vietnamese VAT invoice fields, tax rates, patterns{baseDir}/references/bank-formats.md — Vietnamese bank names, transaction formats, amount patterns{baseDir}/references/po-fields.md — PO fields, delivery status logic, payment terms{baseDir}/references/ocr-setup.md — OCR installation, troubleshooting, confidence scoring