feat(vehicle-addon): vehicle add-on sales and standalone vehicle tickets (#36) #105

Merged
amiryahaya merged 7 commits from feat/36-vehicle-addon into main 2026-10-27 01:19:02 +01:00
Owner

Vehicle add-on slice of #36. Does not close #36 (ticket top-up/upgrade is still open).

What it does

  • Staff add a vehicle to a completed ticket sale: POST /v1/admin/transactions/{id}/vehicle-add-ons (Idempotency-Key required, permission admin_portal.tickets.scan). It creates a child sale type = 'vehicle_add_on' priced by the server for the visit's whole stay, in the parent's currency. The customer pays (wallet or M-Pesa) or Finance waives it.
  • Completion issues one standalone vehicle ticket per unit (no master, no parent_ticket_id). Master scans never move them; gate scans refuse a vehicle code (409 vehicle_ticket) until vehicle check-in exists.
  • Every ticket sale now takes each ticket's activity type from its product (before, a vehicle product in a plain checkout was issued as park_entry under the master). The master's dates come from the person lines.
  • Migration 0023 (transactions_add_on_shape, sale_bad_parent, tickets_master_parent, vehicle activity type); ADR 0019; OpenAPI operation plus live contract test; CLAUDE.md "Vehicle add-on" section.

[verify] items for the owner

Server pricing and issuing at all (legacy did neither); no plate captured; buyer is the parent's buyer, not a new guest; whole-stay charge including past days; no promo on add-ons; several add-ons per parent allowed.

Known limits (ADR 0019)

Vehicle-only cart still gets a master with no children (h); a pending add-on can be paid after the master is checked out (i); a plain checkout takes the product type at issue time (j); a product retype in a narrow window is a 500, not a 422 (k). Down migration fails once add-on data exists (test databases only).

Review (dual pass)

  • Pass 1 (ponytail): no Must fix. Re-checked after the fix wave: no Must fix, no Should fix.
  • Pass 2 (correctness): one Important finding (add-on could not complete after its product was retyped; M-Pesa money stuck). Fixed in 401e588 with a regression test. Minor items fixed or documented.
  • Skipped on purpose: shared helper for the add-on/overstay handler duplication.

Verification

go test -race ./... green, make lint 0 issues, make contract ok, clients generated, make cover: total coverage 90.3% (minimum 80%).

Deploy

Run migration 0023 (KWS_MODE=migrate). No new environment variables. The worker must be running (as for checkout).

🤖 Generated with Claude Code

Vehicle add-on slice of #36. **Does not close #36** (ticket top-up/upgrade is still open). ## What it does - Staff add a vehicle to a completed ticket sale: `POST /v1/admin/transactions/{id}/vehicle-add-ons` (`Idempotency-Key` required, permission `admin_portal.tickets.scan`). It creates a child sale `type = 'vehicle_add_on'` priced by the server for the visit's whole stay, in the parent's currency. The customer pays (wallet or M-Pesa) or Finance waives it. - Completion issues one standalone `vehicle` ticket per unit (no master, no `parent_ticket_id`). Master scans never move them; gate scans refuse a vehicle code (409 `vehicle_ticket`) until vehicle check-in exists. - Every ticket sale now takes each ticket's activity type from its product (before, a vehicle product in a plain checkout was issued as `park_entry` under the master). The master's dates come from the person lines. - Migration 0023 (`transactions_add_on_shape`, `sale_bad_parent`, `tickets_master_parent`, `vehicle` activity type); ADR 0019; OpenAPI operation plus live contract test; CLAUDE.md "Vehicle add-on" section. ## [verify] items for the owner Server pricing and issuing at all (legacy did neither); no plate captured; buyer is the parent's buyer, not a new guest; whole-stay charge including past days; no promo on add-ons; several add-ons per parent allowed. ## Known limits (ADR 0019) Vehicle-only cart still gets a master with no children (h); a pending add-on can be paid after the master is checked out (i); a plain checkout takes the product type at issue time (j); a product retype in a narrow window is a 500, not a 422 (k). Down migration fails once add-on data exists (test databases only). ## Review (dual pass) - Pass 1 (ponytail): no Must fix. Re-checked after the fix wave: no Must fix, no Should fix. - Pass 2 (correctness): one Important finding (add-on could not complete after its product was retyped; M-Pesa money stuck). Fixed in 401e588 with a regression test. Minor items fixed or documented. - Skipped on purpose: shared helper for the add-on/overstay handler duplication. ## Verification `go test -race ./...` green, `make lint` 0 issues, `make contract` ok, clients generated, **`make cover`: total coverage 90.3% (minimum 80%)**. ## Deploy Run migration 0023 (`KWS_MODE=migrate`). No new environment variables. The worker must be running (as for checkout). 🤖 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>
docs(vehicle-addon): CLAUDE.md rules for vehicle add-ons (#36)
All checks were successful
ci / changes (pull_request) Successful in 12s
ci / clients (pull_request) Successful in 2m20s
ci / api (pull_request) Successful in 22m17s
ci / ci-gate (pull_request) Successful in 7s
e299cebb9a
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!105
No description provided.