← SIMRANJAISWAL.INTHE ENGINE ROOM · 01 · RECONCILIATION

Three ledgers, one truth

Orders in one system, deliveries in another, invoices in a third, money in the bank feed — and nobody whose job it is to make the four agree. This engine does that job every morning: three matching tiers with printed tolerances, an exception queue with a cause on every line, and a tie-out that refuses to publish if the columns don't add up. It is running below, in your browser, on a 1,200-order book you can make as messy as you like.

◆ LIVE ENGINE · RUNS IN YOUR BROWSER · PYTHON REFERENCE PUBLIC
0ORDERS IN THE REFERENCE BOOK · 60 CUSTOMERS · 180 DAYS
0EXACT KEY → AMOUNT + WINDOW → PART-PAYMENT
0MONEY THE LEDGER WAS LOSING · REFERENCE RUN · ₹ LAKH
0EXCEPTIONS, EACH WITH A CAUSE AND AN AGE
01 · THE JOB

In the collections case, the leak was the ledger: deliveries that were never invoiced, invoices whose dates fell off a spreadsheet, payments applied by memory. The fix was not a person checking harder. It was a machine that checks the same way every day.

Every company that ships before it bills has four records of the same event and no single one of them is true. The order says what was promised; the delivery note says what left; the invoice says what was asked for; the bank says what came. Where they disagree, money sits: a delivery nobody billed is revenue that will never be chased, a duplicate invoice is a customer who will pay once and dispute the rest, a short payment with no credit note is a deduction nobody approved. In case 01 that gap was worth more than any late payer. The Reconciliation Engine is what closes it — TRACE and SEAL of the Leak Ledger, written down as rules and run on a schedule.

02 ·THE ENGINEFOUR LEDGERS, THREE TIERS, ONE QUEUE
THE MORNING RUN · EACH INVOICE LOOKS FOR ITS DELIVERY BY EXACT KEY, THEN BY AMOUNT + DATE WINDOW · EACH PAYMENT LOOKS FOR ITS INVOICE BY REFERENCE, THEN BY AMOUNT, THEN AS A PART-PAYMENT · WHATEVER IS LEFT BECOMES AN EXCEPTION WITH A CAUSE.

The engine is deliberately boring: no learning, no fuzzy-string cleverness, no threshold tuned by feel. Each tier is a sentence a finance controller can read and disagree with, and the tolerance is a number printed on the page. That is what makes an exception queue trustworthy: when the engine says a delivery was never billed, the controller can see exactly which rule said so and why the next rule didn't rescue it.

03 ·THE RULESWHAT "MATCHED" MEANS, EXACTLY
STEPRULEWHAT IT CATCHES
T1 · exactInvoice PO reference = order id, delivered, amounts within ₹1The 90% that are simply right. A second invoice claiming an already-claimed delivery becomes DUPLICATE_INVOICE.
T2 · amount + windowSame customer, an unclaimed delivery within the tolerance (default 0.5%), invoiced 0–30 days after delivery; nearest amount winsMistyped references and rounding between systems — matched, and logged so the reference gets fixed upstream.
T3 · nothingNo delivery fitsINVOICE_WITHOUT_DELIVERY — billed something that never left.
DeliveriesDelivered more than 7 days ago and claimed by no invoiceUNINVOICED_DELIVERY — the leak itself.
P1 · referencePayment carries the invoice idApplied directly.
P2 · amountNo reference; an open invoice of the same customer within the toleranceApplied; the closest amount, oldest first on ties.
P3 · part-paymentNo reference; smaller than every open invoice — applied to the smallest open invoice it fits insideInstalments. Anything that fits nowhere is UNMATCHED_PAYMENT.
AftermathPaid but a balance above tolerance remains for 14+ days → SHORT_PAY; unpaid and past terms → OVERDUE_OPENDeductions nobody approved; money to chase (the input to the chase list).
# tier 2 — the sentence a controller can disagree with (engine.py)
for d in deliveries:
    if d["cust"] != inv["cust"] or d["order"] in claimed: continue
    gap = inv["day"] - d["day"]
    if gap < 0 or gap > 30: continue                     # invoiced 0–30 days after delivery
    diff = abs(inv["amount"] - d["amount"])
    if diff <= max(1, d["amount"] * tol) and (best is None or diff < best[0]):
        best = (diff, d)                                # nearest amount within tolerance wins
