Bundles: protect their parts from deletion, show the saving #8

Merged
reudy merged 2 commits from bundle-parts-sale-price into main 2026-10-26 12:02:42 +01:00
Member

Why

A bundle card showed "1× Item (2 hours)" instead of the service names. Bundle parts are stored as JSON, not relations, so a service could be deleted, or made inactive, while bundles and codes still pointed at it. The public shop only loads active items, so it couldn't name the part. Bundles also didn't show that they're cheaper than buying the parts one by one.

What changes

  • A service or product can't be deleted while a bundle contains it, or while a usable code still has sessions of it to book. This is an onRecordDelete hook, so it also covers the PocketBase dashboard. The admin shows a message naming the bundle or code.
  • Making it inactive is allowed. A bundle with an inactive part (or a length that's no longer offered) is hidden from the shop and can't be bought or issued; the admin list marks it Not on sale with the reason. An inactive service shows how many codes still have sessions of it left, because codes can't book inactive services.
  • Bundle cards show the "bought separately" price crossed out when it's higher than the bundle price.
  • Tested: guard.py (8 checks: delete refused for a bundle part, refused for a code with sessions left, allowed once the code is void, bundle refused with an inactive part, snapshot kept); scenarios 46/46 and passes 37/37 again on a fresh schema; and in a browser: the sale price on the card, the admin warnings, and the delete error banner.

Deploying

Nothing to migrate: these are hook and app changes only. After deploying, check Services & products for bundles marked Not on sale. Any that point at an already-deleted service need that part re-added or removed in the bundle editor.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW

## Why A bundle card showed "1× Item (2 hours)" instead of the service names. Bundle parts are stored as JSON, not relations, so a service could be deleted, or made inactive, while bundles and codes still pointed at it. The public shop only loads active items, so it couldn't name the part. Bundles also didn't show that they're cheaper than buying the parts one by one. ## What changes - A service or product can't be deleted while a bundle contains it, or while a usable code still has sessions of it to book. This is an `onRecordDelete` hook, so it also covers the PocketBase dashboard. The admin shows a message naming the bundle or code. - Making it inactive is allowed. A bundle with an inactive part (or a length that's no longer offered) is hidden from the shop and can't be bought or issued; the admin list marks it **Not on sale** with the reason. An inactive service shows how many codes still have sessions of it left, because codes can't book inactive services. - Bundle cards show the "bought separately" price crossed out when it's higher than the bundle price. - Tested: `guard.py` (8 checks: delete refused for a bundle part, refused for a code with sessions left, allowed once the code is void, bundle refused with an inactive part, snapshot kept); scenarios 46/46 and passes 37/37 again on a fresh schema; and in a browser: the sale price on the card, the admin warnings, and the delete error banner. ## Deploying Nothing to migrate: these are hook and app changes only. After deploying, check **Services & products** for bundles marked *Not on sale*. Any that point at an already-deleted service need that part re-added or removed in the bundle editor. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
agent added 2 commits 2026-10-26 10:05:05 +01:00
Bundle parts are JSON, so deleting a service left bundles pointing at
nothing (shown as "Item" in the shop). An onRecordDelete hook on items
now refuses while a bundle contains it or a usable code still has
sessions of it to book. A bundle with an inactive part is no longer sold
or issued; the admin items list marks it "Not on sale" and shows how many
codes are waiting on an inactive service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
Bundle cards show what the parts cost one by one, crossed out when it's
more than the bundle price. Bundles with a part that isn't on sale are
left out of the shop data, so their parts always have names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hy2vMnHJYP7QGsiH21zHxW
reudy merged commit 76b297153e into main 2026-10-26 12:02:42 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: reudy-net/domaino#8
No description provided.