# finance.bank-reconcile-match The auto-match step of a bank reconciliation: pair each bank statement line with at most one cash-book entry, and list what is left on each side for a person to deal with. **A pair is a candidate** when the amounts are exactly equal (same currency, same sign, same minor units), the dates are at most `dateWindowDays` apart in either direction, and the references are at least `minSimilarity` alike. **Choosing among candidates** is where reconciliations go wrong, so it is fixed and global rather than first-come-first-served. All candidate pairs are ranked by, in order: 1. higher reference similarity, 2. fewer days apart, 3. earlier bank line (input order), 4. earlier ledger entry (input order), and taken best first, skipping any pair whose bank line or ledger entry is already matched. Two payments of 500.00 on the same day, referenced INV2002 and INV2001, pair with the ledger entries of those references even when the ledger lists them the other way round; matching bank lines in order to the first equal amount would cross them. The same inputs always give the same pairs. **Reference similarity** is a Sørensen-Dice score on character pairs, in basis points: both references are reduced to their ASCII letters and digits in upper case ("INV-1001 Acme" becomes "INV1001ACME"), and the score is twice the number of shared adjacent-character pairs over the total number of pairs, counting repeats, rounded down. Identical non-empty references score 10000; a reference with fewer than two characters after reduction scores 0 against anything else, as does an empty one. "INV1001" against "INV1001ACME" is 7500; against "INV1002" it is 8333. Matches come back in bank-line order, with the day difference (bank date less ledger date; positive when the bank cleared later) and the similarity that justified them. Ids must be unique within each list. One-to-many matches (one deposit paying several invoices) are not attempted; they need a person or a separate rule.