feat(reports): finance pax and revenue by gate export (#38) #114

Merged
amiryahaya merged 5 commits from feat/38-gate-pax-revenue into main 2026-10-28 03:40:45 +01:00
Owner

What

Finance reports PR C of #38 slice 2: pax and revenue by gate, replacing legacy QR Report and Revenue Report. GET /v1/admin/reports/finance/gate-pax-revenue/export?from&to[&park_id&gate_id&currency] (admin_portal.finance.manage, platform scope only; max 366 days; two at a time per node; at most 100,000 grouped rows, counted first, 422 above).

  • Sheet Pax and Revenue: long form, one row per Nairobi check-in day, park, gate, currency and product, with Pax (checked-in tickets) and Revenue (sum of purchase_price, net of discount, before tax and fee); product name, short form, resident type, activity type. Sheet Summary: pax and revenue per currency, and per currency and park.
  • Masters are excluded, a check-out is not a pax, a top-up replacement counts once when it checks in. A 100 % promo sale counts with revenue 0; a waived sale at its ticket price (no money received).
  • Per currency, never converted or added across currencies. Never returns tickets.code. No migration.
  • OpenAPI exportGatePaxRevenueReport + live contract test; ADR 0023 and CLAUDE.md updated.

Owner defaults (research defaults; all [verify] in ADR 0023)

Check-in-day basis (legacy used the UTC sale day), long form instead of one column per product, finance.manage only, no exchange-rate or KES columns. Vehicle rows do not exist: vehicle tickets cannot be checked in (ADR 0019), and legacy's vehicle columns were always empty. Rows are ordered by park and gate name (codes can be NULL).

Verification

  • make cover: 91.0% total (minimum 80%); make lint 0 issues; make contract ok; go test -race ./... ok; client generation ran.
  • Boundary test at 20:59:59Z / 21:00:00Z; tests for top-up counted once, check-out not counted, masters excluded, currencies separate, free and waived, filters, too-many-rows.

Review

Dual-pass. Pass 1 (ponytail): Must fix none; Should-fix items skipped (shared summary-sum helper across three handlers, the "" sentinel key, a second aggregate for the group count). Pass 2 (correctness): 0 Critical; Important (docs said waived sales count 0, the code counts their ticket price) and minors fixed in 04fbc4e, including keying the per-park Summary by park id so two same-named parks (a soft-deleted one and a live one) cannot merge. Pass 1 re-check of the fix: Must fix none.

Known gaps

  • Park-level sorting of the Summary uses Go string order, the main sheet uses the database collation (cosmetic).
  • The count query aggregates the groups a second time on every export (correct, unmeasured).
  • No export has been opened in Excel. Legacy numbers will not match (sale day vs check-in day, USD dropped without a rate in legacy).

🤖 Generated with Claude Code

## What Finance reports PR C of #38 slice 2: pax and revenue by gate, replacing legacy QR Report and Revenue Report. `GET /v1/admin/reports/finance/gate-pax-revenue/export?from&to[&park_id&gate_id&currency]` (`admin_portal.finance.manage`, platform scope only; max 366 days; two at a time per node; at most 100,000 grouped rows, counted first, 422 above). - Sheet `Pax and Revenue`: long form, one row per Nairobi **check-in day**, park, gate, currency and product, with `Pax` (checked-in tickets) and `Revenue` (sum of `purchase_price`, net of discount, before tax and fee); product name, short form, resident type, activity type. Sheet `Summary`: pax and revenue per currency, and per currency and park. - Masters are excluded, a check-out is not a pax, a top-up replacement counts once when it checks in. A 100 % promo sale counts with revenue 0; a waived sale at its ticket price (no money received). - Per currency, never converted or added across currencies. Never returns `tickets.code`. No migration. - OpenAPI `exportGatePaxRevenueReport` + live contract test; ADR 0023 and CLAUDE.md updated. ## Owner defaults (research defaults; all [verify] in ADR 0023) Check-in-day basis (legacy used the UTC sale day), long form instead of one column per product, `finance.manage` only, no exchange-rate or KES columns. Vehicle rows do not exist: vehicle tickets cannot be checked in (ADR 0019), and legacy's vehicle columns were always empty. Rows are ordered by park and gate **name** (codes can be NULL). ## Verification - `make cover`: **91.0%** total (minimum 80%); `make lint` 0 issues; `make contract` ok; `go test -race ./...` ok; client generation ran. - Boundary test at `20:59:59Z` / `21:00:00Z`; tests for top-up counted once, check-out not counted, masters excluded, currencies separate, free and waived, filters, too-many-rows. ## Review Dual-pass. Pass 1 (ponytail): Must fix none; Should-fix items skipped (shared summary-sum helper across three handlers, the `""` sentinel key, a second aggregate for the group count). Pass 2 (correctness): 0 Critical; Important (docs said waived sales count 0, the code counts their ticket price) and minors fixed in 04fbc4e, including keying the per-park Summary by park id so two same-named parks (a soft-deleted one and a live one) cannot merge. Pass 1 re-check of the fix: Must fix none. ## Known gaps - Park-level sorting of the Summary uses Go string order, the main sheet uses the database collation (cosmetic). - The count query aggregates the groups a second time on every export (correct, unmeasured). - No export has been opened in Excel. Legacy numbers will not match (sale day vs check-in day, USD dropped without a rate in legacy). 🤖 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>
fix(reports): gate pax summary keyed by park id, waived wording (#38)
All checks were successful
ci / changes (pull_request) Successful in 13s
ci / clients (pull_request) Successful in 1m14s
ci / api (pull_request) Successful in 15m7s
ci / ci-gate (pull_request) Successful in 6s
04fbc4e416
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!114
No description provided.