One statement, four payouts, four lots of commission
A monthly delivery statement was billed in every weekly payout it touched. The fix put it in one week, then showed the hole that opens when it arrives late.
A food hall that pays its kitchens weekly has a problem the kitchens never see: the delivery platforms report monthly. A statement arrives covering the whole of September, and the hall has to decide which week's payout it belongs to, charge commission on it once, and credit the kitchen for it once.
Our payout run selected statements by overlap. Any statement whose period touched the payout's period was included, in full. A ten thousand pound monthly statement therefore landed in week one, week two, week three and week four. The hall charged four thousand pounds of commission on ten thousand of revenue, and the kitchen was credited the whole month's delivery takings in every weekly payout. Thirty-six thousand paid out on ten thousand taken, and both directions wrong at once.
The dating already knew the answer
When a statement is walked through the commission ladder it is given a date, and that date was already the last second of its period. A statement to the thirtieth of September was being pulled into the week ending the seventh while carrying a timestamp that said otherwise. The selection and the date disagreed, and the selection won.
The rule we settled on was already written down elsewhere in the product, for a different table: a thing belongs to the window its period ends in, and to exactly one. Containment would have fixed the double and opened a gap, because a statement straddling two weeks would then belong to neither. Three places used the same overlap test. Two were this bug. The third checks whether payouts cover a window, where a straddling payout genuinely does cover part of it, so overlap is right there and we left it alone.
The hole the fix opened
End-of-period attribution has no gaps provided the statement exists when the payout is raised. A platform statement is a PDF that arrives afterwards. We drove that case rather than reasoning about it: week one raised and marked paid, then the statement for that same week typed in. Five hundred pounds of commission appeared on the commission screen and in no payout at all. Before the fix that statement would have been billed again every week for ever. After it, nothing billed it and nothing said so.
So the save now answers honestly. The statement is a fact and is recorded, but the response names the payout that already closed its period and says what to do instead, and the statements table marks that row as not billed, recomputed every time it is drawn, because whether a statement can still be billed changes later when a payout is raised over it. Making a late statement billable needs a decision about where to record which payout consumed it. That is the owner's call, and the screen says so rather than guessing.