function finalizeSessionIfUnresolved
finalizeSessionIfUnresolved(
sessionId: string,
attendeeId: number,
paymentReference?: string,
): Promise<void>

Heal a still-unresolved reservation by stamping attendee_id, leaving ticket_tokens untouched. The ledger-replay path uses this: when a late delivery finds the booking already recorded in the ledger, it points its fresh reservation row at the existing attendee so the next delivery takes the fast already-processed path — but ONLY while the row is unresolved, so it never overwrites the attendee_id or blanks the ticket_tokens a racing delivery may have just finalized and stored. Guarded on UNRESOLVED_RESERVATION (the first outcome wins), and a no-op if the row was pruned away.

When the replayed session carries a provider paymentReference, it is stored too, so a replay that recreated the idempotency row (after a prune) restores the refundable charge reference rather than leaving it empty — the only refundable id for a provider-less/admin-added attendee's balance charge.

Parameters

sessionId: string
attendeeId: number
optional
paymentReference: string =

Return Type

Promise<void>

Usage

import { finalizeSessionIfUnresolved } from "docs/database.ts";