feat(api): invoice, check-in and itinerary number sequences (#25) #93
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/kws!93
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/25-number-sequences"
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?
Closes #25. Implements R-TOUR-1 for all three counters. Nothing calls it yet; #26 will.
What
number_sequences, one row per (kind, year), unique on that pair.internal/numbering: the legacy formats (invoiceYY+ 8 digits, check-inC+YY+ 8 digits, itineraryI+YY+ 8 digits), the Kenya-time year,ErrUnknownKind,ErrYearOutOfRange(2000-2099).numbering/pgstore:Next(ctx, kind, now)takes a number with one atomicINSERT ... ON CONFLICT DO UPDATE ... RETURNINGin its own short transaction. Concurrent callers on any node never get the same number. A number is skipped if the sale that asked for it rolls back (gaps are allowed).Decisions (agreed on the issue)
Checks
make lint: 0 issues.make contract: pass.make cover: total 94.4% (minimum 80%);numbering100%,numbering/pgstore91.7%.Review
Dual pass per the review rule. Ponytail: no Must fix (two Should-fix items applied). Independent reviewer: "with fixes", nothing Critical; the year-range guard and a doc line were applied.
Follow-ups (not in this PR)
Nextbefore opening the sale transaction (it needs its own pool connection), and add a unique index on the invoice number column. A sequential number must never be used as an access token for public lookup.🤖 Generated with Claude Code