The next number is derived by scanning the most recent PO numbers for the org and incrementing the highest trailing digits, starting at PO-1001. A unique index rejects a duplicate insert if two are allocated at the same moment; the caller retries.
Also called: PO number · purchase order numbering · next PO
- 1nextPoNumber reads the 50 most recent po_number values for the org
- 2The trailing digits are parsed and the maximum incremented
- 3The same logic runs server-side in /api/orders/send
- 4The comment is explicit about the trade-off: 'Race-condition tolerant… For real concurrency a sequence would be better, but for typical solo/small-team usage this is fine.'
A PO number is what a supplier quotes back on their invoice and their delivery note. It has to be predictable, per-business, and never silently duplicated — hence the database-level backstop rather than trusting the read.
- Hand-typed PO numbers repeat
- Numbers shared across businesses collide
See it on your own jobs
Twenty minutes, your numbers, no slide deck. We’ll build one of your real buildings in front of you and send you the estimate link at the end — yours to keep either way.
or keep browsing features →