Both reports below were generated at 06:35 UTC on November 9. One says Alder Design Co. owes $1,000. The other says $600. Look just under the company name and you’ll see what changed.
In this demo, invoice AR-1001 was issued September 1 for $1,000, due September 30. The customer paid $400 against it on October 1. Here’s the September 30 report. The full $1,000 is in Current / Not Due. An invoice due today is still current.
Move the cutoff forward one day. Now the $400 counts, and the remaining $600 is one day past due. You can see it move one column to the right.
What if someone enters the payment two days late?
Change one fact for a separate test. Suppose the customer actually paid on September 30, but nobody entered the payment until October 2. If you sent a report on September 30, it would have shown $1,000. Rerun September on October 2, including the newly recorded payment, and you get $600. The invoice is still current in that rerun. Its due date hasn’t moved.
Now “give me September’s balance” has two possible answers. The customer asking for a corrected statement wants $600. The coworker asking what you sent last week wants $1,000.
Put both dates in the test
The function below takes two arguments. as_of is the financial cutoff. known_on is the last day of entries available to that run. This small example uses whole days and one invoice, so each payment in the list is already matched to it. Save it as aging_replay.py and run python3 aging_replay.py.
from datetime import date from typing import NamedTuple sep30 = date(2026, 9, 30) oct1 = date(2026, 10, 1) oct2 = date(2026, 10, 2) class Payment(NamedTuple): effective_on: date recorded_on: date cents: int def aging_row(payments, *, as_of, known_on): # One USD invoice, due Sep 30. Each payment is applied to it. paid = sum( p.cents for p in payments if p.effective_on <= as_of and p.recorded_on <= known_on ) return 100_000 - paid, max(0, (as_of - sep30).days) # Result: (open cents, days past due) october_payment = [Payment(oct1, oct1, 40_000)] assert aging_row(october_payment, as_of=sep30, known_on=sep30) == (100_000, 0) assert aging_row(october_payment, as_of=sep30, known_on=oct2) == (100_000, 0) assert aging_row(october_payment, as_of=oct1, known_on=oct1) == (60_000, 1) # A different history: the Sep 30 payment was first entered on Oct 2. late_entry = [Payment(sep30, oct2, 40_000)] assert aging_row(late_entry, as_of=sep30, known_on=sep30) == (100_000, 0) assert aging_row(late_entry, as_of=sep30, known_on=oct2) == (60_000, 0) print("All five cutoff checks passed.") Try removing the recorded_on check. The first three assertions still pass. The fourth fails because it now deducts a payment nobody had entered when the September report went out. Change the financial cutoff from <= to < and the third assertion fails instead. October 1 is the day the $400 should count.
If your database only keeps the latest balance, an older cutoff won’t tell you what someone saw on screen. Keeping the export answers “what did we send?” If you need to reconstruct it from data, preserve when each entry or correction became known, including previous versions when entries can be edited.
ChatGPT wrote this article and the Python example. All five assertions were run on CPython 3.14.4. The screenshots are from our Bokeping demo company.
The Excel workbook with this invoice and payment (.xlsx) reproduces the two screenshots. In Aging!B4, switch September 30 to October 1. The separate late-entry test above runs in Python.






