Task #735: booking reference digits-only (no letters)

- makeBookingReference in artifacts/api-server/src/routes/protocol.ts now
  returns `${year}-${pad4(id)}` instead of `RB-${year}-${pad4(id)}`.
- Backfilled 7 existing dev DB rows: stripped "RB-" prefix via
  regexp_replace; verified 0 rows contain letters, unique/NOT NULL intact.
- lib/db/scripts/pre-push-cleanup.ts updated (architect-review finding):
  NULL backfill now uses digits-only format, plus a new idempotent
  normalization step that strips legacy "RB-" prefixes on every push.
- Frontend unchanged: bookingNumber() already strips non-digits; details
  card and public booking success page display the raw reference which is
  now digits-only. ilike search still works.
- tsc clean for tx-os and lib/db; API workflow restarted.
This commit is contained in:
Replit Agent
2026-07-09 09:17:43 +00:00
parent 1d2ff5e6b9
commit 86b2d64f5c
2 changed files with 18 additions and 6 deletions
+3 -3
View File
@@ -442,10 +442,10 @@ async function lockRoomRow(
}
// Build a human-friendly booking reference (رقم الحجز) from a row id and its
// creation date, e.g. "RB-2026-0042". Deterministic + unique because the id
// is unique.
// creation date, e.g. "2026-0042". Digits only (no letters, per user
// request). Deterministic + unique because the id is unique.
function makeBookingReference(id: number, when: Date): string {
return `RB-${when.getFullYear()}-${String(id).padStart(4, "0")}`;
return `${when.getFullYear()}-${String(id).padStart(4, "0")}`;
}
// Reserve the next booking id from the table's serial sequence so we can