Gapless, immutable invoice numbers
The problemInvoice numbering is a legal and accounting requirement: no gaps, no reuse, and no editing a number once it's issued — even under concurrent requests.
How I solved itA per-year sequence (AD-2026-0001…) allocated atomically in Postgres, so two invoices can never collide. Issued invoices are immutable — you void, never delete — so the financial record stays trustworthy.