The Scenario: The Deluge of Incoming Invoices and Receipts
The manual review and booking of incoming invoices is among the most time-consuming, monotonous, and error-prone jobs in any finance department. Conventional OCR (Optical Character Recognition) engines promise relief, yet fail in practice as soon as an invoice layout changes even slightly or handwritten notes appear on the paper. Our fourth AI agent resolves these issues via multimodal semantic analysis and implements fully automated 3-way matching.
The Revolution: 3-Way Matching on Steroids
An intelligent controlling agent goes beyond simple data matching. It conducts a comprehensive, three-way verification to ensure absolute data precision:
[Incoming Invoice] ───────┐
├─> [AI Agent: Semantic Alignment] ─> [Approve ERP]
[Delivery Note (ERP)] ────┤
├─> (Does any item mismatch?)
[Purchase Order] ─────────┘ │
▼
[Alert to Controlling]
Anomaly Detection via Deep Semantics
The agent reads totals, tax rates, and individual line items while understanding context. Does a unit price deviate from the framework conditions negotiated and logged in the ERP? Do delivery quantities match the packing slip exactly? If the agent identifies an anomaly or suspects a duplicate invoice (e.g. submitted under slightly altered file names), it halts the automated booking and generates a flagged ticket for a human controller.
Python Implementation: Invoice Extraction with Pydantic
We leverage modern libraries to extract structured data directly from PDF invoices. Here is a practical engineering example showing structured extraction in corporate finance:
from typing import List
from pydantic import BaseModel, Field
class InvoiceItem(BaseModel):
description: str = Field(..., description="The item description.")
quantity: int = Field(..., description="The quantity delivered.")
unit_price: float = Field(..., description="The net unit price.")
vat_rate: float = Field(..., description="The VAT rate in percent.")
class B2BInvoice(BaseModel):
vendor_name: str = Field(..., description="The invoice emitter name.")
vat_id: str = Field(..., description="The Value Added Tax ID.")
invoice_date: str = Field(..., description="The date of the invoice.")
items: List[InvoiceItem] = Field(..., description="List of all invoice line items.")
total_net: float = Field(..., description="The total net amount.")
total_gross: float = Field(..., description="The total gross amount.")
# The agent feeds this schema to the LLM to get a guaranteed, parseable JSON structure.
Security Architecture & Compliance (GoBD)
Compliance is the highest priority in corporate finance. An AI system must not be a "black box." Our controlling agent operates within an isolated containerized sandbox, and every executed booking receives a secure, tamper-proof audit trail. Every decision step of the AI is comprehensively logged:
Compliance with German GoBD Guidelines:
- check_circle Immutability: All logs and audit trails are encrypted and archived in WORM (Write-Once-Read-Many) storage.
- check_circle Traceability: The active LLM prompt version and the exact file path of the source PDF are permanently embedded in each transaction ledger.
- check_circle Data Minimization: No personal bank account information is cached in global model stores.
Financial Conclusion
Savings potentials in corporate controlling are massive. By fully eliminating manual keying errors and spotting discrepancies early, medium-sized businesses avoid penalty fees and capture optimal early payment discount terms.
