feat(partner): customers (#50) #155

Merged
amiryahaya merged 7 commits from feat/partner-customers-50 into main 2026-11-03 18:18:34 +01:00
Owner

Closes the customers part of #50: an organization keeps a private list of its travellers (customers) for itineraries (#51).

What

  • partner_customers table (migration 0037): private per organization; ID number unique per organization, ignoring case, among live rows; expiry dates follow the customer type (CHECK); soft delete; name, email, phone, ID number and expiry dates kept out of audit_log.
  • internal/partners (service, store, handler) and /v1/orgs/{id}/customers[/{customer_id}]: list with search and paging, create (Idempotency-Key), get, edit (version), delete (?version=). Permissions business_portal.customer.view|create|update|delete in the organization; writes need an active organization (ADR 0021); another organization's customer is 404.
  • Partner portal: Customers page (search, paging, add, edit, remove by permission), mocked e2e at 320/768/1280.
  • ADR 0032 and a CLAUDE.md section. Legacy bugs not ported: ID number unique across all organizations, no organization check on get/update/delete.

Checks

  • make cover: 91.6% (minimum 80%). golangci-lint: 0 issues. go test ./... all packages pass.
  • Partner unit tests 114 pass; scripts/web-e2e.sh partner 34 passed; typecheck of partner, admin and ticket ok.
  • Dual-pass review: ponytail complexity pass (2 small web bugs fixed), then a fresh whole-branch review (3 findings fixed test-first; 7 minors deferred, listed below).

Owner questions ([verify], ADR 0032)

  1. Customer type (citizen / resident / non-resident) is stored on the customer (legacy took it from a ticket-category product).
  2. One customer per create (legacy's form took several rows).
  3. Phone is plain text; the web form turns a Kenyan 07xx number into +254.
  4. Past expiry dates are accepted.

Deferred minors

NUL byte in search or text gives a 500 (codebase-wide); create accepts a stray version; lock-wait on write statements after the organization lock is a 500 not 503; list items and total are two queries; pager can point past the last page after others delete; e2e PUT mock keeps old fields; searching the typed 07xx phone finds nothing.

Notes: orgs.OrgRoute is a thin exported wrapper of orgRoute; all customer routes use the default rate class (sensitive allows 10 an hour).

🤖 Generated with Claude Code

Closes the customers part of #50: an organization keeps a private list of its travellers (customers) for itineraries (#51). ## What - `partner_customers` table (migration 0037): private per organization; ID number unique per organization, ignoring case, among live rows; expiry dates follow the customer type (CHECK); soft delete; name, email, phone, ID number and expiry dates kept out of `audit_log`. - `internal/partners` (service, store, handler) and `/v1/orgs/{id}/customers[/{customer_id}]`: list with search and paging, create (`Idempotency-Key`), get, edit (`version`), delete (`?version=`). Permissions `business_portal.customer.view|create|update|delete` in the organization; writes need an active organization (ADR 0021); another organization's customer is 404. - Partner portal: Customers page (search, paging, add, edit, remove by permission), mocked e2e at 320/768/1280. - ADR 0032 and a CLAUDE.md section. Legacy bugs not ported: ID number unique across all organizations, no organization check on get/update/delete. ## Checks - `make cover`: **91.6%** (minimum 80%). `golangci-lint`: 0 issues. `go test ./...` all packages pass. - Partner unit tests 114 pass; `scripts/web-e2e.sh partner` 34 passed; typecheck of partner, admin and ticket ok. - Dual-pass review: ponytail complexity pass (2 small web bugs fixed), then a fresh whole-branch review (3 findings fixed test-first; 7 minors deferred, listed below). ## Owner questions ([verify], ADR 0032) 1. Customer type (citizen / resident / non-resident) is stored on the customer (legacy took it from a ticket-category product). 2. One customer per create (legacy's form took several rows). 3. Phone is plain text; the web form turns a Kenyan 07xx number into +254. 4. Past expiry dates are accepted. ## Deferred minors NUL byte in search or text gives a 500 (codebase-wide); create accepts a stray `version`; lock-wait on write statements after the organization lock is a 500 not 503; list items and total are two queries; pager can point past the last page after others delete; e2e PUT mock keeps old fields; searching the typed 07xx phone finds nothing. Notes: `orgs.OrgRoute` is a thin exported wrapper of `orgRoute`; all customer routes use the `default` rate class (`sensitive` allows 10 an hour). 🤖 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>
fix(partners): refuse year-0 dates, keep expiry dates out of audit_log, new idempotency key for an edited form (#50)
All checks were successful
ci / changes (pull_request) Successful in 15s
ci / clients (pull_request) Successful in 1m23s
ci / web-partner (pull_request) Successful in 2m36s
ci / web-ticket (pull_request) Successful in 4m35s
ci / web-admin (pull_request) Successful in 4m53s
ci / api (pull_request) Successful in 12m6s
ci / ci-gate (pull_request) Successful in 2s
e1bb1aefb2
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!155
No description provided.