feat(api): cart line details (park, product, availability, unit price) (#40) #124

Merged
amiryahaya merged 8 commits from feat/40-cart-line-details into main 2026-10-29 09:11:25 +01:00
Owner

What

GET and PUT /v1/me/cart now return read-only details on each cart line, so the web cart page (and checkout, #41) no longer needs parks × dates requests to find names and prices. Request bodies are unchanged. API only; the web change is a separate PR.

New line fields: park_id, available (always), and park_name, product_name, age_group, resident_type, unit_price (optional).

Rules

  • unit_price = price of one ticket for the whole stay, in the cart currency, before promo/tax/fee. Not an order total; checkout stays the only pricer.
  • Priced with the checkout helpers (dayQuotes, dayPrice, stayDays), one quote per distinct (park, day), summed with money.Amount. A test compares the cart price with what a real checkout charges.
  • available: false (no unit_price) when any stay day has no price/rate, the visit day is before today (Nairobi), or the park/product is off. A switched-off park or product also has no names. An unknown currency makes every line unavailable, not a 500.
  • Cart view runs in one read-only transaction; lines, park ids and park names come from one statement (fixes a race found in review where a concurrent PUT could give a 500).
  • Responses stay no-store; owner from the token.

Docs

Spec docs/superpowers/specs/2026-10-29-cart-line-details-design.md, plan, CLAUDE.md cart note, ADR 0011, OpenAPI CartLine. Calls marked [verify] in the spec await the owner.

Checks

  • make cover: 91.3% total (minimum 80%), run after the last code change
  • make lint, make contract pass; TS and Dart clients regenerate (scripts/generate-clients.sh)
  • Dual-pass review (complexity, then correctness) done; Pass 1 re-check after the fix: Ship

Not covered / known

No test for a concurrent PUT during the read (relies on the single statement); no USD parity test against checkout, no inactive-currency DB test, no unavailable-line live contract case (all optional, parked).

🤖 Generated with Claude Code

## What `GET` and `PUT /v1/me/cart` now return read-only details on each cart line, so the web cart page (and checkout, #41) no longer needs parks × dates requests to find names and prices. Request bodies are unchanged. API only; the web change is a separate PR. New line fields: `park_id`, `available` (always), and `park_name`, `product_name`, `age_group`, `resident_type`, `unit_price` (optional). ## Rules - `unit_price` = price of one ticket for the whole stay, in the cart currency, before promo/tax/fee. **Not an order total**; checkout stays the only pricer. - Priced with the checkout helpers (`dayQuotes`, `dayPrice`, `stayDays`), one quote per distinct (park, day), summed with `money.Amount`. A test compares the cart price with what a real checkout charges. - `available: false` (no `unit_price`) when any stay day has no price/rate, the visit day is before today (Nairobi), or the park/product is off. A switched-off park or product also has no names. An unknown currency makes every line unavailable, not a 500. - Cart view runs in one read-only transaction; lines, park ids and park names come from one statement (fixes a race found in review where a concurrent PUT could give a 500). - Responses stay `no-store`; owner from the token. ## Docs Spec `docs/superpowers/specs/2026-10-29-cart-line-details-design.md`, plan, CLAUDE.md cart note, ADR 0011, OpenAPI `CartLine`. Calls marked **[verify]** in the spec await the owner. ## Checks - `make cover`: **91.3%** total (minimum 80%), run after the last code change - `make lint`, `make contract` pass; TS and Dart clients regenerate (`scripts/generate-clients.sh`) - Dual-pass review (complexity, then correctness) done; Pass 1 re-check after the fix: Ship ## Not covered / known No test for a concurrent PUT during the read (relies on the single statement); no USD parity test against checkout, no inactive-currency DB test, no unavailable-line live contract case (all optional, parked). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fix(sales): cart view review fixes (#40)
All checks were successful
ci / changes (pull_request) Successful in 11s
ci / clients (pull_request) Successful in 1m31s
ci / web (pull_request) Successful in 3m45s
ci / api (pull_request) Successful in 9m55s
ci / ci-gate (pull_request) Successful in 3s
d709b0d520
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!124
No description provided.