# Financial PDF Table Reconciler & Invoice Math Verifier (`jacobianflux/financial-pdf-table-reconciler`) Actor

Extract tables, invoice metadata, and LLM-ready Markdown from financial PDFs, invoices, purchase orders, and BOQs with deterministic Qty × UnitPrice and row-sum reconciliation (RECONCILED vs DISCREPANCY_DETECTED). Pages without tables and failed downloads are free.

- **URL**: https://apify.com/jacobianflux/financial-pdf-table-reconciler.md
- **Developed by:** [Jacobian Flux Labs](https://apify.com/jacobianflux) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 table reconcileds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Financial PDF Table Reconciler & Invoice Math Verifier

**Extract structured line items, LLM-ready Markdown tables, and header metadata from financial PDFs, invoices, purchase orders, and tender Bills of Quantities (BOQs) — with deterministic `Quantity × Unit Price` and row-sum reconciliation.**

Standard PDF/OCR scrapers dump raw text or Markdown without verifying whether the numbers actually add up, leaving AI agents vulnerable to arithmetic hallucinations and undetected billing errors. **Financial PDF Table Reconciler** acts as your deterministic financial guardrail in `n8n`, `Make`, `LangGraph`, and `Claude / Cursor MCP`.

***

### Key Advantages Over Generic PDF Extractors

- **Auditor-Grade Arithmetic Proof:** Verifies every line item (`Quantity × UnitPrice == LineTotal`, counting `rowMathMismatches`) and cross-checks `calculatedTotal` against `declaredTotal`, `declaredSubtotal`, `declaredTax`, and `declaredDiscount` within `tolerance`.
- **Clear Tri-State Verdict:** Emits `RECONCILED`, `DISCREPANCY_DETECTED` (with exact `discrepancyDelta`), or `UNRECONCILED_NO_TOTAL`.
- **Dual Structured JSON + LLM Markdown Output:** Returns typed `rows` dictionaries for ERP/SQL ingestion **plus** a clean `markdownTable` string ready to drop directly into RAG or LLM prompts.
- **Invoice Header & Tax ID Extraction:** Automatically detects `invoiceNumber`, `documentDate`, currency (`$`, `€`, `£`, `₹`, `¥`, `CHF` across US `1,234.56`, EU `1.234,56`, and Indian `1,23,456.78` formats), and tax registrations (`GSTIN`, `VAT`, `EIN`).
- **Share-Link Auto-Resolution & Zero-Waste Billing:** Automatically converts Google Drive, Dropbox, and GitHub share links into direct PDF downloads. Cover/text pages with `NO_TABLE_FOUND` and failed downloads are **never billed**.

***

### Input Parameters

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `documentUrls` | `array` | *Sample invoice PDF* | Public, presigned, Google Drive, Dropbox, or GitHub PDF URLs. |
| `maxPages` | `integer` | `20` | Maximum PDF pages to inspect across documents (`1`–`200`). |
| `tolerance` | `number` | `0.05` | Allowable rounding delta before flagging `DISCREPANCY_DETECTED`. |
| `timeout` | `integer` | `30` | HTTP download timeout per PDF in seconds (`5`–`120`). |

***

### Sample Output JSON

```json
{
  "documentUrl": "https://www.princexml.com/samples/invoice-plain/index.pdf",
  "pageNumber": 1,
  "tableIndex": 0,
  "reconciliationStatus": "RECONCILED",
  "declaredTotal": 950.0,
  "calculatedTotal": 950.0,
  "discrepancyDelta": 0.0,
  "declaredSubtotal": null,
  "declaredTax": null,
  "declaredDiscount": null,
  "rowMathMismatches": 0,
  "rowCount": 2,
  "currency": "USD",
  "invoiceNumber": null,
  "documentDate": "26 November 2015",
  "taxIds": [],
  "columns": ["Column_1", "Column_2"],
  "rows": [
    {
      "Column_1": "Website design",
      "Column_2": "$300.00",
      "_line_amount": 300.0
    },
    {
      "Column_1": "Website development",
      "Column_2": "$650.00",
      "_line_amount": 650.0
    }
  ],
  "markdownTable": "| Column_1 | Column_2 |\n| --- | --- |\n| Website design | $300.00 |\n| Website development | $650.00 |",
  "confidenceScore": 100,
  "reconciledAt": "2026-11-23T04:00:00+00:00",
  "error": null
}
```

***

### Integrations (`apify-client`, Claude / Cursor MCP & `n8n`)

#### Python (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("jacobianflux/financial-pdf-table-reconciler").call(
    run_input={
        "documentUrls": [{"url": "https://www.princexml.com/samples/invoice-plain/index.pdf"}],
        "maxPages": 20,
        "tolerance": 0.05,
    }
)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(
        f"Page {item['pageNumber']}: {item['reconciliationStatus']} | "
        f"Declared={item['declaredTotal']} vs Calculated={item['calculatedTotal']} (Delta={item['discrepancyDelta']})"
    )
