feat(api): catalog products, park-products and price windows (#17, part 1) #82

Merged
amiryahaya merged 1 commit from feat/catalog-products into main 2026-10-23 06:34:46 +02:00
Owner

Part 1 of #17 (does not close it: the shop price lookup is part 2).

What

Products, the products each park sells, and their price windows, as admin CRUD.

  • Migration 0007: products, park_products, park_product_prices.
    • Products carry no currency or base price (never read by pricing). They are unique by name, resident type and category, also when there is no resident type, which fixes the legacy duplicate check that compared a category id with a currency id.
    • Price windows are whole calendar days with an inclusive end, per park product and currency. The database refuses overlapping active windows, including a window that encloses an existing one, which the legacy check (it only tested the two ends) let through.
    • products.form_id has no foreign key until forms exist (#19).
  • API (catalog.ProductHandler, all /v1/admin/..., admin_portal.administration.manage): products CRUD with filters and versioned soft delete; park products (create, list per park, update order/active); prices (create, list, update). Optimistic locking everywhere, overlap is a 409, prices travel as decimal strings (a JSON number is rejected), removed products drop out of lists.
  • Decision recorded: the legacy fine-grained product permissions were never enforced (only the policies applied), so I did not start enforcing them; setup uses the same gate as the rest of the catalog.

Standards review (docs/development-standards.md)

  • TDD: schema, validation, handler, store and end-to-end tests written first. Breaking the overlap mapping fails its test.
  • SOLID / coupling: three narrow store interfaces (ProductStore, ParkProductStore, PriceStore); ProductHandler takes them separately; shared plumbing reused (rest, pgrest), nothing duplicated.
  • Coverage: 94.4% total; catalog 100%, catalog store 95.9%. make lint 0 issues.
  • A correction: earlier PRs said "govulncheck clean" after reading only the tail of local output. A local run uses the installed Go 1.26.0 and reports 28 standard-library fixes that the pinned 1.26.10 already has, with or without this change. The CI security job (pinned toolchain) is the authoritative check and was green on main after the last merge. The standards doc now says so.

Known limits

  • Admin lists are not paginated (products and park products are dozens, not thousands).
  • Moving nothing between parks/currencies on a price (the pair is fixed once created; create a new price instead).

Next (part 2, closes #17)

The shop lookup in a new pricing package: price for a visit day in the chosen currency, converted at the admin rate valid that day, "not available in " otherwise (ADR 0004).

🤖 Generated with Claude Code

Part 1 of #17 (does not close it: the shop price lookup is part 2). ## What Products, the products each park sells, and their price windows, as admin CRUD. - **Migration 0007**: `products`, `park_products`, `park_product_prices`. - Products carry no currency or base price (never read by pricing). They are unique by name, resident type and category, also when there is no resident type, which fixes the legacy duplicate check that compared a category id with a currency id. - Price windows are whole calendar days with an inclusive end, per park product and currency. The database refuses overlapping *active* windows, including a window that encloses an existing one, which the legacy check (it only tested the two ends) let through. - `products.form_id` has no foreign key until forms exist (#19). - **API** (`catalog.ProductHandler`, all `/v1/admin/...`, `admin_portal.administration.manage`): products CRUD with filters and versioned soft delete; park products (create, list per park, update order/active); prices (create, list, update). Optimistic locking everywhere, overlap is a 409, prices travel as decimal strings (a JSON number is rejected), removed products drop out of lists. - Decision recorded: the legacy fine-grained product permissions were never enforced (only the policies applied), so I did not start enforcing them; setup uses the same gate as the rest of the catalog. ## Standards review (docs/development-standards.md) - **TDD**: schema, validation, handler, store and end-to-end tests written first. Breaking the overlap mapping fails its test. - **SOLID / coupling**: three narrow store interfaces (`ProductStore`, `ParkProductStore`, `PriceStore`); `ProductHandler` takes them separately; shared plumbing reused (`rest`, `pgrest`), nothing duplicated. - **Coverage**: 94.4% total; catalog 100%, catalog store 95.9%. `make lint` 0 issues. - **A correction**: earlier PRs said "govulncheck clean" after reading only the tail of local output. A local run uses the installed Go 1.26.0 and reports 28 standard-library fixes that the pinned 1.26.10 already has, with or without this change. The CI security job (pinned toolchain) is the authoritative check and was green on `main` after the last merge. The standards doc now says so. ## Known limits - Admin lists are not paginated (products and park products are dozens, not thousands). - Moving nothing between parks/currencies on a price (the pair is fixed once created; create a new price instead). ## Next (part 2, closes #17) The shop lookup in a new `pricing` package: price for a visit day in the chosen currency, converted at the admin rate valid that day, "not available in <currency>" otherwise (ADR 0004). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(api): catalog products, park-products and price windows (part 1 of #17)
All checks were successful
ci / changes (pull_request) Successful in 7s
ci / api (pull_request) Successful in 3m43s
ci / ci-gate (pull_request) Successful in 2s
a9dc879787
Migration 0007: products (unique by name, resident type, category; fixes the legacy duplicate check),
park_products and park_product_prices with whole-day inclusive windows. The database refuses overlapping
active windows per park product and currency, including a window enclosing another.
ProductHandler: admin CRUD gated by administration.manage with optimistic locking and versioned soft
delete; amounts travel as decimal strings. The shop price lookup follows in the next PR.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
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
primatekuntech/kws!82
No description provided.