Automation · LLM Pipeline · Production · Germany

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.

Zero rerunsTwo-level deduplication prevents duplicate records from forwarded attachments
2-layerBaseline parser first, Gemini verification second — works even when API is down
Cron-readyGitHub Actions scheduling, deduplication, status tracking, Telegram summaries
Multi-supplierDifferent PDF formats per supplier handled by the LLM extraction layer

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?
An automated pipeline connects to your accounting inbox via IMAP, detects incoming PDF attachments, extracts invoice metadata (vendor, invoice date, net amount, VAT percentage, gross total) using hybrid regex and Gemini AI, stores the data in a structured database, and synchronizes files with Google Drive.
Is automated invoice processing GoBD-compliant in Germany?
Yes. Under GoBD guidelines, original digital invoice PDFs must be stored immutably without modification. The pipeline archives original files in structured Google Drive folders, maintains an audit trail with exact arrival timestamps, and outputs DATEV-compatible ledger files.
How much time does invoice automation save for an SMB in Munich?
For small businesses handling 20–50 invoices weekly, manual data entry takes 2–4 hours every week. Automated processing cuts this to near zero: invoices process automatically within 90 seconds of arrival, delivering 80–100% time savings.
How does the pipeline handle multi-page invoices and varying supplier formats?
The pipeline combines deterministic layout heuristics with multimodal LLM vision. Multi-page document flows are consolidated, line items are extracted from multi-column tables, and disparate invoice templates from domestic and EU suppliers are normalized automatically.
Which accounting software and ERPs can import the processed records?
The pipeline generates structured export files directly compatible with DATEV Unternehmen online, Lexware, sevDesk, and QuickBooks. Additionally, automated webhooks can transmit validated invoice records via secure REST APIs directly into custom internal ERP systems or cloud databases.

Tools used

TypeScript Node.js Gemini 2.5 Flash PostgreSQL Google Drive API Gmail IMAP GitHub Actions Telegram Bot API
Rechnungen automatisch verarbeiten?

I build invoice and document automation pipelines for German businesses. Multi-supplier, multi-format, GoBD-compatible. Let's talk about your workflow.

Contact me Read the article All projects
← Back to projects