# AccountReports: What This Is and Why

## In one paragraph

GoodBooks GB4.7 has a large, mature set of accounting reports — account registers, ledgers,
outstanding-balance analysis, ageing, settlement history, and collection-performance projections.
As part of the GB4.7 → GB5 rebuild, these reports are being re-implemented one at a time on the new
GB5 backend (.NET 9, FastEndpoints, Dapper — see the main repo `CLAUDE.md` for the architecture).
Each migrated report is wired into GB5's existing "MetaReport" framework, the same
menu-driven, configurable report viewer that already exists in GB5 for other report types — so once
a report is migrated, it shows up and behaves like any other GB5 report, not as a one-off screen.

## Why migrate one at a time, rather than all at once

Each legacy report has its own quirks — sign conventions, hidden business rules in comments,
tables that look similar but mean different things depending on context. Moving fast by copying SQL
wholesale would silently carry legacy bugs (and legacy SQL-injection-shaped string concatenation)
into GB5. Instead, each report is:
1. Read from the actual legacy source, not guessed at.
2. Checked against the **live** GB5 database schema before any new SQL is written — GB5 isn't always
   schema-identical to legacy, and columns/values that look the same sometimes aren't.
3. Validated by actually running the new SQL against a real GB5 database with real data, before it's
   wired into any C# code.
4. Tested via a real HTTP call against a running GB5 server before being called "done."

This is slower per-report than a bulk automated port would be, but it means every report that reaches
"live-verified" status in this document set has actually been proven correct against real data — not
just reviewed for syntax.

## What's already migrated

See [AccountReports_Catalog.md](AccountReports_Catalog.md) for the full list and detail. In short,
as of 2026-08-01:

- **Account Register** and **Account Register Summary** — the flat voucher-by-voucher and
  grouped-by-account register views.
- **Account Ledger** (Statement of Account) and **Account Ledger Summary** — per-account running
  balance and opening/closing rollup.
- **Outstanding Detail** and **Outstanding Summary** — what's currently owed to/by each account,
  as of any date (not just "right now").
- **Ageing Detail** and **Ageing Summary** — the same outstanding balances broken into
  configurable age buckets (15/30/45/60/75 days by default).
- **Settlement Register** and **Settlement Register With Rate** — the audit trail of how each bill
  was actually settled (advance, against, batch, etc.), with a currency-enriched variant.
- **Collection/Payment Projection** — for each account, how fast money has historically been
  collected (receivables) or paid out (payables), projected forward against the current
  outstanding balance, plus any early-payment cash-discount benefit still available.

## What's coming, and what's genuinely new

Some legacy reports haven't been migrated yet (payment-performance detail beyond the projection
already built, balance confirmation letters, vendor ageing variants, unbilled reports, and a few
others). Some things the business has asked for **don't exist in legacy at all** and will be built
as new services using the same architecture and the same rigor — for example, reminders/dunning
letters and bill-count/days-based credit checking were identified as real gaps during this work,
not oversights in the migration.

Payment-terms-based bill splitting (creating multiple due-date instalments for one bill) is a
related but **separate** piece of work that happens when a transaction is saved, not something these
reporting endpoints do — the reports are built to correctly read and display whatever
already-split bill records exist, whichever module created them.

## How to read the rest of this document set

- If you just want to know what a specific report does and how to turn it on for a client, go to
  [AccountReports_Catalog.md](AccountReports_Catalog.md) and find that report's entry.
- If you're setting up GB5 for a client and need to know what menu/permission work is involved, go
  to [AccountReports_AdminConfigGuide.md](AccountReports_AdminConfigGuide.md).
- If you're a developer picking up the next report on the list, go to
  [AccountReports_DeveloperPlaybook.md](AccountReports_DeveloperPlaybook.md) — it walks through the
  exact process, with the reasoning behind each step, so you don't have to rediscover it.
