Skip to content
Docs menu

Finance reconciliation rules

How Reconciliation pairs records across sources. The five rule types, how ties are broken, the ruleset JSON, versions, who may read and change rulesets, and the tools.

View .md

Reconciliation takes records from two or more sources that should agree (a bank statement, a payment gateway's settlement report, a travel agency's statement, your property system) and pairs the records that explain each other. A ruleset says how: an ordered list of rules. Each rule pairs records from one source (the left) with records from another (the right). Rules run in order, and each one takes the records it matches, so a later rule only sees what the earlier ones left. Put the strictest rules first.

Rulesets belong to the Reconciliation module (finance.recon). Open them in Finance > Reconciliation (/finance/recon/rulesets). Each ruleset shows its rules in run order, each in a plain sentence, and its earlier versions. Members who run reconciliations can add a ruleset, edit its rules, and archive or restore it.

What a record is

Every source's lines are mapped to the same shape before matching:

Field What it is
date The booking, transaction or statement date
value_date When the money moved, when the source says
amount Signed, in minor units (cents): money in is positive, money out negative
currency ISO 4217. Records in different currencies never match
reference The reference the source gives
counterparty Who the other side is
fields.<name> The source's own fields, such as fields.booking_id or fields.payout_id

A rule names the fields it compares by these names. reference is compared after normalising: upper case, only letters and digits kept, and leading zeros dropped from every run of digits, so INV-000123, inv 123 and INV000123/ are all INV123. counterparty ignores case and extra spaces.

The rule types

Every rule has a key (lower-case letters, digits and _, unique in the ruleset), a type, a left and a right source, an optional label, and sign: same (the default) when the left amount equals the right one, opposite when it equals the right amount negated (a ledger credit against a bank credit).

Amounts in rules are whole minor units. Percentages are basis points: 100 is 1%, 1500 is 15%. Where a rule takes a tolerance, the difference allowed is the larger of amount_minor and amount_bp of the left amount.

Type Pairs Settings
exact One left with one right whose fields in on are all equal on: the fields, for example ["fields.booking_id", "amount"]
tolerance One left with the closest right on the same on fields, the amount within the tolerance and the dates at most days apart (default 0) on (may be empty: the currency only), amount_minor, amount_bp, days
reference One left with the right whose normalised reference is the same (match: "equal"), or appears in the other's text as a word ("contains", the default) match, left_field and right_field (default reference), optional amount_minor, amount_bp, days
grouped One left (a payout) with all right records (its bookings) that share a value of group_by, named in the left's link field. The expected payout is their sum less less_bp of it and less_fixed_minor per record group_by, link (default reference), link_match (equal or contains), less_bp, less_fixed_minor, amount_minor, amount_bp, days
grouped with group_left_by Many to many: left records grouped by group_left_by with right records grouped by group_by that have the same value group_by, group_left_by, less_bp, less_fixed_minor, amount_minor, amount_bp, days
windowed_sum One left (a bank line that bundles several settlements) with a set of right records dated from days_before before to days_after after it whose sum equals it within the tolerance on, days_before (default 3), days_after (default 0), max_candidates (at most 12, the default), max_steps (default 5,000), min_items (default 1), amount_minor, amount_bp

A contains match looks for whole words of at least 4 characters that hold a digit. A bank line reading TRF PAYOUT REF 000987654 STRIPE contains 987654; a two-character reference never pairs anything. A word is also split where letters meet digits, so PAYOUT123456 contains 123456.

When a contract is on file for the counterparty (a later release), the grouped rule's expected amount comes from the contract instead of less_bp and less_fixed_minor.

Commission is rounded half to even to the minor unit, as everywhere in Finance. All arithmetic is exact: no amount ever goes through a floating-point number.

Ties

The same records and rules always give the same matches, whatever order the records arrive in. Every source is first sorted by date and then id, and the left records are taken in that order. When several right records would do:

