Skip to content

feat(core+cli): PDF report generation (balance sheet, income statement, net worth)#260

Merged
kafkade merged 2 commits into
mainfrom
kafkade-feat-pdf-report-generation
Jul 5, 2026
Merged

feat(core+cli): PDF report generation (balance sheet, income statement, net worth)#260
kafkade merged 2 commits into
mainfrom
kafkade-feat-pdf-report-generation

Conversation

@kafkade

@kafkade kafkade commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Description

Adds PDF export for the balance sheet, income statement, and net worth reports.

The work is split along the platform boundary so no heavy PDF dependency reaches the WASM core feature:

  • ldgr-core (pure, WASM-safe, no new dependencies): a new accounting::report_document module adds a layout-agnostic, serializable model — ReportDocument → ReportSection → ReportRow, with per-commodity Amounts carrying rust_decimal::Decimal. Converters balance_sheet_document, income_statement_document, and net_worth_document turn the existing computed reports into this presentation-neutral model, which future web/iOS export paths can reuse. Commodity-less zero entries (from elided postings) are suppressed.
  • ldgr-cli (allowed I/O): a new render::pdf module turns a ReportDocument into PDF bytes using pdf-writer with the built-in Standard-14 (base-14) fonts — Helvetica for labels/headings, Courier for the right-aligned amount column so widths are measurable without a font-metrics table. No font files are bundled. It handles pagination, a title/period header, an indented account hierarchy, emphasized totals, and a page footer.

What's included

  • New CLI usage: ldgr export --format pdf --report <balancesheet|incomestatement|networth> --output <file> [query...]. The period subtitle is derived from date:/begin:/end: query filters.
  • The export command also gains an --output flag so CSV/JSON/hledger output can be written to a file instead of stdout.
  • Multi-currency amounts are grouped per commodity; decimal values render exactly (no floats).
  • pdf-writer is added to the CLI crate only. Verified it is absent from ldgr-core's dependency tree and that cargo build -p ldgr-core --target wasm32-unknown-unknown --no-default-features --features core,sync still compiles, so the CI bundle-size budget is unaffected.
  • README (usage examples + command table) and roadmap updated.

Related Issues

Closes #223

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Refactoring (no functional changes)
  • CI / infrastructure
  • Other (describe below)

Component

  • crates/ldgr-core/ — Core library (crypto, accounting, storage)
  • crates/ldgr-cli/ — CLI tool
  • crates/ldgr-server/ — Sync server
  • bindings/swift/ — UniFFI Swift bindings
  • apps/ios/ — iOS / iPadOS / watchOS app
  • apps/web/ — Web app (Next.js + WASM)
  • docs/ — Documentation

Privacy Checklist

  • No plaintext financial data is sent to or stored on the server — PDF is generated locally in the CLI from the already-unlocked vault; nothing is sent anywhere
  • No new metadata exposure introduced (or documented if unavoidable)
  • Any new external service interaction is documented in the trust boundary model — N/A, no external service interaction
  • Crypto changes use audited RustCrypto crates — no custom primitives — N/A, no crypto changes
  • Key material is never exposed in error messages, logs, or Debug output

Checklist

  • I have read CONTRIBUTING.md
  • Tests pass (cargo test --workspace)
  • Clippy passes (cargo clippy --workspace -- -D warnings)
  • Formatting passes (cargo fmt --check)
  • I have updated documentation (if applicable)

@kafkade kafkade enabled auto-merge (squash) July 5, 2026 04:26
@kafkade kafkade merged commit 485b3d1 into main Jul 5, 2026
14 checks passed
@kafkade kafkade deleted the kafkade-feat-pdf-report-generation branch July 5, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core+cli): PDF report generation (balance sheet, income statement, net worth)

1 participant