# Duplicate Vendor Invoice Finder (`afkdigital/duplicate-vendor-invoice-finder`) Actor

Review CSV and XLSX invoice exports for exact duplicates and separately flagged candidates. Export row evidence and amounts for review by currency.

- **URL**: https://apify.com/afkdigital/duplicate-vendor-invoice-finder.md
- **Developed by:** [AFK Digital](https://apify.com/afkdigital) (community)
- **Categories:** Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.20 / 1,000 valid invoice revieweds

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

## Duplicate Vendor Invoice Finder

Review accounts-payable invoice exports for duplicate payment risk. Upload a CSV or XLSX and get exact duplicate groups, separate review candidates, source-row evidence and amounts grouped by currency. No accounting connection is required.

### Quick start

Run with `{}` for a synthetic demo. For a real file, upload it into your Apify key-value store, copy its signed HTTPS record link, and supply it as `invoiceFile.url`. Treat this link as a secret and keep the run and its storage private. You can also supply a UTF-8 CSV string in `invoiceFile.csvText` or base64 XLSX in `invoiceFile.xlsxBase64`. Supply one source only.

```json
{
  "invoiceFile": {"format":"csv","csvText":"Vendor,Number,Total,Currency\nV-12,INV-1024,100.00,USD\nV-12,INV-1024,100.00,USD"},
  "columnMapping": {"supplier_id":"Vendor","invoice_number":"Number","amount":"Total","currency":"Currency"},
  "dateToleranceDays": 5,
  "amountTolerance": 0,
  "maxInvoices": 5000
}
```

Map supplier ID, invoice number, invoice amount and three-letter currency. Optional mappings include `invoice_id` (a row ID), `invoice_date` (ISO YYYY-MM-DD or a native XLSX date), `document_type` and `status`. Keep identifiers as text in Excel to preserve leading zeros. Use plain decimals without separators or symbols. An absent row ID falls back to `row-N`. CSV accepts comma, semicolon, tab or pipe via `invoiceFile.delimiter`. For a multi-sheet workbook, provide `invoiceFile.sheet`. Export literal cell values. The limit is 5 MiB and up to 5,000 invoice rows per run. A file above its row limit fails before producing results. Invalid rows are identified by source row and excluded from billing.

### How matching works

- `exact_duplicate` requires the same supplier ID, case-sensitive invoice number after outer trimming, exact decimal amount and currency. Dates do not gate this rule.
- `needs_review` separates punctuation/case variants and near-number candidates. Near-number candidates require a close date, similar invoice numbers and an amount within tolerance. Same invoice numbers with an amount difference also require a close date and the amount tolerance. The default amount tolerance is zero. Both tolerances use absolute values. For equal amounts, distinct numbers on three dates with weekly, fortnightly or monthly spacing are reported as possible recurring activity. Batches of four or more distinct numbers on the same day are also reported separately. These patterns suppress fuzzy-number matches between affected rows. Exact and format matches take precedence.
- Map type and status to identify positive credit notes, cancelled/voided entries and explicitly recurring invoices. Negative and zero amounts are excluded. Exclusions and invalid rows appear separately in the Summary with source row references.
- Exact groups take precedence. Among remaining rows, formatting pairs take precedence, then date-dependent pairs in source order. Each row belongs to at most one group. Overlapping candidate pairs are counted separately in the Summary. Consecutive invoice numbers issued near one another can still produce a review candidate. Verify findings against your ledger.

### Outputs and billing

The default Dataset exports JSON and CSV with group ID, supplier, invoice IDs, match status, reasons, currency, review amount and evidence rows. Evidence row numbers are 1-based and include the header. CSV counts logical records, including any quoted multiline fields as one record. Use the linked spreadsheet-safe CSV when opening results in spreadsheet software. This export includes column headers even when the Dataset contains zero groups. The Summary records the input sheet, exclusions, invalid rows, successful review count and amounts by currency.

An exact group's review amount is the total of copies after the first row. A review pair uses the lower amount. Review amounts represent records to investigate. They do not establish a payment, overpayment or savings. Currency totals are never combined.

The proposed Store model uses one proportional Pay per Event charge per valid customer invoice reviewed, expressed per 1,000 invoices. Classification of a valid credit, cancellation or recurring row counts as review. Findings and the built-in demo carry no Actor event fee. On paid runs, the charge limit must cover all valid rows. Apify stores the input and outputs under its storage retention settings. The Actor does not log invoice records or signed links.

### Local tests

```sh
python -m unittest discover -s tests -v
docker build -t newapi81:1.0.0 .
```

# Actor input Schema

## `invoiceFile` (type: `object`):

Supply format csv/xlsx and one of csvText, xlsxBase64, or a signed HTTPS Apify key-value-store record URL in url. Leave empty for the synthetic demo.

## `columnMapping` (type: `object`):

Map supplier_id, invoice_number, amount and currency to exact headers. Optional invoice_id, invoice_date, document_type and status.

## `dateToleranceDays` (type: `integer`):

Maximum gap for date-dependent candidates.

## `amountTolerance` (type: `number`):

Maximum absolute amount difference in the source currency. Does not affect exact matching.

## `maxInvoices` (type: `integer`):

Files exceeding this limit fail without a partial review.

## Actor input object example

```json
{
  "dateToleranceDays": 5,
  "amountTolerance": 0,
  "maxInvoices": 5000
}
```

# Actor output Schema

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

No description

## `csv` (type: `string`):

No description

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

No description

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("afkdigital/duplicate-vendor-invoice-finder").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("afkdigital/duplicate-vendor-invoice-finder").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 '{}' |
apify call afkdigital/duplicate-vendor-invoice-finder --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,afkdigital/duplicate-vendor-invoice-finder"
        }
    }
}
```

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/kXMUBQcfuLdKyxRSF/builds/KS7sUVNfWH4tHS2rf/openapi.json
