feat(reports): ticket activity report and export (#38 slice 3) #111

Merged
amiryahaya merged 7 commits from feat/38-reporting-slice3 into main 2026-10-27 18:07:41 +01:00
Owner

Slice 3 of #38 (reporting): the ticket activity report. Issue stays open for slice 2 (finance: daily invoice, QR income, over/underpayment) and #51 (partner report).

What

  • GET /v1/admin/reports/ticket-activities (keyset paging) and /export (XLSX: "Ticket Activities" + "Summary" sheets), reports.view, platform scope only.
  • The legacy Park Entry Report is this report with kind=checked_in. Filters: from/to (Nairobi days, 366 max), kind, park_id, gate_id, currency, payment_method, code (sale code or check-in number).
  • Masters excluded. Ticket codes (secrets) are never selected, returned, exported or logged.
  • Summary: counts per kind; for check-ins, count and sum of purchase_price per currency (never converted). That is the face value of tickets used, not a sales figure (a top-up never double counts: the replaced ticket is cancelled before check-in).
  • Migration 0028 (ticket_activities (created_at, id) index), OpenAPI + live contract test, ADR 0023 "Slice 3", CLAUDE.md bullet. Reuses slice 1's snapshot, limiter, XLSX writer and handler helpers.

Owner defaults to confirm ([verify], listed in ADR 0023)

Park Entry = a filter, not a second page; only reports.view (legacy let Marketing roles see it); export cap stays 100,000 rows (one peak legacy month was 100,243, so users add a park filter); purchase_price value including waived sales; no KES grand total; masters excluded; no ticket codes or staff user in exports; UTC times; ticket-status search, details page/PDF, pax counts and revenue recognition deferred.

Verification

  • Coverage (make cover): 90.9% total (minimum 80%). make lint 0 issues, make contract ok, go test -race ./... ok.
  • Review: per-task reviews (Tasks 1, 2), then dual-pass whole-branch review (Pass 1 ponytail: no must-fix; Pass 2 correctness: ready, minors fixed; Pass 1 re-check of the fixes).
  • Not done on purpose (Pass 1 optional cleanups): computing the export summary in Go instead of a third query, sharing the opt/paging code between the transaction and activity stores, merging the two Normalize methods. Fine for two reports; revisit with a third.
  • Known gap: the export's "too many rows" 422 is covered by handler tests, not the live contract test. Nothing opened an export in Excel yet (see slice 1).

🤖 Generated with Claude Code

Slice 3 of #38 (reporting): the ticket activity report. Issue stays open for slice 2 (finance: daily invoice, QR income, over/underpayment) and #51 (partner report). ## What - `GET /v1/admin/reports/ticket-activities` (keyset paging) and `/export` (XLSX: "Ticket Activities" + "Summary" sheets), `reports.view`, platform scope only. - The legacy Park Entry Report is this report with `kind=checked_in`. Filters: `from`/`to` (Nairobi days, 366 max), `kind`, `park_id`, `gate_id`, `currency`, `payment_method`, `code` (sale code or check-in number). - Masters excluded. Ticket codes (secrets) are never selected, returned, exported or logged. - Summary: counts per kind; for check-ins, count and sum of `purchase_price` per currency (never converted). That is the face value of tickets used, not a sales figure (a top-up never double counts: the replaced ticket is cancelled before check-in). - Migration 0028 (`ticket_activities (created_at, id)` index), OpenAPI + live contract test, ADR 0023 "Slice 3", CLAUDE.md bullet. Reuses slice 1's snapshot, limiter, XLSX writer and handler helpers. ## Owner defaults to confirm ([verify], listed in ADR 0023) Park Entry = a filter, not a second page; only `reports.view` (legacy let Marketing roles see it); export cap stays 100,000 rows (one peak legacy month was 100,243, so users add a park filter); `purchase_price` value including waived sales; no KES grand total; masters excluded; no ticket codes or staff user in exports; UTC times; ticket-status search, details page/PDF, pax counts and revenue recognition deferred. ## Verification - Coverage (`make cover`): **90.9%** total (minimum 80%). `make lint` 0 issues, `make contract` ok, `go test -race ./...` ok. - Review: per-task reviews (Tasks 1, 2), then dual-pass whole-branch review (Pass 1 ponytail: no must-fix; Pass 2 correctness: ready, minors fixed; Pass 1 re-check of the fixes). - Not done on purpose (Pass 1 optional cleanups): computing the export summary in Go instead of a third query, sharing the `opt`/paging code between the transaction and activity stores, merging the two `Normalize` methods. Fine for two reports; revisit with a third. - Known gap: the export's "too many rows" 422 is covered by handler tests, not the live contract test. Nothing opened an export in Excel yet (see slice 1). 🤖 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>
GET /v1/admin/reports/ticket-activities (keyset page) and .../export
(sheets Ticket Activities and Summary), platform scope with
admin_portal.reports.view, mapped like the transaction routes.

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: ADR 0023 slice 3 consistency (#38)
All checks were successful
ci / changes (pull_request) Successful in 44s
ci / clients (pull_request) Successful in 1m27s
ci / api (pull_request) Successful in 14m33s
ci / ci-gate (pull_request) Successful in 3s
1234d73ffc
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!111
No description provided.