---
title: Reconciliation runs, matches and cases
description: Run a ruleset over a period's records, see what it matched and why, undo a wrong match, match by hand, and work the cases it opens for every record left over and every difference until the money is recovered or written off.
section: finance
order: 55
audience: [user, operator, agent]
sources: [services/nodejs-cloud/lib/finance/recon/run.ts, services/nodejs-cloud/lib/finance/recon/matches.ts, services/nodejs-cloud/lib/finance/recon/cases.ts, services/nodejs-cloud/lib/finance/recon/runs-pure.ts, services/nodejs-cloud/lib/finance/recon/runs-mcp.ts, services/nodejs-cloud/app/(finance)/finance/recon/runs, services/nodejs-cloud/app/(finance)/finance/recon/cases, services/nodejs-cloud/migrations/0436_fin_recon_runs.sql]
features: [cloud.page-finance]
---

A **run** takes one [ruleset](/docs/finance/reconciliation-rules.md) and a period, and matches the unmatched records of the ruleset's
[sources](/docs/finance/reconciliation-sources.md) dated in that period. What matches is marked matched; what is left over, and every
match whose amounts differ by more than the run's tolerance, becomes a **case** you work until it is closed. Runs and
cases are part of the Reconciliation module (`finance.recon`) and live in **Finance > Reconciliation** under **Runs**
(`/finance/recon/runs`, one run at `?id=…`) and **Cases** (`/finance/recon/cases`, one case at `?id=…`).

## Starting a run {#runs}

Pick a ruleset, the first and last day (at most 366 days), and a tolerance in minor units (`100` is 1.00; the default
is 0). Every source a rule names must be a source of the ruleset's entity. One ruleset has at most one run going at a
time; starting another while one runs answers 409 with the running one's id.

A run works in the background, in small steps the minute cron drives, and the page shows how far it has got. Each step
holds a lease on the run for a short while, so two steps never work the same run at once, and every write checks the
lease and each record's state before it changes anything. A step that stops halfway (a deploy, a timeout) loses
nothing: the next one carries on from the records still unmatched. A run that keeps failing stops after six tries and
says why (`bad_rules`, `bad_sources`, `engine_input` or `internal`).

Running the same period again is safe. Records already matched are left alone, and a record or a difference that
already has an open case does not get a second one, so a second run over the same period finds nothing new. When a later
run does match a record an earlier run left over (the other side's file came in since), the record's open "No match"
or missing payout case is closed as dismissed with its exception, and the match keeps it, so undoing the match opens it
again. A run never closes a duplicate charge or an unexpected refund: finding the record's other side does not give
the money back.

When a run finishes it shows its totals per source: records in the period, matched, left unmatched and excluded, with
the amounts. The ruleset's version is kept on the run, so its matches can always be explained by the rules that made
them.

## Matches {#matches}

Every match records its rule (or who made it), both sides' records and totals, what was expected (from a
[contract](/docs/finance/recon-contracts.md) when the source's counterparty has one), the difference, and a plain-English
explanation. A match is `active`, `suggested` (made by an agent or by hand to confirm later; its records stay
unmatched) or `undone`.

- **Match by hand**: choose records from two or more sources of one entity, in one currency, none already matched or
  excluded, and give a reason. The records' own open cases (`unmatched`, `duplicate_charge`, `unexpected_refund` or
  `missing_payout`) are closed as dismissed.
- **Confirm**: a suggestion becomes active and its records matched; confirming a rule's match records that a person
  checked it.
- **Undo**: the records go back to unmatched exactly as they were, the cases the match opened are dismissed, and the
  cases it closed are opened again. An undone match stays on record.
- **Exclude**: take a record out of reconciliation (a test charge, a duplicate line) with a reason. Its open case, of
  whatever kind, is dismissed. `include` brings it back as unmatched. A matched record is excluded only after its match
  is undone.

## Cases {#cases}

A case says what is wrong, on which records, and how much is at stake: expected, actual and the difference (actual
minus expected; for an unmatched record, its own amount). Each case also opens an entry in the
[exceptions queue](/docs/finance/exceptions.md) under the module `recon`.

