feat(reports): finance daily invoice export (#38) #113

Merged
amiryahaya merged 7 commits from feat/38-daily-invoice into main 2026-10-27 21:30:07 +01:00
Owner

What

Finance reports PR B of #38 slice 2: the Daily Invoice Excel export, GET /v1/admin/reports/finance/daily-invoice/export?from&to[&currency] (admin_portal.finance.manage, platform scope only; max 366 days; two at a time per node).

  • Sheets Daily Invoice (per Nairobi day: DR = money received per provider, a Waived line, CR = revenue recognised at check-in by station, Recognised at sale for vehicle tickets and overstay, Tax, Service charge, Expired unused), Deferred Revenue (roll-forward per currency and station) and Summary (per currency).
  • Per currency, never converted or added across currencies. An unset GL code is an empty cell, never a guessed one.
  • Migration 0029_currency_gl_code (currencies.general_ledger_code, admin-only like account); settings types ledger_code / text and keys gl_mpesa, gl_wallet, gl_recognised_revenue, gl_tax, gl_service_charge, gl_waiver, finance_bank_name.
  • OpenAPI operation exportDailyInvoiceReport + live contract test; ADR 0023 and CLAUDE.md updated.

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

DR is money received (not legacy's net-of-fee figure); waived sales are their own DR line; vehicle/overstay recognised at completion; expired unused recognised on the Nairobi day of expires_at; deferred as of the end of to; no KES conversion; refund-due money excluded. Finance still has to set the gl_* settings and finance_bank_name; the codes are not assumed.

Verification

  • make cover: 91.0% total (minimum 80%); make lint 0 issues; make contract ok; go test -race ./... ok; client generation ran.
  • Boundary tests at 20:59:59Z / 21:00:00Z for completion, check-in, expiry and the deferred cut-off. The roll-forward identity (opening + issued - recognised - cancelled - expired - recognised at sale = closing) is pinned on a mixed fixture.

Review

Dual-pass. Pass 1 (ponytail): Must fix none; Should-fix items skipped (shared ledger-code regex, unused label constants, showing Closing and Closing (direct) both [kept on purpose as a visible cross-check], Go-side totals). Pass 2 (correctness): 0 Critical; Important (Paid To printed " - KES" when the bank name is unset) fixed in 756a710 with a test, plus wording fixes; Pass 1 re-check of the fix: Must fix none. The store review found one Important (queries could not use the partial completed-sales index), fixed in 0826eec.

Known gaps

  • A sale that completes on a later Nairobi day than its tickets' expiry day (e.g. a mobile-money sale left processing) can make Closing differ from Closing (direct) for a range that splits those days. Documented in the ADR.
  • The deferred-balance scan reads every park-entry ticket and has not been measured (marked shortcut: with the upgrade path of a monthly snapshot job).
  • No export has been opened in Excel.

🤖 Generated with Claude Code

## What Finance reports PR B of #38 slice 2: the **Daily Invoice** Excel export, `GET /v1/admin/reports/finance/daily-invoice/export?from&to[&currency]` (`admin_portal.finance.manage`, platform scope only; max 366 days; two at a time per node). - Sheets `Daily Invoice` (per Nairobi day: DR = money received per provider, a `Waived` line, CR = revenue recognised at check-in by station, `Recognised at sale` for vehicle tickets and overstay, `Tax`, `Service charge`, `Expired unused`), `Deferred Revenue` (roll-forward per currency and station) and `Summary` (per currency). - Per currency, never converted or added across currencies. An unset GL code is an empty cell, never a guessed one. - Migration `0029_currency_gl_code` (`currencies.general_ledger_code`, admin-only like `account`); settings types `ledger_code` / `text` and keys `gl_mpesa`, `gl_wallet`, `gl_recognised_revenue`, `gl_tax`, `gl_service_charge`, `gl_waiver`, `finance_bank_name`. - OpenAPI operation `exportDailyInvoiceReport` + live contract test; ADR 0023 and CLAUDE.md updated. ## Owner defaults (research defaults; all [verify] in ADR 0023) DR is money received (not legacy's net-of-fee figure); waived sales are their own DR line; vehicle/overstay recognised at completion; expired unused recognised on the Nairobi day of `expires_at`; deferred as of the end of `to`; no KES conversion; refund-due money excluded. Finance still has to set the `gl_*` settings and `finance_bank_name`; the codes are not assumed. ## Verification - `make cover`: **91.0%** total (minimum 80%); `make lint` 0 issues; `make contract` ok; `go test -race ./...` ok; client generation ran. - Boundary tests at `20:59:59Z` / `21:00:00Z` for completion, check-in, expiry and the deferred cut-off. The roll-forward identity (opening + issued - recognised - cancelled - expired - recognised at sale = closing) is pinned on a mixed fixture. ## Review Dual-pass. Pass 1 (ponytail): Must fix none; Should-fix items skipped (shared ledger-code regex, unused label constants, showing `Closing` and `Closing (direct)` both [kept on purpose as a visible cross-check], Go-side totals). Pass 2 (correctness): 0 Critical; Important (Paid To printed " - KES" when the bank name is unset) fixed in 756a710 with a test, plus wording fixes; Pass 1 re-check of the fix: Must fix none. The store review found one Important (queries could not use the partial completed-sales index), fixed in 0826eec. ## Known gaps - A sale that completes on a later Nairobi day than its tickets' expiry day (e.g. a mobile-money sale left processing) can make `Closing` differ from `Closing (direct)` for a range that splits those days. Documented in the ADR. - The deferred-balance scan reads every park-entry ticket and has not been measured (marked `shortcut:` with the upgrade path of a monthly snapshot job). - No export has been opened in Excel. 🤖 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(reports): daily invoice Paid To without a bank name, wording (#38)
All checks were successful
ci / changes (pull_request) Successful in 16s
ci / clients (pull_request) Successful in 1m26s
ci / api (pull_request) Successful in 7m41s
ci / ci-gate (pull_request) Successful in 2s
756a71023d
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!113
No description provided.