# PO Invoice & Receipt Exception Report (`h_murdock/invoice-po-receipt-audit`) Actor

Audit cumulative PO, invoice and split-receipt quantities from CSV or JSON. Flag over-invoicing, receipt shortfalls, price deviations, duplicate IDs and missing links. Export JSON, CSV and HTML.

- **URL**: https://apify.com/h\_murdock/invoice-po-receipt-audit.md
- **Developed by:** [Gilad Ronen](https://apify.com/h_murdock) (community)
- **Categories:** E-commerce, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.50 / completed report

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

### What does PO Invoice & Receipt Exception Report do?

Compare **purchase-order lines, current invoices, historical invoices and multiple partial receipts** in one cumulative exception report. Supply structured CSV or JSON; receive a purchase-line reconciliation, a flat findings queue, exact decimal totals and a standalone HTML report. The Actor makes no document downloads, external data calls or changes to your systems.

For example, a PO orders 100 EA at USD 4 each. Two receipts record 20 and 40 EA, an earlier invoice billed 40 EA, and a new invoice bills 30 EA. The report shows 70 invoiced, 60 received and a **10 EA receipt shortfall** in the supplied comparable evidence. It does not allocate an individual receipt to a particular invoice or approve an invoice for payment.

### Why use this invoice and PO reconciliation?

Run the same checks each time you receive another invoice batch. The report identifies cumulative over-invoicing, invoice unit-price changes, receipt shortfalls, excess receipts, duplicate document lines, missing links and incompatible units or currencies. Exact identifiers keep evidence traceable. There is no fuzzy product matching or unexplained match score.

Apify API access, scheduling and integrations can run the report on repeated exports. Use the API tab for an invocation example. Every new run is a separate report, including a repeat of the same input.

### How to use it

1. Export the relevant PO lines, all receipts in scope, and current and historical invoice lines from your authorized source systems.
2. Remove names, addresses, banking details and unrelated columns. Retain stable supplier, PO, document and line identifiers.
3. Paste JSON arrays or CSV text into the Input tab. Each table can use a different format. Use exactly one format for each table.
4. Confirm the two coverage flags only after checking that the submitted history and receipts cover the same cumulative scope. Choose tolerances appropriate for those units and currencies.
5. Run the Actor and download the findings and reconciliation. Review incomplete lines before interpreting their totals.

### Input schemas and exact matching

The top-level tables are `purchaseOrders`, `invoices`, `historicalInvoices` and `receipts`. They are JSON arrays. The equivalent CSV fields are `purchaseOrdersCsv`, `invoicesCsv`, `historicalInvoicesCsv` and `receiptsCsv`. Omitted tables are empty. At least one row is required overall. The example input includes a matched line, multiple partial receipts, historical invoices, price deviations, currency/unit differences, duplicate PO and invoice lines, and missing links.

| Table | Fields |
| --- | --- |
| All tables | `supplierId`, `poId`, `poLineId`, `quantity`, `unit` |
| Purchase orders | Common fields plus `currency`, `unitPrice` |
| Invoices and historical invoices | Common fields plus `currency`, `unitPrice`, `invoiceId`, `invoiceLineId` |
| Receipts | Common fields plus `receiptId`, `receiptLineId` |

All quantities and prices **must be decimal strings**, such as `"0.125"` or `"100"`. JSON numbers, thousands separators, exponent notation, negative values and leading zero decimal forms such as `"01"` are rejected. Up to 12 integer and 6 fractional digits are supported. Zero is allowed. Values are calculated with integer arithmetic; quantity × price retains up to 12 fractional digits without currency rounding.

Identifiers are strings up to 80 characters. Leading zeros remain significant: `"001"` and `"1"` differ. Matching is case-sensitive and uses exactly `supplierId` + `poId` + `poLineId`. No trimming or case conversion is performed; padded IDs are rejected. Missing/empty linking and document IDs produce findings and exclude affected evidence instead of inventing matches. Units are explicit, case-sensitive strings up to 24 characters. Currencies must be uppercase three-letter codes; the Actor checks exact equality, not currency-code validity or conversions.

Every occurrence of a duplicate PO key is ambiguous. Every occurrence of a duplicate document-line identity is excluded. Invoice uniqueness is supplier + invoice ID + invoice-line ID, across both current and historical tables. Receipt uniqueness is supplier + receipt ID + receipt-line ID. Different suppliers can reuse document numbers. An invoice line must appear in either current or history, never both.

CSV supports a UTF-8 BOM, quoted commas, escaped quotes and quoted multiline fields. Blank physical lines are skipped. Duplicate or padded headers, irregular row lengths and malformed quoting are rejected. By default headers must be canonical field names. To map source exports, use `columnMappings`, for example:

```json
{
  "columnMappings": {
    "purchaseOrders": {
      "supplierId": "Vendor", "poId": "Order", "poLineId": "Line",
      "quantity": "Qty", "unit": "UOM", "currency": "Currency", "unitPrice": "Price"
    }
  }
}
```

Map each required field. Unmapped columns are ignored only when an explicit mapping is supplied. Unknown JSON row fields are rejected. Use the included CSV example to test a mapped import.

### Coverage, tolerances and interpretation

`historyComplete` and `receiptsComplete` default to `false`. Set `historyComplete: true` when all relevant prior invoices are submitted, including when you know there are none. Set `receiptsComplete: true` when the submitted receipts cover the same cumulative scope. These are caller assertions, not facts verified by the Actor. Unconfirmed coverage marks all purchase lines incomplete.

`tolerances` accepts `quantity` and `unitPrice`, both nonnegative decimal strings defaulting to `"0"`. Quantity tolerance applies to invoice-over-order, invoice-over-receipt and receipt-over-order differences. Unit-price tolerance applies to the absolute difference between each invoice price and its linked PO price, including historical invoices. A difference equal to tolerance is not flagged. There is no percentage tolerance. These numerical thresholds apply in each line's unit/currency; use separate runs if different lines need different thresholds.

Current and historical invoice quantities are summed. Receipt quantities are summed separately. Unit/currency mismatches, duplicate document lines and missing required identity are excluded from both quantities and money. Incomplete line totals describe accepted evidence only and are not final liabilities. A missing PO or ambiguous match produces a finding without allocation. Absent comparable receipts for a positive invoiced quantity remain incomplete even under a large tolerance.

`orderedUnreceivedQuantity` is an informational outstanding quantity, not a late-delivery finding. `cumulativePriceVariance` is the signed difference between accepted invoice value and accepted cumulative invoice quantity × PO unit price; it is not compared to the full PO value. Quantity over-invoicing is checked separately. No totals are summed across currencies or units.

### Output and downloads

The default dataset contains **one complete report item** with `summary`, `scope`, `rows` and `findings`. You can download the dataset in various formats such as JSON, HTML, CSV, or Excel. For a flat review workflow, use these dedicated key-value-store files:

| File | Contents |
| --- | --- |
| `OUTPUT` | Full compact JSON report, including reconciliation and findings |
| `reconciliation.csv` | One row per submitted PO line, totals, status and evidence references |
| `findings.csv` | Stable finding ID, severity, reason, source references and applicable numerical evidence |
| `report.html` | Escaped, standalone readable report, with no external scripts or assets |

Source references use the table name and 1-based data-row index, excluding CSV headers. For example `receipts:2` refers to the second parsed receipt record, not necessarily physical file line 3 when quoting spans lines. Aggregate findings point to a purchase-row reference whose accepted/excluded reference lists identify all contributing evidence. Finding IDs are deterministic for the same input order, not permanent identifiers across reordered files.

`no-exceptions` means no checked exception in submitted comparable records under the configured tolerances. `exceptions` identifies review findings with otherwise comparable evidence. `incomplete` means identity, coverage or comparability prevents a complete reconciliation. Report-level `reviewRequired` also includes orphan source rows that cannot be assigned to a PO. CSV fields that could execute spreadsheet formulas receive an apostrophe prefix; use JSON when exact unmodified identifiers are needed.

### Pricing and limits

The price is **$0.50 per completed report**, with platform usage included, for up to **10,000 combined rows and 4 MB of JSON input**. One `report-completed` event is charged after all exports have been validated and saved, using one complete dataset item. There is no startup fee or additional dataset-item fee. Invalid input and insufficient report budget do not produce a report charge. New runs are billable again.

Full JSON is capped at 8 MB and each download at 9 MB. Exception-heavy data or long identifiers can reach those output limits before the row limit; split that input into smaller complete scopes. All output sizes are checked before any report event. Defaults are 1024 MB memory and a 180-second timeout.

If an execution stops while writing exports, some downloads can exist before billing; resume the same run to complete them. If a dataset write succeeds but charging is interrupted, resurrection validates the input fingerprint and deterministically rebuilt saved report before charging once. An already charged saved report regenerates downloads without another event. Do not change input, edit the saved dataset, or delete its only report before resurrection. Use a new run for revised data.

### Limits, privacy and support

This Actor provides arithmetic exception review, not payment approval, invoice rejection, tax advice, accounting compliance, fraud detection or proof of receipt. It supports supplied cumulative snapshots, without dates or automatic period filtering. Callers must align the reporting scope. Credits, returns, cancellations, discounts, taxes, freight, OCR/PDF extraction, ERP synchronization and currency/unit conversion are outside this version. Negative values and unsupported fields are rejected.

Submit only records you are authorized to process. Inputs and generated reports are held in your Apify run storage under your account's access and retention settings; this Actor does not delete them automatically. Raw commercial rows are not logged. No customer data is sent to an external AI provider or target website. Refer to the Issues tab for reproducible problems using synthetic examples, and avoid attaching confidential invoices.

The distinction between unit-price and cumulative quantity checks is consistent with the terminology in [Microsoft's invoice-matching overview](https://learn.microsoft.com/en-us/dynamics365/finance/accounts-payable/accounts-payable-invoice-matching). This Actor is an independent, narrower report and does not implement that system's accounting policies.

# Actor input Schema

## `purchaseOrders` (type: `array`):

Structured purchaseOrders rows. Supply this or purchaseOrdersCsv. Decimal quantities/prices and all IDs must be strings. Up to 10,000 combined rows in 4 MB total input. See README for row schema.

## `purchaseOrdersCsv` (type: `string`):

Comma-delimited UTF-8 purchaseOrders data with headers. BOM and quoted fields supported. Do not supply alongside the JSON rows for this table.

## `invoices` (type: `array`):

Structured invoices rows. Supply this or invoicesCsv. Decimal quantities/prices and all IDs must be strings. Up to 10,000 combined rows in 4 MB total input. See README for row schema.

## `invoicesCsv` (type: `string`):

Comma-delimited UTF-8 invoices data with headers. BOM and quoted fields supported. Do not supply alongside the JSON rows for this table.

## `receipts` (type: `array`):

Structured receipts rows. Supply this or receiptsCsv. Decimal quantities/prices and all IDs must be strings. Up to 10,000 combined rows in 4 MB total input. See README for row schema.

## `receiptsCsv` (type: `string`):

Comma-delimited UTF-8 receipts data with headers. BOM and quoted fields supported. Do not supply alongside the JSON rows for this table.

## `historicalInvoices` (type: `array`):

Structured historicalInvoices rows. Supply this or historicalInvoicesCsv. Decimal quantities/prices and all IDs must be strings. Up to 10,000 combined rows in 4 MB total input. See README for row schema.

## `historicalInvoicesCsv` (type: `string`):

Comma-delimited UTF-8 historicalInvoices data with headers. BOM and quoted fields supported. Do not supply alongside the JSON rows for this table.

## `columnMappings` (type: `object`):

Optional per-table object mapping canonical field names to CSV headers, for example {"purchaseOrders":{"supplierId":"Vendor","quantity":"Qty"}}. Map every required field. Unmapped CSV columns are ignored only with an explicit mapping.

## `historyComplete` (type: `boolean`):

Set true only when all prior invoices for the supplied PO lines are included, or when there are none. False marks reconciliation incomplete.

## `receiptsComplete` (type: `boolean`):

Set true only when the submitted receipt records cover the same cumulative scope. False marks reconciliation incomplete.

## `tolerances` (type: `object`):

Nonnegative decimal strings: quantity is in each PO line unit; unitPrice is in each line currency. Differences equal to tolerance are not flagged. No percent tolerance or currency conversion.

## Actor input object example

```json
{
  "purchaseOrders": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "100",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "10",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "1.25"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "03",
      "quantity": "5",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "2"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "10",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "05",
      "quantity": "2",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "05",
      "quantity": "3",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "2",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    }
  ],
  "invoices": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "30",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "NEW-A",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "4",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "1.25",
      "invoiceId": "NEW-B",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "6",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "1.25",
      "invoiceId": "NEW-C",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "03",
      "quantity": "6",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "2.10",
      "invoiceId": "NEW-D",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "1",
      "unit": "BOX",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "NEW-E",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "1",
      "unit": "EA",
      "currency": "EUR",
      "unitPrice": "4",
      "invoiceId": "NEW-F",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "05",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "NEW-G",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "DUPLICATE",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "DUPLICATE",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "99",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "ORPHAN",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "MISSING-LINK",
      "invoiceLineId": "01"
    }
  ],
  "receipts": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "20",
      "unit": "EA",
      "receiptId": "RCPT-A",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "40",
      "unit": "EA",
      "receiptId": "RCPT-B",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "4",
      "unit": "EA",
      "receiptId": "RCPT-C",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "6",
      "unit": "EA",
      "receiptId": "RCPT-D",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "03",
      "quantity": "5",
      "unit": "EA",
      "receiptId": "RCPT-E",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "10",
      "unit": "EA",
      "receiptId": "RCPT-F",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "2",
      "unit": "EA",
      "receiptId": "RCPT-G",
      "receiptLineId": "01"
    }
  ],
  "historicalInvoices": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "40",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "OLD-A",
      "invoiceLineId": "01"
    }
  ],
  "historyComplete": false,
  "receiptsComplete": false,
  "tolerances": {
    "quantity": "0",
    "unitPrice": "0"
  }
}
```

# Actor output Schema

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

One dataset item containing the complete report, reconciliation rows and findings.

## `json` (type: `string`):

No description

## `reconciliation` (type: `string`):

No description

## `findings` (type: `string`):

No description

## `html` (type: `string`):

Download and open locally. Escaped HTML, no external scripts or resources.

# 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 = {
    "purchaseOrders": [
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "100",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "10",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "1.25"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "03",
            "quantity": "5",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "2"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "10",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "05",
            "quantity": "2",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "05",
            "quantity": "3",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "2",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4"
        }
    ],
    "invoices": [
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "30",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "NEW-A",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "4",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "1.25",
            "invoiceId": "NEW-B",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "6",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "1.25",
            "invoiceId": "NEW-C",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "03",
            "quantity": "6",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "2.10",
            "invoiceId": "NEW-D",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "1",
            "unit": "BOX",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "NEW-E",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "1",
            "unit": "EA",
            "currency": "EUR",
            "unitPrice": "4",
            "invoiceId": "NEW-F",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "05",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "NEW-G",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "DUPLICATE",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "DUPLICATE",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "99",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "ORPHAN",
            "invoiceLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "MISSING-LINK",
            "invoiceLineId": "01"
        }
    ],
    "receipts": [
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "20",
            "unit": "EA",
            "receiptId": "RCPT-A",
            "receiptLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "40",
            "unit": "EA",
            "receiptId": "RCPT-B",
            "receiptLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "4",
            "unit": "EA",
            "receiptId": "RCPT-C",
            "receiptLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "6",
            "unit": "EA",
            "receiptId": "RCPT-D",
            "receiptLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "03",
            "quantity": "5",
            "unit": "EA",
            "receiptId": "RCPT-E",
            "receiptLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "10",
            "unit": "EA",
            "receiptId": "RCPT-F",
            "receiptLineId": "01"
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "2",
            "unit": "EA",
            "receiptId": "RCPT-G",
            "receiptLineId": "01"
        }
    ],
    "historicalInvoices": [
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "40",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "OLD-A",
            "invoiceLineId": "01"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("h_murdock/invoice-po-receipt-audit").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 = {
    "purchaseOrders": [
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "100",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "10",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "1.25",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "03",
            "quantity": "5",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "2",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "10",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "05",
            "quantity": "2",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "05",
            "quantity": "3",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "2",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
        },
    ],
    "invoices": [
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "30",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "NEW-A",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "4",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "1.25",
            "invoiceId": "NEW-B",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "6",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "1.25",
            "invoiceId": "NEW-C",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "03",
            "quantity": "6",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "2.10",
            "invoiceId": "NEW-D",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "1",
            "unit": "BOX",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "NEW-E",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "1",
            "unit": "EA",
            "currency": "EUR",
            "unitPrice": "4",
            "invoiceId": "NEW-F",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "05",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "NEW-G",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "DUPLICATE",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "DUPLICATE",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "99",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "ORPHAN",
            "invoiceLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "",
            "quantity": "1",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "MISSING-LINK",
            "invoiceLineId": "01",
        },
    ],
    "receipts": [
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "20",
            "unit": "EA",
            "receiptId": "RCPT-A",
            "receiptLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "40",
            "unit": "EA",
            "receiptId": "RCPT-B",
            "receiptLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "4",
            "unit": "EA",
            "receiptId": "RCPT-C",
            "receiptLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "02",
            "quantity": "6",
            "unit": "EA",
            "receiptId": "RCPT-D",
            "receiptLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "03",
            "quantity": "5",
            "unit": "EA",
            "receiptId": "RCPT-E",
            "receiptLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "04",
            "quantity": "10",
            "unit": "EA",
            "receiptId": "RCPT-F",
            "receiptLineId": "01",
        },
        {
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "06",
            "quantity": "2",
            "unit": "EA",
            "receiptId": "RCPT-G",
            "receiptLineId": "01",
        },
    ],
    "historicalInvoices": [{
            "supplierId": "001",
            "poId": "PO-100",
            "poLineId": "01",
            "quantity": "40",
            "unit": "EA",
            "currency": "USD",
            "unitPrice": "4",
            "invoiceId": "OLD-A",
            "invoiceLineId": "01",
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("h_murdock/invoice-po-receipt-audit").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 '{
  "purchaseOrders": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "100",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "10",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "1.25"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "03",
      "quantity": "5",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "2"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "10",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "05",
      "quantity": "2",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "05",
      "quantity": "3",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "2",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4"
    }
  ],
  "invoices": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "30",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "NEW-A",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "4",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "1.25",
      "invoiceId": "NEW-B",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "6",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "1.25",
      "invoiceId": "NEW-C",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "03",
      "quantity": "6",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "2.10",
      "invoiceId": "NEW-D",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "1",
      "unit": "BOX",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "NEW-E",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "1",
      "unit": "EA",
      "currency": "EUR",
      "unitPrice": "4",
      "invoiceId": "NEW-F",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "05",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "NEW-G",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "DUPLICATE",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "DUPLICATE",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "99",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "ORPHAN",
      "invoiceLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "",
      "quantity": "1",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "MISSING-LINK",
      "invoiceLineId": "01"
    }
  ],
  "receipts": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "20",
      "unit": "EA",
      "receiptId": "RCPT-A",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "40",
      "unit": "EA",
      "receiptId": "RCPT-B",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "4",
      "unit": "EA",
      "receiptId": "RCPT-C",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "02",
      "quantity": "6",
      "unit": "EA",
      "receiptId": "RCPT-D",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "03",
      "quantity": "5",
      "unit": "EA",
      "receiptId": "RCPT-E",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "04",
      "quantity": "10",
      "unit": "EA",
      "receiptId": "RCPT-F",
      "receiptLineId": "01"
    },
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "06",
      "quantity": "2",
      "unit": "EA",
      "receiptId": "RCPT-G",
      "receiptLineId": "01"
    }
  ],
  "historicalInvoices": [
    {
      "supplierId": "001",
      "poId": "PO-100",
      "poLineId": "01",
      "quantity": "40",
      "unit": "EA",
      "currency": "USD",
      "unitPrice": "4",
      "invoiceId": "OLD-A",
      "invoiceLineId": "01"
    }
  ]
}' |
apify call h_murdock/invoice-po-receipt-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,h_murdock/invoice-po-receipt-audit"
        }
    }
}
```

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/Icu1InWeubsEu0BvV/builds/uExgxWbXp8b5icwmp/openapi.json
