feat(reports): finance QR income and payment exceptions exports (#38) #112

Merged
amiryahaya merged 7 commits from feat/38-finance-qr-income into main 2026-10-27 19:25:29 +01:00
Owner

What

Finance reports PR A of #38 slice 2: two Excel exports, platform scope only, permission admin_portal.finance.manage.

  • GET /v1/admin/reports/finance/qr-income/export: one row per checked-in non-master ticket. Basis is the check-in day (Nairobi), Amount = purchase_price + discount, Net = purchase_price, D/C = C for wallet, Paid To = currencies.account.
  • GET /v1/admin/reports/finance/payment-exceptions/export: refund_due / refunded payments with a reason (currency > over/under > duplicate > late; variance only for the same currency).
  • Never returns tickets.code. Per currency, never converted. Cap 100,000 rows, 366 days, two exports at a time per node.
  • OpenAPI operations + live contract test; ADR 0023 and CLAUDE.md updated.

Owner defaults (research defaults, "go with defaults")

Check-in-day basis, finance.manage only, no ticket codes, per currency. [verify] items are listed in ADR 0023.

Also in this PR

  • Main was red since 6afdeba: slice 3's actRow test used time.FixedZone, failing kenyatime.TestNoOtherZones (PR #111 CI ran before kenyatime landed). Fixed here (ae1413a); can be split out if you prefer.
  • Transaction tests depended on the current month (rows stamped by the DB trigger with the real clock); now use untilToday() (ad6a407).

Verification

  • make cover: 90.9% total (minimum 80%)
  • make lint: 0 issues; make contract: ok; clients script ran.

Review

Dual-pass. Pass 1 (ponytail): Must fix none; optional Should-fix cleanups skipped (summary math in handler, repeated opt closure, export-only JSON tags, variance cell helper). Pass 2 (correctness): one Important (OpenAPI Payment Method wording) and minors, fixed in c68acae; Pass 1 re-check of that commit: Must fix none.

Known gaps

  • Top-up new-ticket row shows the parent sale's payment provider; free-sale row shows the sale's chosen method while the Summary paid-by is empty (both [verify] in ADR).
  • Live contract test checks only zip + content type, not exceptions row contents or the too-many-rows 422 (unit tests cover them).
  • No export has been opened in Excel (only validated with openpyxl).

🤖 Generated with Claude Code

## What Finance reports PR A of #38 slice 2: two Excel exports, platform scope only, permission `admin_portal.finance.manage`. - `GET /v1/admin/reports/finance/qr-income/export`: one row per checked-in non-master ticket. Basis is the **check-in day** (Nairobi), Amount = purchase_price + discount, Net = purchase_price, D/C = C for wallet, Paid To = `currencies.account`. - `GET /v1/admin/reports/finance/payment-exceptions/export`: `refund_due` / `refunded` payments with a reason (currency > over/under > duplicate > late; variance only for the same currency). - Never returns `tickets.code`. Per currency, never converted. Cap 100,000 rows, 366 days, two exports at a time per node. - OpenAPI operations + live contract test; ADR 0023 and CLAUDE.md updated. ## Owner defaults (research defaults, "go with defaults") Check-in-day basis, `finance.manage` only, no ticket codes, per currency. [verify] items are listed in ADR 0023. ## Also in this PR - **Main was red since 6afdeba**: slice 3's `actRow` test used `time.FixedZone`, failing `kenyatime.TestNoOtherZones` (PR #111 CI ran before kenyatime landed). Fixed here (ae1413a); can be split out if you prefer. - Transaction tests depended on the current month (rows stamped by the DB trigger with the real clock); now use `untilToday()` (ad6a407). ## Verification - `make cover`: **90.9%** total (minimum 80%) - `make lint`: 0 issues; `make contract`: ok; clients script ran. ## Review Dual-pass. Pass 1 (ponytail): Must fix none; optional Should-fix cleanups skipped (summary math in handler, repeated `opt` closure, export-only JSON tags, variance cell helper). Pass 2 (correctness): one Important (OpenAPI Payment Method wording) and minors, fixed in c68acae; Pass 1 re-check of that commit: Must fix none. ## Known gaps - Top-up new-ticket row shows the parent sale's payment provider; free-sale row shows the sale's chosen method while the Summary paid-by is empty (both [verify] in ADR). - Live contract test checks only zip + content type, not exceptions row contents or the too-many-rows 422 (unit tests cover them). - No export has been opened in Excel (only validated with openpyxl). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
QR income: one row per checked-in non-master ticket (slice 3 joins) with
GL code, category, station, gate, buyer email, promo code, the succeeded
payment's provider and reference and the currency's account; Amount =
purchase_price + discount, Net = purchase_price; D/C is C for wallet.
Summary per currency and provider in SQL. Count first, same snapshot.

Payment exceptions: refund_due and refunded payments by payment day with
the reason computed in SQL (currency, over, under, duplicate, late),
variance only in the same currency, refunded_at when refunded.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Rows whose created_at the database forces to the real clock fell outside the fixed
2026-10 range from November. The range now ends two days after today.

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: PR A review fixes (#38)
All checks were successful
ci / changes (pull_request) Successful in 19s
ci / clients (pull_request) Successful in 1m37s
ci / api (pull_request) Successful in 14m16s
ci / ci-gate (pull_request) Successful in 3s
c68acae299
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!112
No description provided.