Skip to content

Build booking rows consistently for paid and free orders - #1904

Merged
stefan-burke merged 7 commits into
mainfrom
split/canonical-booking-lines
Jul 25, 2026
Merged

Build booking rows consistently for paid and free orders#1904
stefan-burke merged 7 commits into
mainfrom
split/canonical-booking-lines

Conversation

@stefan-burke

@stefan-burke stefan-burke commented Jul 23, 2026

Copy link
Copy Markdown
Member

What changed

  • Build paid and free checkout booking rows through one shared path.
  • Keep item order, quantities, prices, dates, package paths, and parent allocations unchanged.
  • Stop before writing when a required listing or paid amount is missing.
  • Add direct tests for checkout results and the surrounding paid and free flows.

Why

Paid and free checkout completion built the same booking data separately. One shared path prevents those results from drifting and makes incomplete checkout data fail clearly.

Checks

  • nix develop -c deno task precommit
  • 100% mutation score for all changed source files

Summary by CodeRabbit

  • Bug Fixes
    • Improved payment booking creation to keep listing identity aligned and correctly stamp package/child booking details.
    • Enhanced post-payment error formatting (including better handling of capacity/package-name scenarios).
    • Hardened booking-line preparation to fail fast when required paid amounts or listings are missing.
    • Improved free-reservation completion to use consistent booking-line building and one-day defaults.
  • Tests
    • Expanded booking-line, payment-processing, ticket checkout/context, free reservations, packages, and booking-date field coverage.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bf8abc84-7e13-41f3-80bc-ce6d86e2326e

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd7609 and 2e47430.

📒 Files selected for processing (1)
  • scripts/mutation/equivalent-mutants.txt

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The shared booking-line API now separates checkout-line construction from order-booking generation. Paid payment processing and free reservations use ID-based listing alignment, stricter lookup validation, and revised capacity errors. Tests cover booking allocation, checkout flows, ticket context, package terms, and payment outcomes.

Changes

Checkout booking flow

Layer / File(s) Summary
Shared booking-line builders
src/shared/booking-lines.ts, test/shared/booking-lines.test.ts, test/shared/booking-date-fields.test.ts, scripts/mutation/equivalent-mutants.txt
Introduces checkoutBookingLines and bookingsForOrder, validates listing and paid-amount lookups, preserves zero prices, expands allocations, applies package stamping, and updates equivalent-mutant entries.
Payment and free-reservation integration
src/features/api/payment-processing/create.ts, src/features/public/ticket-payment.ts, test/features/api/payment-processing/create.test.ts, test/features/public/ticket-payment/free-reservation.test.ts
Uses the new booking pipeline for paid and free flows, pairs listings by ID, simplifies capacity formatting, and validates payment and reservation outcomes.
Public ticket-payment validation and coverage
test/features/public/ticket-payment/checkout.test.ts, test/features/public/ticket-payment/context.test.ts, test/features/public/ticket-payment/packages.test.ts, scripts/mutation/equivalent-mutants.txt
Adds coverage for checkout-provider outcomes, availability defaults, holiday and package context branches, package terms, and ticket-payment equivalence sites.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PaymentOrReservationFlow
  participant checkoutBookingLines
  participant bookingsForOrder
  participant attendeesApi.createBookingAtomic
  PaymentOrReservationFlow->>checkoutBookingLines: build lines from checkout items, listings, and paid amounts
  checkoutBookingLines-->>PaymentOrReservationFlow: return validated booking lines
  PaymentOrReservationFlow->>bookingsForOrder: apply order date, duration, and allocations
  bookingsForOrder-->>PaymentOrReservationFlow: return booking rows
  PaymentOrReservationFlow->>attendeesApi.createBookingAtomic: submit booking rows
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: shared booking-row construction for paid and free orders.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split/canonical-booking-lines
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch split/canonical-booking-lines

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/api/payment-processing/create.ts`:
- Around line 330-335: Update the paid-path failure handling in the result
success check to guard package orders before passing a listing name to
formatPostPaymentError. Reuse the free path’s package-detection logic and
provide the established generic message for package orders, while preserving the
named-listing message for non-package orders.

In `@src/shared/booking-lines.ts`:
- Around line 40-52: Rename the nullable helper paidAmountFor to
paidAmountForOrNull and update every call site and reference accordingly,
preserving its existing number-or-undefined behavior and error handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d72d0e0f-e1ea-412b-a154-d97b5a640560

📥 Commits

Reviewing files that changed from the base of the PR and between 65a176a and 36f669f.

📒 Files selected for processing (11)
  • scripts/mutation/equivalent-mutants.txt
  • src/features/api/payment-processing/create.ts
  • src/features/public/ticket-payment.ts
  • src/shared/booking-lines.ts
  • test/features/api/payment-processing/create.test.ts
  • test/features/public/ticket-payment.test.ts
  • test/features/public/ticket-payment/checkout.test.ts
  • test/features/public/ticket-payment/context.test.ts
  • test/features/public/ticket-payment/free-reservation.test.ts
  • test/features/public/ticket-payment/packages.test.ts
  • test/shared/booking-lines.test.ts

Comment thread src/features/api/payment-processing/create.ts
Comment thread src/shared/booking-lines.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/api/payment-processing/create.ts`:
- Around line 331-337: Add a concise comment immediately before
validatedItems[0]!.name documenting that every capacity result includes at least
one validated item with a listing, making the non-null assertion a guaranteed
invariant. Keep the existing package redaction logic and errorName calculation
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5762e023-b20b-4c99-85a3-ea090e6c28eb

📥 Commits

Reviewing files that changed from the base of the PR and between 36f669f and a2cfff6.

📒 Files selected for processing (3)
  • src/features/api/payment-processing/create.ts
  • src/shared/booking-lines.ts
  • test/features/api/payment-processing/create.test.ts

Comment thread src/features/api/payment-processing/create.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2cfff6b9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread test/features/public/ticket-payment.test.ts Outdated
Comment thread scripts/mutation/equivalent-mutants.txt
@stefan-burke
stefan-burke added this pull request to the merge queue Jul 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 23, 2026
@stefan-burke

Copy link
Copy Markdown
Member Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@stefan-burke
stefan-burke added this pull request to the merge queue Jul 25, 2026
Merged via the queue into main with commit 6a125dd Jul 25, 2026
3 checks passed
@stefan-burke
stefan-burke deleted the split/canonical-booking-lines branch July 25, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant