Invoice & PO Deterministic Math Validator (MCP) avatar

Invoice & PO Deterministic Math Validator (MCP)

Pricing

$4.00 / 1,000 invoice validateds

Go to Apify Store
Invoice & PO Deterministic Math Validator (MCP)

Invoice & PO Deterministic Math Validator (MCP)

Zero-scraping deterministic B2B invoice & purchase order auditor. Catches LLM subtotal/tax hallucinations with exact BigInt cents math and outputs clean normalized JSON.

Pricing

$4.00 / 1,000 invoice validateds

Rating

0.0

(0)

Developer

對帳 秒

對帳 秒

Maintained by Community

Actor stats

0

Bookmarked

1

Total users

0

Monthly active users

a day ago

Last modified

Categories

Features

Limited permissions

Share

Structured Invoice & PO Deterministic Validator (MCP)

Stop LLM arithmetic hallucinations before they corrupt your ERP, QuickBooks, Xero, or Google Sheets.

AI models (GPT, Claude, Gemini) and OCR pipelines are great at reading messy PDF invoices—but notoriously unreliable at math. They routinely miscalculate quantity × unit_price, silently drop negative credit-note signs, hallucinate tax totals, or break on currency rounding.

Structured Invoice & PO Deterministic Validator is a zero-scraping, pure-compute, 100% deterministic financial auditing Actor & MCP Tool. Feed it raw JSON extracted by any LLM or OCR engine, and get back:

  • Exact integer minor-unit math verification (zero IEEE-754 floating-point drift)
  • Explicit LLM hallucination flagging (hallucinationDetected, expected, actual, delta)
  • Multi-country Tax ID / VAT / EIN / Taiwan GUI checksum verification
  • Clean, strictly typed, auto-corrected normalizedInvoice JSON ready for downstream automation

Why Developers Choose This Actor

FeatureLLM Self-CheckingThis Deterministic MCP Actor
Arithmetic accuracy (19.99 × 3, taxes, credits)Probabilistic (hallucination-prone)100% Exact BigInt Minor-Unit Math
External URL / Web ScrapingN/AZero Scraping, Zero Outbound Calls, Zero SSRF
Data Privacy & LatencySlow extra LLM round-tripPure in-memory compute (< 50ms core execution)
Cost PredictabilityHigh token cost per retryPay-Per-Event: $0.004 per invoice
Downstream RoutingFree-form text explanationsMachine-readable error codes for n8n / Make IF nodes

What It Validates & Normalizes

  1. Line-Item Math: Verifies quantity × unit_price - discount = line_total across arbitrary decimal quantities (up to 6 decimal places) and messy currency strings ("$1,234.50", "NT$ 10,500", "1.234,50", accounting negatives "(50.00)").
  2. Credit Notes & Discounts: Distinguishes legitimate negative credit lines from OCR/LLM sign-flip errors (NEGATIVE_SIGN_MISMATCH).
  3. Tax & Grand Total Verification: Supports both tax-exclusive and tax-inclusive modes, per-line or header tax rates, shipping, and invoice-level discounts.
  4. Multi-Currency Precision: Built-in ISO-4217 minor unit table (USD/EUR/GBP: 2 decimals, TWD/JPY/KRW: 0 decimals, KWD/BHD: 3 decimals) with configurable HALF_UP or HALF_EVEN rounding.
  5. Multi-Country Tax IDs: Validates EU/UK VAT formats (DE, FR, NL, GB, ES, IT, etc.), US EIN, and Taiwan Unified Business Numbers (MOF 2023+ checksum).
  6. Date & Duplicate Guards: Normalizes ISO, US, and Taiwan ROC dates (115/11/28 → 2026-11-28), rejects impossible calendar dates and due_date < issue_date, and flags duplicate OCR line extractions (DUPLICATE_LINE_ITEM).

Pricing (Pay-Per-Event)

  • invoice-validated: $0.004 USD per invoice audited and normalized ($4.00 per 1,000 invoices).
  • No proxy costs. No hidden browser compute overhead. Runs at minimal 128–256MB memory.

Example Input

{
"invoice": {
"invoice_number": "INV-2026-0042",
"vendor_name": "Neural Supplies GmbH",
"vendor_tax_id": "DE123456789",
"issue_date": "2026-11-15",
"due_date": "2026-12-15",
"currency": "EUR",
"tax_rate": "19%",
"line_items": [
{
"description": "GPU Rack Mount",
"quantity": 7,
"unit_price": 149.5,
"line_total": 1096.5
},
{
"description": "Fiber Patch Cable",
"quantity": 4,
"unit_price": 12.25,
"line_total": 49.0
}
],
"subtotal": 1145.5,
"tax_amount": 217.65,
"total": 1363.15
},
"options": {
"toleranceMinorUnits": 1,
"autoCorrectOutput": true
}
}

Example Output (Hallucination Caught & Auto-Corrected)

{
"invoiceNumber": "INV-2026-0042",
"status": "INVALID",
"hallucinationDetected": true,
"confidenceScore": 0,
"currency": "EUR",
"issueCount": 4,
"issues": [
{
"code": "LINE_SUBTOTAL_MISMATCH",
"severity": "ERROR",
"field": "line_items[0].line_total",
"expected": 1046.5,
"actual": 1096.5,
"delta": 50
}
],
"auditTrail": {
"subtotal": { "reported": 1145.5, "computed": 1095.5, "delta": 50 },
"tax": { "reported": 217.65, "computed": 208.15, "delta": 9.5 },
"grandTotal": { "reported": 1363.15, "computed": 1303.65, "delta": 59.5 }
},
"normalizedInvoice": {
"invoice_number": "INV-2026-0042",
"currency": "EUR",
"subtotal": 1095.5,
"tax_amount": 208.15,
"total": 1303.65
}
}

Integration Guide

1. Connect via Claude Desktop / Cursor (Apify MCP Server)

Add this to your claude_desktop_config.json or Cursor MCP configuration:

{
"mcpServers": {
"apify-invoice-validator": {
"command": "npx",
"args": [
"-y",
"@apify/actors-mcp-server",
"--actors",
"YOUR_APIFY_USERNAME/structured-invoice-line-validator"
],
"env": {
"APIFY_TOKEN": "YOUR_APIFY_API_TOKEN"
}
}
}
}

2. Connect via n8n / Make (AP Automation Guardrail)

Recommended 4-node workflow:

  1. Trigger: Email Attachment / Google Drive PDF upload.
  2. LLM Extraction Node: Extract raw invoice JSON (OpenAI / Claude / Mistral OCR).
  3. Apify Run Actor Node (structured-invoice-line-validator): Pass {{ $json }} into invoice.
  4. IF Router Node:
    • status === "VALID" → Auto-post normalizedInvoice to QuickBooks / Xero / ERP.
    • hallucinationDetected === true → Route to Slack/Email human approval with exact auditTrail diff.

Security & Compliance Statement

This Actor performs 100% deterministic in-memory computation on user-supplied JSON payloads. It does not accept external URLs, does not scrape websites, does not make outbound network requests, and does not transmit financial documents to third-party AI APIs.