Payment Matching

Each bank transaction matched to the open invoice it pays. A payment that quotes an open invoice's reference is matched by plain lookup; the rest go to _predict of invoice_id across the link from bank transactions to invoices, with $why showing which name, description, and amount tokens carried the match.

Payment Matching: screenshot from the Accounting demo
🧾 Accounting_predict_searchAccounting
In the demoIn the accounting demo, payments that quote no reference come first and are matched with _predict and $why; the badge shows Aito's $p, the number the explanation adds up to, while an amount check helps decide what is matched or only suggested. Payments that quote a reference are matched by lookup, without Aito.

The problem

Bank reconciliation is matching free text to records. The payer writes the reference wrong, abbreviates the company name, pays two invoices at once, or pays a slightly different amount. Exact-match rules clear the easy lines and leave the rest to a person.

How it works

A payment that quotes the reference of an open invoice is a lookup, and the demo matches it without Aito. For the rest, the bank transaction's description, amount, and payer name go into the where clause, and _predict of invoice_id follows the schema link to the invoices table, limited to the open ledger. The candidates come back ranked, and $why highlights the tokens that carried the match: a company name, a word in the description, the amount.

The badge on each match shows Aito's $p, the number its explanation multiplies out to. The demo then weighs that probability against a plain amount check to decide what to auto-match, suggest, or leave unmatched. Only the confident matches post without review.

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application. For the whole picture, see predictive accounting.

See it live

This use case runs in the 🧾 Accounting demo today. Click through to the live application and inspect the queries that produce the result.

Open the live demo →

Build it with Claude Code

Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.

Payment matching: a prompt for Claude Code
Add payment matching to this codebase using Aito, a predictive database. The feature: match each incoming bank payment to the open invoice it pays, with a confidence.

1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code).
2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query.
3. Read the use-case guide: https://aito.ai/use-cases/payment-matching/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-accounting-demo/blob/main/src/matching_service.py and https://github.com/AitoDotAI/aito-accounting-demo/blob/main/src/data_loader_v2.py
5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample.
6. Measure before wiring the UI: hold out recent rows, run the predictions, and report accuracy against the current behaviour.
7. In the UI, show the confidence ($p) and the reasons ($why). Fill in automatically only above a threshold I choose; below it, suggest.

Ask me before changing anything outside the new feature.