PROJECT 05 • DAY 6 OF 90 • DOCUMENT AI

INVOICE
INTELLIGENCE.

An 8-stage financial document intelligence and Accounts Payable workstation combining OpenCV affine deskewing, Tesseract 5.4 bounding-box OCR, reverse-token table extraction, mathematical line-item reconciliation, and audited Excel/JSON exports.

Python 3.12OpenCVTesseract 5.4StreamlitSQLite344/44 Pytest
Invoice Intelligence Preview
AP WORKFLOW
8 Stages • 13 Views
PYTEST SUITE
44 / 44 Passed
8 Stages
Capture to Audit Lifecycle
13 Workspaces
AP Operations Console
3 Conf Tiers
Green / Amber / Red BBoxes
44 / 44
Pytest Tests Passed
01 / Overview

BRIDGING UNSTRUCTURED INVOICES AND AUDITED LEDGERS.

Manual invoice entry suffers from transcription errors and duplicate disbursements. Invoice Intelligence enforces mathematical verification and human-in-the-loop confidence inspection.

01

OpenCV Image Pipeline

Performs MinAreaRect affine deskewing, bilateral edge-preserving denoising, 1.5x bicubic upscaling, and Otsu binarization.

02

Tesseract 5.4 BBox Overlay

Extracts spatially anchored tokens under PSM 4 and highlights fields Green (>=80%), Amber (50–79%), or Red (<50%).

03

Reverse-Token Table Parser

Scans invoice line items right-to-left to robustly separate quantities, unit rates, taxes, and amounts even in wrapped descriptions.

04

Math Reconciliation Gate

Validates sum(line_items) + tax against extracted invoice grand totals, routing discrepancies directly into My Work Queue.

05

Currency-Segregated AP Desk

Separates INR, USD, EUR, and GBP analytics totals accurately without mixing FX denominations.

06

Formula-Safe Excel Export

Neutralizes spreadsheet CSV/Excel formula injection payloads while emitting audit logs and normalized vendor summaries.

02 / Architecture

HOW IT WORKS.

Documents flow from raw upload through CV enhancement, regex/reverse-token parsing, math checks, and AP ledger approval.

STAGE 01

Capture

PDF/Image upload & SHA duplicate check.

→
STAGE 02

CV + OCR

Deskew, Otsu & Tesseract PSM 4.

→
STAGE 03

Extract

Regex anchors & reverse-token lines.

→
STAGE 04

Reconcile

Line-sum vs subtotal/tax math check.

→
STAGE 05

Audit Export

Approve & sanitize .xlsx ledger.

03 / Screenshots

APPLICATION SCREENSHOTS.

Live screens captured from the running application. Click any image to view full size, or follow setup instructions in the GitHub repository.

04 / Technical Details

OCR CONFIDENCE & RECONCILIATION RULES.

Key modules, rules, safety checks, and automated test results documented in the repository.

Stage / Rule Threshold / Logic Action
Confidence Tiering Green >= 80% | Amber 50–79% | Red < 50% Visual reviewer bbox color highlight
Preprocessing MinAreaRect deskew + Otsu + 1.5x bicubic Maximizes scanned receipt legibility
Exception Queue MISSING_INFO / VALIDATION_FAILED / DUPLICATE Prioritized inbox in My Work Queue
Export Security Prefix-escapes =, +, -, @ cell starters Prevents Excel formula execution
05 / Tech Stack

CORE TECHNOLOGIES.

Frameworks, databases, visualization tools, and testing libraries used in Invoice Intelligence.

COMPUTER VISION
OpenCV • Pillow
OCR ENGINE
Tesseract 5.4 (PSM 4)
PARSING LOGIC
Regex • Right-to-Left Table Parser
FRONTEND
Streamlit (13 Workspaces)
STORAGE & EXPORT
SQLite3 • OpenPyXL
TESTING
Pytest (44/44 Passed)
06 / Next Steps

FUTURE ENHANCEMENTS.

Upcoming improvements planned for Invoice Intelligence.

LayoutLMv3 / Donut transformer fallback for handwritten vendor receipts.
Direct webhook connectors for ERP accounting synchronization.
Multilingual Tesseract packs for Hindi, German, French, and Spanish bills.
PO-to-Invoice 3-way purchase order matching module.
Batch ZIP archival with signed PDF compliance manifests.
Automated vendor GSTIN checksum and tax slab validation.
OPEN-SOURCE PROJECT • GITHUB.COM/RAGURAMRRP

EXPLORE SOURCE & DOCS.

View the complete codebase, sample datasets, quick-launch scripts, and automated test suites on GitHub.