feat(core+cli): PDF report generation (balance sheet, income statement, net worth)#260
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
corefeature:ldgr-core(pure, WASM-safe, no new dependencies): a newaccounting::report_documentmodule adds a layout-agnostic, serializable model —ReportDocument → ReportSection → ReportRow, with per-commodityAmounts carryingrust_decimal::Decimal. Convertersbalance_sheet_document,income_statement_document, andnet_worth_documentturn 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 newrender::pdfmodule turns aReportDocumentinto PDF bytes usingpdf-writerwith 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
ldgr export --format pdf --report <balancesheet|incomestatement|networth> --output <file> [query...]. The period subtitle is derived fromdate:/begin:/end:query filters.exportcommand also gains an--outputflag so CSV/JSON/hledger output can be written to a file instead of stdout.pdf-writeris added to the CLI crate only. Verified it is absent fromldgr-core's dependency tree and thatcargo build -p ldgr-core --target wasm32-unknown-unknown --no-default-features --features core,syncstill compiles, so the CI bundle-size budget is unaffected.Related Issues
Closes #223
Type of Change
Component
crates/ldgr-core/— Core library (crypto, accounting, storage)crates/ldgr-cli/— CLI toolcrates/ldgr-server/— Sync serverbindings/swift/— UniFFI Swift bindingsapps/ios/— iOS / iPadOS / watchOS appapps/web/— Web app (Next.js + WASM)docs/— DocumentationPrivacy Checklist
Checklist
cargo test --workspace)cargo clippy --workspace -- -D warnings)cargo fmt --check)