FAILURE MAP
← Case archive

FA-59922 / Inventory cost layering / Member archive

Moving average perpetual costing: average reset at zero stock · case 02

An issue that empties stock zeroes the average, so the next receipt is costed with a zero-weight but reported avg is wrong in between.

Member previewVariant 2 · 3 implementations · 8 checks per implementation

Case contract

Input {onhand, avg (cents, integer), events}. On receipt the average becomes round-half-up((onhand*avg + qty*cost)/(onhand+qty)) to whole cents; an issue is costed at qty*avg with the current average and never changes it; an issue exceeding on-hand returns "short". When on-hand reaches zero the average is kept as the last value (not reset). Return {cogs, onhand, avg}.

Why this case matters

Inventory valuation and cost-of-goods decisions depend on this rule.

One recorded failure

Sample boundary fixture

This sample comes from the broken implementation of a controlled reproducer.

Boundary fixtureActualExpectedOutcome
issue all{"avg": 0, "cogs": [208], "onhand": 0}{"avg": 26, "cogs": [208], "onhand": 0}Failed

MEMBER ARCHIVE

The complete case is available to members.

This record includes three runnable implementations, regression fixtures, execution results, and source hashes.

Member access is invitation-based. Sign in with your invited account to inspect the sources.

Sign in to the archive ↗