fix(goods): lock voucher before posting (H34) #52

Merged
morrning merged 1 commit from Seyyed/Seyyed_arc:codex/team-base-13-h34-goods-post-idempotency into master 2026-11-12 16:54:53 +03:30
Contributor

H34

Lock the goods expense/income voucher and refresh its current state before the existing status check, in the transaction that posts the warehouse movement and GL. Repeated requests retain the existing INVALID_STATUS (400) response.

On team base 2354c27d50, an expired database snapshot held in a live ORM identity map allowed a second posting. Starting from 10 units with a 2-unit voucher at cost 200, the stale request produced stock of 6 for expense and 14 for income, with two warehouse vouchers and two balanced GL documents of 400 each. After the fix, stock is 8 or 12 and each voucher has a single warehouse movement and a single balanced GL document of 400.

Verification

  • 32 selected pytest cases passed, including the goods service/hardening tests, stale and fresh repeats, rollback after a forced GL failure, retry, and warehouse regressions.
  • PostgreSQL 16.15, READ COMMITTED, isolated dbtest schema. Two independent connections posted the same expense voucher. pg_blocking_pids confirmed that the second waited for the first. After commit it received INVALID_STATUS (400), with stock 8 and one warehouse and GL document.
  • Tests call the service directly. HTTP transport and the complete CI suite were outside the executed coverage.
## H34 Lock the goods expense/income voucher and refresh its current state before the existing status check, in the transaction that posts the warehouse movement and GL. Repeated requests retain the existing INVALID_STATUS (400) response. On team base 2354c27d50cc1b0561c822be51024f43a312fba3, an expired database snapshot held in a live ORM identity map allowed a second posting. Starting from 10 units with a 2-unit voucher at cost 200, the stale request produced stock of 6 for expense and 14 for income, with two warehouse vouchers and two balanced GL documents of 400 each. After the fix, stock is 8 or 12 and each voucher has a single warehouse movement and a single balanced GL document of 400. ## Verification - 32 selected pytest cases passed, including the goods service/hardening tests, stale and fresh repeats, rollback after a forced GL failure, retry, and warehouse regressions. - PostgreSQL 16.15, READ COMMITTED, isolated dbtest schema. Two independent connections posted the same expense voucher. pg_blocking_pids confirmed that the second waited for the first. After commit it received INVALID_STATUS (400), with stock 8 and one warehouse and GL document. - Tests call the service directly. HTTP transport and the complete CI suite were outside the executed coverage.
morrning merged commit 74fbf8cf58 into master 2026-11-12 16:54:53 +03:30
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hesabix/arc!52
No description provided.