| Kind | Opened when |
|---|---|
| `unmatched` | A record in the period matched nothing |
| `short_payment` | A match's difference is below minus the tolerance, or a contract says the payout was short |
| `over_payment` | A match's difference is above the tolerance |
| `over_commission` | A contract says the counterparty kept more commission than agreed |
| `fee_mismatch` | A contract says a fee was charged that does not match its terms |
| `missing_payout` | A counterparty's record that a contract says should have been paid by now was never paid |
| `late_payout` | A contract says the payout came after it was due |
| `duplicate_charge` | An unmatched charge has the same reference and amount as a matched charge of the same source within 3 days |
| `unexpected_refund` | An unmatched refund (a negative record of kind `refund`) that nothing explains |

A contract applies to a match through either side's source: the agency's statement priced against the property system
works as the property system priced against the agency's statement. When every record on the statement side carries a
`commission` field (a [mapping field](/docs/finance/reconciliation-sources.md#fields)), the commission it shows is compared with the
contract's, so an over-charged commission opens `over_commission` for the exact difference. A record of kind `payout` is
already net and due on its own date.

A case is `open`, then `claimed` (you asked the counterparty for the money: a claim reference and a due date), and is
closed as `recovered` or `partly_recovered` (with the amount recovered), `written_off` or `dismissed` (each with a
note). Closing a case resolves its exception. A closed case stays closed: a new gap opens a new case.
Claim letters, the recovery ledger, the daily report and the adjusting journal of a written-off case are in
[Recovery](/docs/finance/reconciliation-recovery.md).

## Who may do what {#rights}

| Action | Roles |
|---|---|
| Read runs, matches and cases (`recon.read`) | controller, recon clerk, auditor |
| Start a run (`recon.run`) | controller, recon clerk |
| Match, confirm, undo, exclude and work cases (`recon.work`) | controller, recon clerk |

Each on the run's, match's or case's entity; one on an entity you cannot see answers as if it did not exist. See
[Finance roles](/docs/finance/roles.md). An organisation without Reconciliation gets 403 `product_not_enabled` naming
`finance.recon`.

A case can be mentioned and linked anywhere in Petawork as `fin_recon_case:<id>` (see
[Finance in references](/docs/finance/references.md)); only people who may read the case see its card.

## Events {#events}

On the [event chain](/docs/finance/audit-trail.md): `finance.recon_run.started`, `.matched` (one per batch of matches written) and
`.completed`; `finance.recon_match.created`, `.suggested`, `.confirmed` and `.undone`; `finance.recon_record.excluded`
and `.included`; `finance.recon_case.opened`, `.claimed`, `.recovered` (fully or partly; the status says which),
`.written_off`, `.dismissed`, `.reopened` and `.updated`. The [webhooks](/docs/finance/events.md) `finance.recon_run.completed`,
`finance.recon_case.opened` and `finance.recon_case.recovered` go out once each, after the change is saved.

## For agents {#agents}

| Tool | Scope | What it does |
|---|---|---|
| `finance_reconrun_start` | `finance:write` | Start a run (`ruleset_id`, `period_from`, `period_to`, `tolerance_minor`); it takes its first step at once |
| `finance_reconrun_get` | `finance:read` | One run: status, phase, counts, totals per source, failure |
| `finance_reconrun_list` | `finance:read` | Runs, newest first, by `entity_id`, `ruleset_id` or `status` |
| `finance_reconmatch_list` | `finance:read` | Matches by `run_id`, `entity_id`, `status` or `record_id` |
| `finance_reconmatch_create` | `finance:write` | Match records by hand (`left_ids`, `right_ids`, `reason`), or `suggest` one with a `confidence` |
| `finance_reconmatch_confirm` | `finance:write` | Confirm a suggestion, or a rule's match |
| `finance_reconmatch_undo` | `finance:write` | Undo a match with a `reason` |
| `finance_reconrecord_exclude` | `finance:write` | Exclude a record with a `reason`, or `include` it again |
| `finance_reconcase_list` | `finance:read` | Cases, open and claimed by default; `status` (or `all`), `kind`, `entity_id`, `run_id`, `source_id`, `counterparty_party_id` |
| `finance_reconcase_get` | `finance:read` | One case with its records, evidence and exception |
| `finance_reconcase_update` | `finance:write` | Move a case (`status`) and set `claim_ref`, `recovered_minor`, `due_back_by`, `assignee`, `note` |

Amounts are whole minor units as text (`"12500"` is 125.00), never floats. REST twins under `/api/v1/finance/recon`:
`GET`/`POST /runs`, `GET /runs/{id}`, `GET`/`POST /matches`, `POST /matches/{id}/confirm`, `POST /matches/{id}/undo`,
`POST /records/{id}/exclude`, `GET /cases`, `GET`/`PATCH /cases/{id}`.
