Invoice Automation Pipeline
Invoices from multiple suppliers arrive as PDFs by email in different formats. The manual routine was: find email, download PDF, classify supplier, extract fields, file to Drive, enter into accounting. Now it runs on a schedule — automatically, end-to-end. Built for German business operations: multi-supplier, multi-format, idempotent.
How it works
- IMAP inbox scan → PDF attachment detection → supplier classification.
- Baseline regex parser extracts structured fields first (fast, free, reliable).
- Gemini 2.5 Flash verifies and fills gaps, handles format variations across suppliers.
- Validated records upserted to PostgreSQL / Firestore, filed to Google Drive folder structure.
- Telegram summary with run results and any flagged anomalies after each run.
Why it's built this way
- Reliability over extraction accuracy — the pipeline never silently fails.
- Deterministic baseline ensures LLM is a verification layer, not a dependency.
- Idempotent design: re-running the pipeline never creates duplicates.
- Production-grade: logged, scheduled, monitored — not a script that runs once.
What changed
- Weekly manual invoice processing routine completely eliminated.
- Multi-supplier formats handled automatically — no per-supplier configuration needed.
- Records available in database and Drive immediately after email arrives.
- Anomaly detection catches edge cases that previously required manual review.
Your use case
- Any German business receiving 10+ invoices per week from multiple suppliers can automate this entirely.
- Works with DATEV-compatible output format for German accounting software.
- Handles German invoice fields: Steuernummer, USt-IdNr., Rechnungsdatum, Nettobetrag, MwSt.
- Compliant with GoBD archiving requirements via Google Drive structured storage.
GoBD Compliance Architecture & Multi-Stage Invoice Parsing Pipeline
Deterministic regex extraction vs LLM vision: German tax compliance demands absolute mathematical precision on financial numbers, tax rates, and corporate IDs. Relying solely on large language models introduces risks of decimal parsing errors (comma vs dot notation) or currency hallucinations. This pipeline deploys a resilient two-stage parser: pure digital PDF streams are first processed with regex patterns targeting standard German invoice nomenclature (Rechnungsdatum, Rechnungsnummer, Steuernummer, USt-IdNr, Nettobetrag, MwSt-Satz, Bruttogesamtbetrag). Only ambiguous tables or scanned graphic attachments trigger Gemini 2.5 Flash for multimodal vision extraction.
Automated arithmetic validation & anomaly alerts: Before database persistence, an invariant check verifies arithmetic truth: Netto + MwSt == Brutto within a 0.01 EUR rounding tolerance. Any detected mathematical mismatch, duplicate invoice number, or unrecognized tax exemption triggers an immediate Telegram alert with the raw PDF attachment link, routing the document to a human bookkeeper rather than quietly corrupting company accounting ledgers.
GoBD compliance & DATEV integration: In accordance with German GoBD directives (Grundsätze zur ordnungsmäßigen Führung und Aufbewahrung von Büchern, Aufzeichnungen und Unterlagen in elektronischer Form), original PDF documents remain strictly unaltered in encrypted cloud storage with tamper-evident audit trails. Validated extraction payloads export into DATEV-compatible CSV structures mapped with standard German chart of accounts (SKR03 / SKR04) posting keys.
Frequently Asked Questions
How can I automate invoice processing for a German business?
Is automated invoice processing GoBD-compliant in Germany?
How much time does invoice automation save for an SMB in Munich?
How does the pipeline handle multi-page invoices and varying supplier formats?
Which accounting software and ERPs can import the processed records?
Tools used
I build invoice and document automation pipelines for German businesses. Multi-supplier, multi-format, GoBD-compatible. Let's talk about your workflow.