Function: quoteBooking()
function quoteBooking(input: QuoteBookingInput, deps: QuoteBookingDeps): Promise<BookingQuote | null>;Defined in: server/bookings/pricing-glue.ts:347
Quote the amount owed for a booking at terms-pin (§8.3).
Pipeline:
- If
deps.payments.quoteAmountis present, delegate entirely to it (the external payment module overrides). This call is the deliberate exception to "ports are never awaited inside the transition tx" — see the note on PaymentPort. - Otherwise, load active
pricingdomain rules + conditions throughBookingRepositories.rules/.ruleConditions(same Prisma client as the enclosing transaction — avoids the ambient-binding problem). - Run the engine KERNEL (
matchRulesAgainstTables) → partition → qualify → calculate, scoping via the merged mapping filtered by the pinned policy bag'spricingScopesselector (see below). - If no base-price rule matched, return
null(no pricing configured for this org/type — caller leavesamountOwedCentsnull). Likewise returnnullwhen the booking has NO schedule and the matched base rule's unit is time-shaped (hour/day/night) — a time-priced booking cannot be quoted without a duration. - Otherwise snapshot
amountOwedCents = calculation.order.total_centsandcurrency = "USD"(hard-coded for v1; multi-currency is a future extension point).
pricingScopes interpretation. The policy bag carries
pricingScopes: string[], but the engine wants a Record<scope_type, path> — the plan's literal scopes: policy.pricingScopes is
type-impossible. We read the field as a scope-key SELECTOR: when
non-empty, the merged scope mapping is filtered to those keys (rules
scoped on any other type can no longer resolve a context value, so they
never match this type's bookings); when empty/absent, the full merged
mapping applies.
The caller is responsible for writing the returned quote into the
booking row via repos.bookings.updateIfVersion (or the create data)
inside the same transaction.
Parameters
| Parameter | Type |
|---|---|
input | QuoteBookingInput |
deps | QuoteBookingDeps |
Returns
Promise<BookingQuote | null>