web: balance report page (#2242) - #2739
Conversation
…od balance reports as HTML pages Journal page contains links to those reports.
Cell classes and builtin stylesheet rules replace attribute styles. AI usage: Claude Opus 5, ~8k output tokens.
balanceReportAsSpreadsheetParts, allCommoditiesFromPeriodicReport, and multiBalanceReportTitle, for hledger-web. AI usage: Claude Opus 5, ~1k output tokens.
Render the report as the thead, tbody, and tfoot of a bootstrap table in a .table-responsive wrapper, styled by hledger.css. AI usage: Claude Opus 5, ~12k output tokens.
AI usage: Claude Opus 5, ~1k output tokens.
AI usage: Claude Opus 5, ~2k output tokens.
Only the interval was used, so "monthly in 2024" covered the whole journal and "2024" was unrestricted. A bad expression now shows an alert instead of running text. AI usage: Claude Opus 5, ~10k output tokens.
AI usage: Claude Opus 5, ~4k output tokens.
The links row moves to a shared widget, marks the current report, and gets per-interval titles. The heading is now the command line report's. The search form and its clear button keep the period parameter, on this page only (so far). AI usage: Claude Opus 5, ~14k output tokens.
Seven cases: the report and its register links, no inline styles, the multi-period report and the form keeping its period, the expression's date span, a depth: term, and a bad period expression. AI usage: Claude Opus 5, ~8k output tokens.
AI usage: Claude Opus 5, ~2k output tokens.
Keep it standalone until there are more such reports and a navigation scheme for them (hledgerorg#2242). The links between the balance reports stay. AI usage: Claude Opus 5, ~3k output tokens.
As on the command line, date:monthly sets the report interval and wins over the period parameter. Exports intervalFromQueryOpts. AI usage: Claude Opus 5, ~6k output tokens.
AI usage: Claude Opus 5, ~3k output tokens.
-E means the opposite here than on the command line: hide zero items, which are shown by default. The report took the command line sense, so a single -E made the sidebar hide zero accounts at the same moment the table started showing them. AI usage: Claude Opus 5, ~3k output tokens.
833d062 to
1f5aa8b
Compare
|
Should this be marked draft ? This todo list seems still in progress |
This is ready to go. This pr is the result of working through the to-do list. I do have a question about column, row and cell linking behavior, but I think the current implementation is acceptable and good for an upcoming release. |
|
It all sounds good to me, and looks good from my testing. And good enough to expose in the UI when you feel ready. I'll merge this soon if there are no objections. My main feedback: I wonder how to clearly distinguish end balance reports and balance change reports for users, in line with the "easy obvious UX" goal, and hledger's bs/is reports. Do hledger-web users need to see changes in ALE accounts, or end balances in RX accounts ? Should we just provide bs and is reports, or include the more general/advanced behaviour of the |
|
As a quick aid, it would be nice to be able to toggle historical mode (-H) on this. |
|
I'm guessing @thielema won't object to this PR, which continues his earlier work. Merging, thank you both! |
That's right. And
|
Builds on @thielema's
web-balance-reportbranch.Fourteen commits on top address the review comments on #2242 and what testing turned up.
/balanceserves the balance report. Account names andperiod headings link into the register (for now).
Two commits change the CLI's HTML output
forbids inline styles. Remove per-cell style attributes. Cells get class
border-{top,bottom,left,right}-{single,double}and the builtin stylesheetgets eight new rules. Both writers changed together, so lucid and blaze do
not drift apart here. Column headers get classes:
accountfor accounts,amountover figures. (web: send a Content-Security-Policy - The Robots are Coming! #2703)negativeclass on cells whose amount is negative.-O htmloutput has two changes: the border color now followsthe text color instead of being hardcoded black, and a single-period report's
account column picks up the builtin
th.account, td.accountrule it wasmissing, so that column sits flush left as it already does in a multi-period
report.
Other fixes
--depthat startup anddepth:in the search box were ignoredperiodexpression was used, so?period=monthly in 2024gave monthly columns over the whole journal, and?period=2024gave a single column of all-time totals. The date span nowrestricts the report as a
date:term would.date:term can set the interval too, as on the command line(
date:monthly), and wins over theperiodparameter.hledger.cssrather than by an inline<style>block, whose unscoped rules would also have restyled the sidebar. It is a
bootstrap table now, so it matches the journal and register pages.
periodparameter is kept by the search form on this page only (so far), and byits clear button, which used to drop you back to the single-period report.
luciddependency.-Ematches account sidebar behavior, which is the opposite of the CLI.-M,-Q,-p 'monthly in 2025'…) produced a single column of row totals instead of the periods it asks for. It now opens the multi-period report, and a period parameter still overrides it.--titlewas ignored — the heading was always "Balance Report". It is now the command line report's heading ("Balance changes in 2024-01-01..2026-12-31"), or--title's value verbatim when one is given.box with it: bootstrap's
.table-responsiveonly scrolls below 768px, so thewrapper carries a rule of our own, and the table scrolls inside the page.
The page is standalone for now
One commit removes the
/balancelinks from the journal page, so there are no linksto it in hledger-web. I think we should add all of the missing reports first and evaluate
them stand-alone before thinking about how to wire it all together.
Addresses @simonmichael's concern on #2242 about committing hledger-web to new
UI: nothing in the existing UI changes.
Open question: what should a column heading link to?
A period heading (
2024) links toregister?q=date:2024, fromHledger.Cli.Anchor. It should instead go to/balance?q=date:2024.The amount cells should probably become links too
(
register?q=inacct:<account> date:<period>), since they are unlinked todayand the heading is currently the only route from this page to the transactions
behind a period. That would give: row → the account's transactions, column →
that period's balances, cell → that account's transactions in that period.
It belongs in
Hledger.Cli.Anchorbut is not included here.How to test
Manual test plan: https://gist.github.com/acinader/e58e0445e6d517e153f93a5b685ae6e3.
It tests:
/balance?period=yearly— the table looks like the journal and register pages/balance?q=depth:1— as many rows as the sidebar/balance?period=2024— one column, holding 2024 only/balance?period=monthly%20in%202024— twelve columns/balance?q=date:monthly— the interval from the search box/balance?period=bogus— an alert, not a tablehledger bal -Y -O html | grep -c 'style="'— zeroCommits
imp: html:mark table borders with CSS classes instead of inline stylesdev: cli:export the balance report spreadsheet parts and titledev: web:style the table like the other pagesdev: web:drop the unused lucid dependency, regenerate the cabal filedev: web:honor the depth limitdev: web:apply the period expression, report a bad oneimp: lib:spreadsheet cells for negative amounts get a "negative" classdev: web:headings, report links, and the period parametertest: web:cover the balance pagedoc: web:describe the balance page and its period parameterdev: web:don't link to it from the journal page yetdev: web:take the interval from a date: search termfix: web:apply the journal's commodity display stylesfix: web:read -E the way the rest of hledger-web doesAI usage: Claude Opus 5, ~140k output tokens across the branch (the
per-commit estimates in the commit messages sum to ~77k; the rest went to
review, testing, and drafting that produced no commit).