Skip to content

Fix booking balances and mobile controls#1863

Merged
stefan-burke merged 6 commits into
mainfrom
screenshot-followups
Jul 19, 2026
Merged

Fix booking balances and mobile controls#1863
stefan-burke merged 6 commits into
mainfrom
screenshot-followups

Conversation

@stefan-burke

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

Copy link
Copy Markdown
Member

What changed

  • show money actually received as the amount paid, including refunds
  • keep the saved order total after refunds or later listing-price changes
  • include booking fees and manual attendee charges in the displayed total
  • keep a fee-free ticket subtotal for reservation-deposit calculations
  • load order rows and all money totals in one two-statement database batch
  • remove an unused per-line ledger-price query from order summaries
  • make parent and child quantity guidance follow the buyer's live selection
  • make the external order cart fit phones with separated quantity controls and full-width actions
  • reject blank setup usernames before screenshot browser automation starts

Why

Marketing screenshot work exposed three customer-facing problems. Balance recaps could overstate the amount paid or lose the original order price after a refund. Child guidance could show a stale maximum beside the live quantity. External cart controls could collide on mobile.

The balance recap now separates net cash, the fee-free reservation subtotal, and the full amount billed. A discounted paid booking stays paid when a listing's current price is higher. Refunded orders keep their original total. Manual charges are included without changing the reservation deposit base.

Checks

  • deno task precommit
  • balance summary mutation testing: 100% (36 killed, 1 proven equivalent)
  • accounting SQL mutation testing: 100% (27 killed)
  • child selector mutation testing: 100%
  • external order widget mutation testing: 100%
  • screenshot scenario validation: 100% line and branch coverage

Risk

  • Full order price now comes from saved ledger charges rather than the listing's current price. This is intentional so later price edits and refunds do not rewrite order history.
  • Reservation deposit calculations use the saved ticket-and-modifier subtotal. Booking fees and later manual charges do not inflate the deposit.

Summary by CodeRabbit

  • New Features
    • Screenshot scenarios can now set scenario-specific admin usernames and generate attendee-specific pay links.
  • Bug Fixes
    • Reservation/admin balance math now derives deposit and full-price from ledger projections (including discounted bookings and refunds).
    • Updated child booking guidance and selector caps, plus refreshed add-on “choose total” wording.
    • Refreshed the order widget layout/styling (cart/stepper/close/continue behavior tweaks).
  • Tests
    • Expanded screenshot scenario validation, UI child-block coverage, and accounting SQL/balance/order-summary assertions.
  • Documentation
    • Added a high-priority marketing screenshot visual cleanup checklist to the project TODO.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5e06a545-9457-41f4-8650-d5ef9fa99ce1

📥 Commits

Reviewing files that changed from the base of the PR and between d6ec47d and 3efeda7.

📒 Files selected for processing (8)
  • scripts/mutation/equivalent-mutants.txt
  • src/features/admin/attendee-ledger-panel.ts
  • src/shared/accounting/projection-sql.ts
  • src/shared/db/attendees/balance.ts
  • test/lib/db/attendee-multiparent-rows.test.ts
  • test/lib/server-reservation/edge-cases.test.ts
  • test/shared/accounting/projection-sql.test.ts
  • test/shared/db/attendees/balance.test.ts
💤 Files with no reviewable changes (1)
  • test/lib/db/attendee-multiparent-rows.test.ts

📝 Walkthrough

Walkthrough

The PR updates attendee balance projections, screenshot scenario setup, reservation child-block rendering, and order widget behavior. It adds related tests, localized guidance, screenshot cleanup documentation, and equivalent-mutant records.

Changes

Attendee balance accounting

Layer / File(s) Summary
External cash and booking SQL projections
src/shared/accounting/projection-sql.ts, test/shared/accounting/projection-sql.test.ts
Adds and tests WORLD-account cash and booking-total subqueries.
Attendee balance integration and validation
src/shared/db/attendees/balance.ts, src/features/admin/..., test/shared/db/attendees/..., test/lib/server-reservation/..., test/lib/server-attendee-form/..., scripts/mutation/equivalent-mutants.txt
Uses ledger-derived payments and totals, with coverage for refunds, settlements, discounted reservations, admin notices, and equivalent mutants.

