FAILURE MAP
← Case archive

FA-60307 / Inventory cost layering / Member archive

Periodic weighted average with vendor returns: COGS rounding leak · case 02

Ending inventory plus COGS no longer equals goods available by a cent.

Member previewVariant 2 · 3 implementations · 8 checks per implementation

Case contract

Input {begin:[qty,value], purchases:[[qty,value]], vendor_returns:[[purchase_index,qty]], ending_qty}. Each vendor return removes qty units and floor(value*qty/purchase_qty) value of that purchase. The pool is beginning plus purchases less returns; ending value = round-half-up(ending_qty*pool value/pool units); COGS = pool value - ending value. ending_qty outside [0, pool units] returns {"error"}. Return {units, pool, ending_value, cogs}.

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
half cent both ways{"cogs": 3, "ending_value": 3, "pool": 5, "units": 2}{"cogs": 2, "ending_value": 3, "pool": 5, "units": 2}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 ↗