Skip to content

feat: edit bookings (updateBooking) and bill at booking (0.1.4) - #35

Merged
BackStacked merged 1 commit into
mainfrom
claude/project-thread-w4wng5
Nov 11, 2026
Merged

BackStacked merged 1 commit into
mainfrom
claude/project-thread-w4wng5

Conversation

@BackStacked

Copy link
Copy Markdown
Contributor

Requested by Himanshu · project thread

This covers C1 and C2 from the handoff: a booking can be changed after it is made, and it can be billed in the same request that creates it.

updateBooking (booking:update)

A booking can be edited while it is booked, sample collected or in process.

  • Doctor, collection type, time, address and notes. Fields left out stay as they are. null clears the doctor, the time or the address.
  • Add tests. A new sample type gets a new pending tube.
  • Remove tests. Only while the test has no results; its empty report is dropped.
    • A tube that hasn't been collected yet is dropped when no remaining test needs it.
    • The last test can't be removed. Cancel the booking instead.
  • Billing follows, in the same transaction.
The invoice is What happens Extra permission
Unpaid Cancelled and issued again with the booking's tests. Line discounts and the bill discount (capped) are kept. invoice:create, plus invoice:cancel when tests are removed
Paid or credited A credit note for each removed test's line. refundablePaise says what can be refunded. accounts:post
Paid, and tests are added A new invoice for the added tests invoice:create
  • Booking.invoice stays on the first live invoice. The new Booking.invoices lists every invoice of the booking, and cancelBooking now checks all of them.
  • Every edit is audited as booking.update with what changed.

Front desk can add tests, but can't remove a billed test, because that needs invoice:cancel or accounts:post.

createBooking bill (C2)

bill: { payments, billDiscountPaise, applyTaxRules } issues the invoice for the booked tests inside the booking's transaction. A bad discount or payment leaves no booking behind. It needs invoice:create, plus invoice:discount for a discount and payment:create for payments, the same as issueInvoice.

Releases needed first

  1. client 1.10.0 (feat: bookings.update, bill at booking, Booking.invoices (1.10.0) client#17). kits.json already points at it.
  2. Then refresh the lockfile with npm install @mgpl-diagnostics/client@1.10.0. Until then, CI's check that every operation exists in the client fails on updateBooking.

No other kit changes: it uses db-kit 2.1.1 and finance-kit 1.0.1 as they are. Version 0.1.4. Tag v0.1.4 after merge; that release also carries #33.

Checks

  • PostgreSQL: TEST_BACKENDS=pg npm test, with client 1.10.0 installed from its packed tarball, gives 260 passed, 0 failed. That includes 22 new end-to-end checks:
    • billing at booking, including rollback on a bad payment and the discount permission;
    • an unpaid invoice replaced;
    • a paid invoice credited, with a separate invoice for the added test;
    • the permission checks for front desk;
    • results locking a test in;
    • tenant isolation and the audit entries;
    • the trial balance still balancing.
  • MongoDB: not run here, because this container can't download MongoDB. CI runs it.
  • Typecheck passes. The schema, API reference and llms files are regenerated. docs/07-domain-flows.md and docs/examples/lab-day.graphql are updated.

Generated by Claude Code

…g bill) (0.1.4)

updateBooking (booking:update) changes the doctor, collection type, time,
address and notes, adds tests and removes tests that have no results yet.
Samples follow the sample types. Billing follows in the same transaction:
an unpaid invoice is cancelled and issued again (invoice:cancel when tests
are removed, invoice:create); a paid or credited one gets a credit note
for removed tests (accounts:post) and a new invoice for added ones.
Booking.invoices lists every invoice of a booking; cancelBooking checks
them all. Audited as booking.update.

createBooking takes bill { payments, billDiscountPaise, applyTaxRules }
and issues the invoice in the same transaction (invoice:create; discount
invoice:discount; payments payment:create).

Needs client 1.10.0 (kits.json bumped); refresh the lockfile once it is
published.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018jBohjC7uBfVPopxyZBtS1
@BackStacked BackStacked self-assigned this Nov 11, 2026
@BackStacked
BackStacked merged commit adda862 into main Nov 11, 2026
1 check failed
@BackStacked
BackStacked deleted the claude/project-thread-w4wng5 branch November 11, 2026 14:44
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.

2 participants