# Invoice and Payment CSV Reconciliation (`dr0g0n/my-actor`) Actor

Match invoice and payment CSV exports by reference. Combine split payments, flag missing, partial and duplicate records, and download a reconciliation report in CSV or JSON.

- **URL**: https://apify.com/dr0g0n/my-actor.md
- **Developed by:** [Dr0g0n](https://apify.com/dr0g0n) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$200.00 / 1,000 completed reconciliation reports

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

## Invoice and Payment CSV Reconciliation

Compare invoice and payment exports by reference and download a report of what matched and what needs review. The Actor combines split payments, flags duplicate invoice references, and identifies missing payments, partial payments, overpayments and payments without an invoice.

Use it for month-end reviews, marketplace payment exports and back-office workflows when both exports already contain a shared invoice reference. The same inputs work in Apify Console and through the Apify API.

### Try it with sample data

1. Open **Input** and use the prefilled sample CSVs.
2. Run the Actor. The sample includes one fully paid invoice with two payments and one overpaid invoice.
3. Open **Output** and download **Spreadsheet-ready CSV report**. Use **Detailed reconciliation JSON** to integrate the result or **Summary JSON** to see counts by status.

To use your own exports, paste UTF-8 CSV text for invoices and payments. The default columns are `reference` and `amount`. Select the matching columns and decimal separator separately for each export. Set an absolute tolerance, such as `0.01`, when you accept differences of one cent or less.

```json
{
  "invoices_csv": "reference,amount\nINV-001,120.00\nINV-002,80.00",
  "payments_csv": "reference,amount\nINV-001,50.00\nINV-001,70.00\nINV-002,78.50",
  "tolerance": "0.00"
}
```

In this example, INV-001 matches and INV-002 is underpaid by 1.50. The signed difference is total payments minus total invoices.

### Results and billing

| Record | Contents |
| --- | --- |
| `REPORT_CSV` | One row per reference group, with status, counts, totals, signed difference and review notes |
| `REPORT` | Summary and all reconciliation rows in JSON |
| `SUMMARY` | Input counts, status totals and number of groups to review |

The records are written to the run's default key-value store. The default dataset contains one row with the summary counts. The Actor generates one `reconciliation-completed` event after writing the report and summary. Check the **Pricing** tab for the current price before running. A report can include rows flagged for review.

### Requirements and data handling

- Use the same currency in both exports. Amounts support two decimal places and decimal points or commas. Use plain amounts without currency symbols or punctuation for thousands.
- Provide up to 20,000 data rows and 3 million characters in each CSV. The Actor detects comma or semicolon delimiters. You can specify pipe or tab in the JSON input.
- Matching uses the shared reference after trimming whitespace. Duplicate invoices and rows with missing references or invalid amounts require review.
- The Actor processes the supplied data on Apify and writes input and output records to Apify storage. It uses no bank credentials, third-party APIs or AI model. Include only the columns needed for matching, check your Apify storage retention settings and delete run data you no longer need.
- The report supports review. Verify flagged rows against the source exports before adjusting balances. PDF invoices, currency conversion and direct bank connections are outside the supported workflow.

### Local verification

```sh
python cli.py examples/input.json
python -m unittest discover -s tests -v
```

# Actor input Schema

## `invoices_csv` (type: `string`):

Paste UTF-8 invoice export. Required columns: reference, amount.

## `payments_csv` (type: `string`):

Paste UTF-8 payment export. Required columns: reference, amount.

## `invoice_key_column` (type: `string`):

Column in the invoice CSV containing the shared reference.

## `invoice_amount_column` (type: `string`):

Column in the invoice CSV containing the invoiced amount.

## `payment_key_column` (type: `string`):

Column in the payment CSV containing the shared reference.

## `payment_amount_column` (type: `string`):

Column in the payment CSV containing the payment amount.

## `invoice_decimal_separator` (type: `string`):

Character that separates whole and fractional amounts in the invoice CSV.

## `payment_decimal_separator` (type: `string`):

Character that separates whole and fractional amounts in the payment CSV.

## `invoices_delimiter` (type: `string`):

Leave blank to detect comma or semicolon. Set explicitly for tab or pipe.

## `payments_delimiter` (type: `string`):

Leave blank to detect comma or semicolon. Set explicitly for tab or pipe.

## `tolerance` (type: `string`):

Maximum absolute difference treated as a match. Use a decimal point.

## Actor input object example

```json
{
  "invoices_csv": "reference,amount\nINV-001,120.00\nINV-002,79.50",
  "payments_csv": "reference,amount\nINV-001,50.00\nINV-001,70.00\nINV-002,80.00",
  "invoice_key_column": "reference",
  "invoice_amount_column": "amount",
  "payment_key_column": "reference",
  "payment_amount_column": "amount",
  "invoice_decimal_separator": ".",
  "payment_decimal_separator": ".",
  "tolerance": "0.00"
}
```

# Actor output Schema

## `report` (type: `string`):

Contains summary and every reference group with balances and review flags.

## `summary` (type: `string`):

No description

## `csv_report` (type: `string`):

CSV export with spreadsheet-formula injection protection.

# 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 = {
    "invoices_csv": `reference,amount
INV-001,120.00
INV-002,79.50`,
    "payments_csv": `reference,amount
INV-001,50.00
INV-001,70.00
INV-002,80.00`
};

// Run the Actor and wait for it to finish
const run = await client.actor("dr0g0n/my-actor").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 = {
    "invoices_csv": """reference,amount
INV-001,120.00
INV-002,79.50""",
    "payments_csv": """reference,amount
INV-001,50.00
INV-001,70.00
INV-002,80.00""",
}

# Run the Actor and wait for it to finish
run = client.actor("dr0g0n/my-actor").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 '{
  "invoices_csv": "reference,amount\\nINV-001,120.00\\nINV-002,79.50",
  "payments_csv": "reference,amount\\nINV-001,50.00\\nINV-001,70.00\\nINV-002,80.00"
}' |
apify call dr0g0n/my-actor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dr0g0n/my-actor"
        }
    }
}
```

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/ZzuTxNhlX7iagXWvd/builds/cNqRp4uWxfHLvUgUK/openapi.json
