From 11c64268341e1922d43ae40ebc6aa0e437f07e4d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 8 Aug 2016 17:50:26 -0700 Subject: [PATCH] ui: show historical balances whenever possible #392 hledger-ui now tries to show historical balances always, including when (to limit transactions on the register screen) a report start date is specified. This means that: - the accounts screen balances are not disturbed by a start date - the register screen is now a little better at showing the running historical balance. It's still not very good at it; some filter queries will cause it to fall back to showing the running total of visible transactions. But it's no longer disturbed by Z (nonzero mode) or a cur: query term. --- hledger-ui/Hledger/UI/AccountsScreen.hs | 7 ++----- hledger-ui/Hledger/UI/Main.hs | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hledger-ui/Hledger/UI/AccountsScreen.hs b/hledger-ui/Hledger/UI/AccountsScreen.hs index cb416381c..bdb821559 100644 --- a/hledger-ui/Hledger/UI/AccountsScreen.hs +++ b/hledger-ui/Hledger/UI/AccountsScreen.hs @@ -68,10 +68,7 @@ asInit d reset ui@UIState{ mexactmatch = findIndex ((a ==) . asItemAccountName) displayitems mprefixmatch = findIndex ((a `isAccountNamePrefixOf`) . asItemAccountName) displayitems uopts' = uopts{cliopts_=copts{reportopts_=ropts'}} - ropts' = ropts { - -- XXX balanceReport doesn't respect this yet - balancetype_=HistoricalBalance - } + ropts' = ropts{accountlistmode_=if flat_ ropts then ALFlat else ALTree} q = queryFromOpts d ropts @@ -82,7 +79,7 @@ asInit d reset ui@UIState{ valuedate = fromMaybe d $ queryEndDate False q -- run the report - (items,_total) = convert $ balanceReport ropts' q j + (items,_total) = convert $ singleBalanceReport ropts' q j -- pre-render the list items displayitem (fullacct, shortacct, indent, bal) = diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index 895ca5fe8..44fcf30e0 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -84,7 +84,9 @@ runBrickUi uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} j = do -- show items with zero amount by default, unlike the CLI empty_=True, -- always disable boring account name eliding, unlike the CLI, for a more regular tree - no_elide_=True + no_elide_=True, + -- always show historical balances, regardless of report start date + balancetype_=HistoricalBalance } } }