04 ·RUN ITTHE ENGINE, LIVE, ON A BOOK YOU CONTROL
SEED
A 1,200-ORDER BOOK IS GENERATED FROM THE PRINTED RULES AND RECONCILED IN YOUR BROWSER. NOTHING LEAVES THIS PAGE.
MONEY THE LEDGER WAS LOSING

Run the morning to see what the engine finds.

THE MATCH LADDER

Two things to try. Drag "never invoiced" to zero and the money found collapses to short-pays and duplicates — most of what a ledger loses is simply work that was never billed. Then widen the tolerance to 2%: T2 rescues more mistyped references, but watch the short-pay count fall too — a wide tolerance quietly forgives small deductions, which is exactly how a 2% "rounding" leak becomes policy. The tolerance is a business decision, so it is a slider, not a constant.

05 ·WHAT IT FINDSTHE REFERENCE RUN · SEED 42

Exceptions by cause

COUNT · VALUE IN ₹ LAKH

How old the found money is

UNINVOICED + DUPLICATES + SHORT-PAYS, BY DAYS SINCE THE EVENT

Who the exceptions belong to

The queue, top of the pile

06 ·WATCHHOW IT RUNS WHEN NOBODY IS LOOKING
WHENWHAT HAPPENSWHO SEES IT
06:00 dailyPull the four ledgers as of midnight; refuse to run if any extract is older than 26 hours or its row count moved more than 20% day-on-day.A failed run pages the owner; a stale source never becomes a wrong queue.
06:04Match, then tie out: deliveries = claimed + uninvoiced + too-recent; invoices = T1 + T2 + duplicates + unmatched. Any gap → no publish.The controller. A tie-out failure is the engine finding a bug in itself.
06:05Publish the queue: one row per exception, cause, value, age, owner; new since yesterday on top.Finance works the queue; sales sees uninvoiced deliveries in their own list.
WeeklyTwo numbers on one chart: money found this week, money still open by age. Tolerance and rules reviewed only when that chart moves.Leadership — the WATCH stage of the Leak Ledger.
07 · THE TAKEAWAY

Reconciliation is not an audit; it is a morning. The value is not in finding the ₹61 lakh once — it is in the queue being empty by Friday and staying that way, because the same rules ran again on Monday. Make the rules readable, make the tolerance a decision, make the tie-out refuse to lie, and the ledger stops being the leak.

THE BOOK IS SYNTHETIC AND GENERATED FROM THE RULES PRINTED IN engine.py (SEED 42; RATES AS SHOWN ON THE SLIDERS). NO CLIENT DATA. THE ENGINE LOGIC IS THE REAL SHAPE OF THE RECONCILIATION SIMRAN RAN ON A PROCUREMENT STARTUP'S ZOHO + MYSQL LEDGERS AND OF THE TIE-OUT DISCIPLINE FROM THE ARREARS WORK; OUTCOME FIGURES IN THOSE CASES ARE AS REPORTED THERE. THE BROWSER ENGINE IS A LINE-FOR-LINE PORT OF THE PYTHON AND REPRODUCES results.json EXACTLY ON THE REFERENCE SETTINGS — THE STATUS LINE ABOVE SAYS SO WHEN IT DOES.

Four systems that don't agree? A reconciliation engine is a two-to-four-week SEAL: your ledgers, your tolerances, your queue — running every morning with a tie-out that refuses to publish a wrong number.

Start with a TRACE → engine.py README results.json The case it came from →