DEV Community

Robin Beraud-Sudreau
Robin Beraud-Sudreau

Posted on

Stop retyping invoices: a stdlib script that turns them into a ledger CSV and flags the wrong ones

Typing supplier invoices by hand is where typos happen: a swapped digit in the VAT, a date read in the wrong order, a total that never added up.

I wrote a small Hermes skill, invoice-to-ledger-csv, that does the mechanical part and refuses to be overconfident. It reads invoices as text (or PDFs, if pdftotext is installed) and writes one CSV row per invoice: supplier, invoice number, date, currency, net, VAT, VAT rate, gross, a suggested category, plus a status.

The useful bit is the checking. For each invoice it verifies that net + VAT equals gross, and that the stated VAT rate matches the one computed from the amounts. If not, the row is marked REVIEW with the reason, and the exit code is 1.

It understands English and French labels (Subtotal / Total HT, VAT / TVA, Total due / Total TTC) and number formats like 1 234,56 and 1,234.56.

python3 scripts/invoice_to_ledger.py inv1.txt inv2.txt -o ledger.csv
Enter fullscreen mode Exit fullscreen mode

Limits, honestly: it is heuristic. Multi-rate invoices and unusual layouts will be flagged or wrong, categories are keyword guesses, and I only tested it on text samples, not real PDFs. Treat it as a first pass that tells you where to look, not as an accountant.

It is standard-library Python, no API key, MIT licensed, in the hermes-skills library.


Skill (MIT): https://github.com/RobinBeraud/hermes-skills/tree/main/productivity/invoice-to-ledger-csv
All skills: https://github.com/RobinBeraud/hermes-skills

This post was written with AI assistance and reviewed through automated checks.

Top comments (0)