From 4a1b029863e850975e547e481cbb972d54f92357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sun, 27 Sep 2026 11:58:35 +0200 Subject: [PATCH] Render account trees with separate lines per account --- README.md | 6 +- .../components/hledger-dashboard.gjs | 13 +- assets/stylesheets/hledger.scss | 58 ++--- lib/hledger/account_tree.rb | 66 ++++++ lib/hledger/report_builder.rb | 152 ++++++------- spec/fixtures/balance_sheet.csv | 8 - spec/fixtures/balance_sheet.json | 104 +++++++++ spec/fixtures/income_statement.csv | 9 - spec/fixtures/income_statement.json | 127 +++++++++++ spec/lib/hledger/account_tree_spec.rb | 69 ++++++ spec/lib/hledger/integration_spec.rb | 21 ++ spec/lib/hledger/report_builder_spec.rb | 31 ++- spec/requests/hledger/reports_spec.rb | 12 +- test/javascripts/acceptance/hledger-test.js | 207 +++++++++++++++++- 14 files changed, 743 insertions(+), 140 deletions(-) create mode 100644 lib/hledger/account_tree.rb delete mode 100644 spec/fixtures/balance_sheet.csv create mode 100644 spec/fixtures/balance_sheet.json delete mode 100644 spec/fixtures/income_statement.csv create mode 100644 spec/fixtures/income_statement.json create mode 100644 spec/lib/hledger/account_tree_spec.rb diff --git a/README.md b/README.md index 24d1531..8566536 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Put an hledger journal in a fenced `hledger` code block in a topic's first post. The block is replaced by a dashboard with four reports, generated live by the `hledger` command line tool: -- Accounts and balances -- Balance sheet -- Income statement +- Accounts and balances (a full account tree, each name capitalized) +- Balance sheet (indented account tree under each section) +- Income statement (indented account tree under each section) - Equity distribution (contributed capital, not legal ownership) ## Installation diff --git a/assets/javascripts/discourse/components/hledger-dashboard.gjs b/assets/javascripts/discourse/components/hledger-dashboard.gjs index 0353a21..2cd1847 100644 --- a/assets/javascripts/discourse/components/hledger-dashboard.gjs +++ b/assets/javascripts/discourse/components/hledger-dashboard.gjs @@ -7,6 +7,7 @@ import { eq } from "discourse/truth-helpers"; import DButton from "discourse/ui-kit/d-button"; import DConditionalLoadingSpinner from "discourse/ui-kit/d-conditional-loading-spinner"; import DDatePicker from "discourse/ui-kit/d-date-picker"; +import dConcatClass from "discourse/ui-kit/helpers/d-concat-class"; import { i18n } from "discourse-i18n"; const REPORT_IDS = ["accounts", "balance_sheet", "income_statement", "equity"]; @@ -118,7 +119,7 @@ export default class HledgerDashboard extends Component { } depthClass(depth) { - return `hledger-dashboard__account--depth-${Math.min(depth || 0, 5)}`; + return `--depth-${Math.min(depth || 0, 3)}`; }