# inventory.valuation-weighted-average
Perpetual weighted average cost (AVCO): every receipt is blended into a running
average, and every issue is costed at the average in force when it happens.
IAS 2 and FRS 102 section 13 allow it alongside FIFO.
**Where the rounding happens.** The ledger keeps the stock's total value in
exact minor units, never an average unit cost. An issue of `q` units from `Q`
on hand worth `V` costs `V x q / Q`, rounded once to minor units by `mode`
(`math.round-div`), and exactly that is taken off the value. So:
- the closing value plus the cost of sales always equals the receipts, to the
penny;
- issuing the last unit takes exactly what is left, so an empty item is worth
exactly zero. The common shortcut of rounding the average to a unit price
and multiplying (546p x 60) drifts, and leaves pence of value on an item
with no stock; one of the vectors shows it.
`averageUnitCost` is the closing value divided by the closing quantity, rounded
by `mode`, for display only; it is not used to cost anything.
Receipts carry a unit cost in `Money`; an issue carries none. An issue larger
than the stock on hand is an error, as are a ledger out of date order, a zero
quantity, a missing or negative receipt cost, an issue with a cost, and a cost
in another currency. Returns are not modelled.
Sources: IAS 2 *Inventories*, paragraph 27 ("the weighted average may be
calculated on a periodic basis, or as each additional shipment is received");
FRS 102 section 13, paragraph 13.18.