The fix that moved the gap instead of closing it
We fixed one of two places a refund figure was built, and for a release the receipt greyed out a refund the server would allow. The sweep is now a test.
Yesterday’s post told the story of a refund that stranded money: refund a discounted dish and the till refused to return the rest of the bill, short by exactly the discount. We found it, fixed it, proved the fix bit, and shipped. This is the story of what the fix did for the next release.
Two places built the same number
The figure in question is how much of a receipt can still be refunded. The refund route builds it to decide whether to allow a refund. The order document builds it too, and the receipt sheet on the till reads that one to grey out its button. Both were fed the gross line prices while refunds hand back the net. We fixed the refund route. We did not look for the second.
For one release the two disagreed in the worst direction. On a thirteen pound bill with a discounted eight pound line already refunded, the receipt sheet said three pounds were left and greyed out anything more. The server would have allowed five. Before the fix both said three and the customer was two pounds short. After it the counter could not even try. A fix applied to one of two places does not close a bug, it moves it.
The lesson in both directions
We already had a rule that a revert matching a shared piece of text hits the wrong thing, so revert by line. The same rule applies on the way in: a fix to a shared expression needs a sweep for every other place that expression appears. One search finds all three callers. It would have taken a second and turned a half-landed fix into a whole one. It is now a test, which counts the callers so a fourth has to be deliberate. The third caller is the till’s own floor for when the field is missing, which passes no line amounts and cannot carry this mistake.
What the test pins
Not either number. The agreement. Whatever the order document says is left, a refund of exactly that must succeed and a penny more must not. That property survives whichever of the two is edited next, and it is what a counter depends on: either figure alone could be wrong in the same direction and still agree with itself. It is driven on three shapes of bill: a deal discount, a discount spread across three kinds of discount at once so a fix that remembered only one is caught, and nothing discounted at all. Reverting fails the first two by name. The undiscounted bill passes either way, which is exactly what makes it a control.