Our trading system values stock at weighted average cost. Every time goods are booked in, it adds their cost to the value of what is already on the shelf and divides by the new quantity. It works well as long as stock is booked in before it is sold.
In May one of our branches took a delivery of four hundred sheets of standard plasterboard on a Friday afternoon. The goods in clerk had gone home, so the delivery note went into a tray for Monday. On Saturday a housebuilder's site manager cleared most of it, and the counter sold three hundred and ninety five sheets that the system did not yet know were there. The stock figure went to minus three hundred and ninety five, valued at the old average of five pounds fifty, which is minus two thousand one hundred and seventy two pounds fifty.
On Monday the delivery was booked in at six pounds a sheet. The system added two thousand four hundred pounds to minus two thousand one hundred and seventy two pounds fifty and divided by the five sheets now on hand. That made each one worth forty five pounds fifty.
Two things followed. The weekend's sales had been costed at five pounds fifty instead of six, so the branch's margin looked better than it was. Then the housebuilder's contract priced plasterboard at cost plus twelve percent, so its next order was priced at more than fifty pounds a sheet. Its buyer rang the branch, sure the system had a bug.
It did not. It had done the arithmetic correctly on events recorded in the wrong order. When we looked across the company, more than four hundred products had gone below zero at some point in the previous year, and the average cost of sixty one had moved by more than half in a single day.
Goods in is now booked by scanning the delivery as it comes off the lorry, so stock reaches the system before the counter can sell it. Selling below zero still has to be possible on a busy Saturday, but it now raises an exception for the branch to clear the same day. Any average cost that moves by more than a fifth overnight is held for review before it reaches a customer's price.
An average is only as good as the order in which its inputs arrive. When a calculation depends on sequence, check the sequence as well as the sums.
– Serguey Shinder

