Project: ledger-api · Branch: feat/invoice-numbers · Mode: default · Model: gpt-5-codex
Summary
Gap-free invoice numbers per legal entity and year, allocated from a Postgres row lock instead of a sequence, because sequences can skip numbers on rollback.
Conversation
Turn 1 — User
Accounting needs invoice numbers without gaps.
Turn 1 — Assistant
Postgres sequences are not gap-free. Use a numbering table per entity and year, SELECT … FOR UPDATE inside the invoice transaction.
Tools used in this turn:
Write: ledger/numbering.pyWrite: migrations/versions/0007_numbering.pyBash: pytest tests/test_numbering.py -q — 5 passed
Connections
- [[ledger-api]]
- [[PostgreSQL]]
- [[RowLocks]]