Type Chosen
exact The earliest left takes the earliest right with the same key (by date, then id)
tolerance The smallest difference, then the fewest days apart, then the earliest date, then the smallest id
reference An equal reference before a contained one, then the smallest difference, the fewest days apart, the earliest date, the smallest id
grouped A group named exactly before one found in the text, then the smallest difference, then the group's value. A group is matched once, whole
windowed_sum The smallest set first; among sets of the same size, the smallest difference, then the first set in nearest-first order

Limits

Matching uses keyed lookups, never a comparison of every record with every other, so 200,000 records match in seconds. Two bounds keep a single record from slowing a run:

  • tolerance and reference look at no more than 256 candidates for one left record.
  • windowed_sum searches only the max_candidates nearest records in the window (at most 12) and tries at most max_steps sets. With 12 candidates every set fits in the default 5,000 steps. When the step limit stops the search, or no set fitted and the window held more records than it could search, the run lists that record as given up (step_cap or too_many_candidates), so a person can match it by hand.

A ruleset has at most 50 rules and 20 sources.

What a match says

Every match carries the rule's key and type, its kind (one_to_one, one_to_many or many_to_many), the record ids on each side, the left sum, the right sum, the expected left amount, the difference (left less expected, zero for a clean match) and a confidence from 0 to 100, with a sentence and the facts behind it (the references compared, the commission taken, the days apart). Records no rule took are the leftovers, listed per source.

Type Confidence
exact 100, or 90 when the amount was not in the key and differs
tolerance 95, less 10 when the amounts differ, less 2 a day apart (at most 20)
reference 95 equal, 80 contained, less 10 when the amounts differ
grouped 95 named exactly, 85 found in the text, 85 many to many; less 10 when there is a difference
windowed_sum 75, 65 with a difference, less 5 when the window held more records than were searched

The ruleset JSON

{
  "entity_id": "0193…",
  "name": "Agency payouts",
  "sources": ["agency", "pms", "bank"],
  "rules": [
    { "key": "by_booking", "type": "exact", "left": "agency", "right": "pms", "on": ["fields.booking_id", "amount"] },
    { "key": "near_booking", "type": "tolerance", "left": "agency", "right": "pms", "on": ["fields.booking_id"], "amount_minor": 100, "days": 2 },
    { "key": "payout", "type": "grouped", "left": "bank", "right": "agency", "group_by": "fields.payout_id", "link_match": "contains", "less_bp": 1500, "amount_minor": 50 },
    { "key": "settlements", "type": "windowed_sum", "left": "bank", "right": "agency", "days_before": 3, "min_items": 2 }
  ]
}

sources lists the source ids (or a pack's source keys) the rules may name; leave it empty to let them name any. Rules are checked when saved: an unknown setting, a fraction where a whole number belongs, a repeated key or a source not in the list is refused, with every problem named.

Versions

Every save that changes a ruleset's name, sources or rules makes the next version; the earlier ones are kept and can be read. A reconciliation run records the version it ran with, so its matches can always be explained by the rules that made them. Saving with expect_version refuses the save when someone else saved a newer version first. Saving the same content again changes nothing. Archiving hides a ruleset and frees its name; restoring brings it back at the same version.

Who may read and change rulesets

Action Roles
Read rulesets (recon.read) controller, recon clerk, auditor
Add and change rulesets (recon.run) controller, recon clerk

Both on the ruleset's entity; a ruleset on an entity you cannot see answers as if it did not exist. See Finance roles. Every change is recorded on the event chain as finance.recon_ruleset.created, .updated, .archived or .restored. An organisation without Reconciliation gets 403 product_not_enabled naming finance.recon.

For agents

Tool Scope What it does
finance_reconruleset_list finance:read The rulesets you may read, with entity, name, sources, version and rule count. archived includes archived ones
finance_reconruleset_get finance:read One ruleset: its rules in order, each with a plain-English description, and its versions. version reads an earlier one
finance_reconruleset_create finance:write A new ruleset on an entity, at version 1
finance_reconruleset_update finance:write The next version (name, sources, rules), or archived true or false; expect_version guards against a stale save

REST twins: GET and POST /api/v1/finance/recon/rulesets, GET and PATCH /api/v1/finance/recon/rulesets/{id} (GET …?version=2 for an earlier version).