Generic double-entry ledger read-only report routers (register, GL, trial balance, income statement, balance sheet, search) over the domain-ledger schema.
| Tier | application |
| Role | unclassified (baselined) |
| Path | crates/application/ledger-reports |
| Edition | 2021 |
| Targets | application_ledger_reports |
| Public items | 2 across 0 modules |
| Tests | 13 |
What it is for
Generic double-entry ledger reports: read-only API routers computed over the domain-ledger schema (accounts / journal_entries / line_items).
Lifted from the books app (server/src/ledger_reports.rs). All endpoints are gated by application_rbac::authz::UserPermissions::has(PERM_READ) and operate over posted entries only, signing balances by account_type (debit-normal = asset/expense; credit-normal = liability/equity/ income) — no normal_side column required. Mount router under whatever admin/auth prefix injects the UserPermissions extension.
Endpoints (relative paths)
GET /ledger/accounts/:code?from=&to=— per-account register / drill-down
with a DB-side running balance and an optional opening balance-forward.
GET /ledger/reports/general-ledger?from=&to=&account=— all posted lines
grouped by account with per-account running balances + subtotals.
GET /ledger/reports/trial-balance?as_of=— as-of signed balances placed in
their natural debit/credit columns, with a balanced check.
GET /ledger/reports/income-statement?from=&to=— income/expense period
totals + net income.
GET /ledger/reports/balance-sheet?as_of=— assets/liabilities/equity with
a synthetic "Net income (unclosed)" equity line so the sheet ties mid-year.
GET /ledger/search?q=&from=&to=&account=&dir=&limit=— global transaction
search over posted lines (ILIKE on description and journal_entries.payee).
Schema note: journal_entries.payee
search filters and returns journal_entries.payee (a standard generic ledger concept). The base ledger migration (crates/domain/ledger/migrations/001_ledger_tables.sql) declares it as a plain nullable text column; consumers get it for free.
Capabilities
crate root
Generic double-entry ledger reports: read-only API routers computed over the
| Item |
|---|
pub const PERM_READ: & str |
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub const PERM_READ: & str | Permission code required by every endpoint in this crate. |
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, | Build the ledger-reports sub-router |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, … (120 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | application |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/application/ledger-reports |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-rbac` | application | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
axum | ^0.7 | multipart | no | always |
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development. None.
Build. None.
Depended on by. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["application-ledger-reports"] SELF -->|runtime| n_application_rbac["application-rbac"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | application_ledger_reports | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | yes |
| network I/O | yes |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 13 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 2 | 0 | 0 |
What the tests establish, by name:
credit_normal_for_liability_equity_income—src/lib.rscurrency_exponent_known_and_default—src/lib.rsdebit_normal_for_asset_and_expense—src/lib.rsis_contra_only_1510—src/lib.rssigned_contra_asset_credit_carried_reads_negative—src/lib.rssigned_credit_normal_credit_increases_debit_decreases—src/lib.rssigned_debit_normal_debit_increases_credit_decreases—src/lib.rstb_columns_preserve_a_balanced_set—src/lib.rstb_contra_asset_credit_balance_flips_to_credit_column—src/lib.rstb_credit_normal_positive_lands_in_credit—src/lib.rstb_debit_normal_positive_lands_in_debit—src/lib.rstb_owner_draw_debit_balance_flips_to_debit_column—src/lib.rstb_zero_balance_is_zero_in_both_columns—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 2 | 2 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 2
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 1212 |
| Code lines | 963 |
| Public API items | 2 |
| Public modules | 0 |
| Tests | 13 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 7 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"constant" : 1
"function" : 1
pie showData
title Rust source composition
"Code" : 963
"Blank or comment" : 249
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.