fix(machine): decrement cassettes by position, not denomination, on cash-out #75
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/cassette-decrement-by-position"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
recordTransaction()inapps/machine/electron/state-store.tsdecremented cassette inventory withbut the v9 migration made
positionthe PK precisely so duplicate denominations across bays are legal (applyOperatorCassettesConfigdocuments this explicitly, and the HAL dispense path builds per-position results with position as the authoritative field). On any machine with two bays of the same denomination — a dual-$20 layout, tejo/batm3 multi-bay configs — a single dispense decremented every matching bay row, silently corrupting:The correct helper
updateCassetteCountByPosition()already existed but had no callers — an unfinished refactor from the v9 cutover.Fix
c.position.Tests
New
state-store-transactions.test.ts(in-memory DB, same pattern as the fees/bunker tests) with a duplicate-denomination layout (2× $20 bays + 1× $50):MAX(0, …)floor holds3 of the 5 tests fail against the old code; all 43 machine-app tests +
vue-tscpass with the fix.Out of scope (noted during review)
manual_dispensetransactions never decrement DB cassette counts at all (the decrement branch iscash_out-only) while HAL decrements its in-memory bays — DB inventory overstates after an operator remediation dispense until cassettes are re-set. Separate issue to follow.🤖 Generated with Claude Code