```

#### Claude Desktop / Cursor / Windsurf (Apify MCP Server)

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com?actors=jacobianflux/financial-pdf-table-reconciler",
      "headers": {
        "Authorization": "Bearer YOUR_APIFY_TOKEN"
      }
    }
  }
}
```

#### `n8n` / Make.com Accounts Payable Automation

1. Trigger on new invoice attachment in Gmail / Outlook / Google Drive (or pipe `documentUrl` from `jacobianflux/gem-cppp-tender-intelligence`).
2. Run **Apify -> Run Actor** (`jacobianflux/financial-pdf-table-reconciler`).
3. Route `reconciliationStatus == "RECONCILED"` directly to QuickBooks / Xero / SAP, and escalate `DISCREPANCY_DETECTED` or `rowMathMismatches > 0` to your finance controller Slack channel.

***

### Transparent Pay-Per-Event Pricing

| Event | Price | Details |
| :--- | :--- | :--- |
| `page-reconciled` | **$0.01 / table** | Charged only when a financial table is extracted and evaluated. Cover pages without tables (`NO_TABLE_FOUND`) and failed/corrupt PDFs (`ERROR`) are **$0 (free)**. |

Non-subscribed Free Plan users can test up to **10 pages per run** automatically.

# Actor input Schema

## `documentUrls` (type: `array`):

List of PDF URLs (invoices, purchase orders, tender BOQs, financial statements). Accepts \[{"url": "..."}] or plain URL strings. Google Drive, Dropbox, and GitHub links are converted to direct downloads automatically.

## `maxPages` (type: `integer`):

Maximum number of PDF pages to inspect across all documents (1 to 200).

## `tolerance` (type: `number`):

Allowable rounding delta (e.g. 0.05) between declaredTotal and calculatedTotal before flagging DISCREPANCY_DETECTED.

## `timeout` (type: `integer`):

HTTP timeout in seconds per PDF download.

## Actor input object example

```json
{
  "documentUrls": [
    {
      "url": "https://www.princexml.com/samples/invoice-plain/index.pdf"
    }
  ],
  "maxPages": 20,
  "tolerance": 0.05,
  "timeout": 30
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing reconciled PDF tables, declared vs. calculated totals, discrepancy deltas, and Markdown renditions.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "documentUrls": [
        {
            "url": "https://www.princexml.com/samples/invoice-plain/index.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jacobianflux/financial-pdf-table-reconciler").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "documentUrls": [{ "url": "https://www.princexml.com/samples/invoice-plain/index.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("jacobianflux/financial-pdf-table-reconciler").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "documentUrls": [
    {
      "url": "https://www.princexml.com/samples/invoice-plain/index.pdf"
    }
  ]
}' |
apify call jacobianflux/financial-pdf-table-reconciler --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jacobianflux/financial-pdf-table-reconciler"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/WfcgRfn4KKUJjDihS/builds/KedUr8YF0eLzHdjCS/openapi.json