Screenshot scenario tooling

Layer / File(s) Summary
Scenario configuration and admin setup
scripts/screenshots.ts, scripts/screenshots/scenario.ts, test/fixtures/screenshots/scenarios/*, test/scripts/screenshots-scenario.test.ts
Supports validated scenario usernames and passes them through setup and login.
Screenshot balance links and cleanup checklist
scripts/screenshots.ts, TODO.md
Adds signed attendee balance paths and documents screenshot cleanup tasks.

Reservation child-block rendering

Layer / File(s) Summary
Child-block guidance and quantity rendering
src/locales/en/tickets.json, src/ui/templates/public/reservations/child-block.ts, test/lib/server-parents-e2e.test.ts, test/ui/templates/public/reservations/child-block.test.ts
Updates add-on guidance and quantity-cap handling with rendering coverage.
Child-block compatibility and questions
test/ui/templates/public/reservations/child-block/{compat-data,questions}.test.ts
Covers compatibility attributes and child-question rendering, validation, and persistence.
Parents-gate test coverage updates
test/lib/server-parents-gate/*
Removes superseded selector and question cases while retaining other gate behavior tests.

Order widget

Layer / File(s) Summary
Responsive cart styling
src/ui/client/order.ts, scripts/mutation/equivalent-mutants.txt
Updates responsive cart CSS and equivalent-mutant records.
Cart interactions and navigation
test/ui/client/order.test.ts, test/ui/client/order/storage.test.ts
Expands assertions for initialization, accessibility, quantities, packages, storage, and navigation.
Storage behavior and catalog fixtures
test/ui/client/order/storage.test.ts, test/ui/client/order/support.ts
Tests corrupt-storage cleanup and extends catalog helpers with package data.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant captureScenario
  participant setupAdmin
  participant ScreenshotScenario
  participant balancePathFor
  participant signBalanceToken

  captureScenario->>setupAdmin: Pass scenario.setupUsername
  setupAdmin-->>captureScenario: Complete setup and login
  captureScenario->>ScreenshotScenario: Run scenario with context
  ScreenshotScenario->>balancePathFor: Request attendee balance URL
  balancePathFor->>signBalanceToken: Sign attendee id
  signBalanceToken-->>balancePathFor: Return signed token
  balancePathFor-->>ScreenshotScenario: Return /pay/ URL
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 is concise and captures the main changes: booking balance fixes and mobile cart controls.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch screenshot-followups

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: 3

🤖 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 `@scripts/screenshots/scenario.ts`:
- Around line 28-29: Update the setupUsername validation in the scenario
candidate validator to accept undefined or only non-blank strings, rejecting
empty and whitespace-only values before setupAdmin uses them. Add regression
coverage for both rejected inputs while preserving valid username and
missing-value behavior.

In `@src/shared/db/attendees/balance.ts`:
- Around line 129-137: Add a clear inline comment beside the non-null assertion
in getAttendeeAmountPaid documenting that the scalar SELECT without a FROM
clause always returns exactly one row. Keep the existing non-null assertion and
amount conversion unchanged.
- Around line 153-157: Update the balance-loading flow around the Promise.all
call to combine getAttendeeBalanceState and getAttendeeAmountPaid into one
batched database query, while keeping getAttendeeOrderRows as the separate
query. Preserve both projections and the existing returned values so the
order-summary path remains within the two-query budget.
🪄 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: 1c3f9fe9-3938-43f4-ac45-e6b6678eed04

📥 Commits

Reviewing files that changed from the base of the PR and between 054111a and a8c198a.

📒 Files selected for processing (9)
  • TODO.md
  • scripts/mutation/equivalent-mutants.txt
  • scripts/screenshots.ts
  • scripts/screenshots/scenario.ts
  • src/shared/accounting/projection-sql.ts
  • src/shared/db/attendees/balance.ts
  • test/lib/server-reservation/edge-cases.test.ts
  • test/shared/accounting/projection-sql.test.ts
  • test/shared/db/attendees/balance.test.ts

Comment thread scripts/screenshots/scenario.ts Outdated
Comment thread src/shared/db/attendees/balance.ts Outdated
Comment thread src/shared/db/attendees/balance.ts Outdated

@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

depositPaid,
fullPrice: depositPaid + (state?.remainingBalance ?? 0),

P2 Badge Avoid flagging discounted paid reservations as unpaid

After this change fullPrice and depositPaid are net cash/owed totals, but buildTemplateData still passes summary.listedFullPrice into attendeeBalanceNotice, whose reservation branch uses Math.max(fullPrice, listedFullPrice) - amountPaid. For a discounted reservation whose balance is cleared while it remains in a reservation status (for example a manual ledger payment, or no paid-default status), this now compares the discounted paid total against the undiscounted list price and shows “still unpaid” for the discount amount instead of the paid-status nudge.

ℹ️ 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 src/shared/db/attendees/balance.ts Outdated
@stefan-burke stefan-burke changed the title Improve screenshot scenarios and balance summaries Improve screenshots and mobile booking controls Jul 19, 2026

@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: 7fc5c4d050

ℹ️ 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 src/shared/db/attendees/balance.ts
@stefan-burke

Copy link
Copy Markdown
Member Author

The discounted paid-reservation finding from the Codex review is fixed in a62d831. The attendee form now compares net cash with the immutable saved booking total instead of the listing’s current price. test/lib/server-attendee-form/status.test.ts reproduces a fully paid £9 order on a listing that now costs £10 and verifies the paid-status nudge appears without an unpaid warning.

@stefan-burke stefan-burke changed the title Improve screenshots and mobile booking controls Fix booking balances and mobile controls Jul 19, 2026

@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/shared/db/attendees/balance.ts`:
- Around line 128-132: Update attendeeOrderMoneyStatement to derive the argument
count from the generated SQL rather than hardcoding Array(8). Build the SQL
once, count its “?” placeholders, and use that count to populate args with
attendeeId, preserving the existing query and SqlStatement shape.
🪄 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: 1d022142-d23b-43db-a277-f6bc2ed82eec

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc5c4d and a62d831.

📒 Files selected for processing (24)
  • scripts/mutation/equivalent-mutants.txt
  • scripts/screenshots/scenario.ts
  • src/features/admin/attendee-page-data.ts
  • src/shared/accounting/projection-sql.ts
  • src/shared/db/attendees/balance.ts
  • test/fixtures/screenshots/scenarios/base.ts
  • test/fixtures/screenshots/scenarios/blank-username.ts
  • test/fixtures/screenshots/scenarios/conflicting-options.ts
  • test/fixtures/screenshots/scenarios/empty-username.ts
  • test/fixtures/screenshots/scenarios/invalid-css.ts
  • test/fixtures/screenshots/scenarios/invalid-full-page.ts
  • test/fixtures/screenshots/scenarios/invalid-name-format.ts
  • test/fixtures/screenshots/scenarios/invalid-name-type.ts
  • test/fixtures/screenshots/scenarios/invalid-run.ts
  • test/fixtures/screenshots/scenarios/invalid-selector.ts
  • test/fixtures/screenshots/scenarios/invalid-username-type.ts
  • test/fixtures/screenshots/scenarios/non-object.ts
  • test/fixtures/screenshots/scenarios/null.ts
  • test/fixtures/screenshots/scenarios/with-username.ts
  • test/fixtures/screenshots/scenarios/without-username.ts
  • test/lib/server-attendee-form/status.test.ts
  • test/scripts/screenshots-scenario.test.ts
  • test/shared/accounting/projection-sql.test.ts
  • test/shared/db/attendees/balance.test.ts
💤 Files with no reviewable changes (1)
  • src/features/admin/attendee-page-data.ts

Comment thread src/shared/db/attendees/balance.ts Outdated

@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: a62d831a3b

ℹ️ 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 src/shared/accounting/projection-sql.ts Outdated
Comment thread src/shared/db/attendees/balance.ts
Comment thread src/shared/db/attendees/balance.ts Outdated
@stefan-burke
stefan-burke added this pull request to the merge queue Jul 19, 2026
Merged via the queue into main with commit 849712f Jul 19, 2026
5 checks passed
@stefan-burke
stefan-burke deleted the screenshot-followups branch July 19, 2026 14:14
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