From 528913d1bd02ebff9760a2b2f3f104c691af593f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 17 Jul 2014 15:18:40 -0700 Subject: [PATCH] balance: -E adds all starting accounts to multicol rpts multicolumn balance reports only show accounts with activity (postings) during the report period, by default. Sometimes you want to show accounts which have an interesting balance, even if they have no activity during the period. -E now does this, in addition to showing leading & trailing empty columns. --- .../Hledger/Reports/MultiBalanceReports.hs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReports.hs b/hledger-lib/Hledger/Reports/MultiBalanceReports.hs index e15b8b09b..773ea6d96 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReports.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReports.hs @@ -114,14 +114,23 @@ multiBalanceReport opts q j = MultiBalanceReport (displayspans, items, totals) | tree_ opts = filter ((depthq `matchesAccount`).aname) -- exclude deeper balances | otherwise = clipAccountsAndAggregate depth -- aggregate deeper balances at the depth limit - postedAccts :: [AccountName] = - dbg "postedAccts" $ - sort $ accountNamesFromPostings ps + postedAccts :: [AccountName] = dbg "postedAccts" $ sort $ accountNamesFromPostings ps + + -- starting balances and accounts from transactions before the report start date + startacctbals = dbg "startacctbals" $ map (\((a,_,_),b) -> (a,b)) startbalanceitems + where + (startbalanceitems,_) = dbg "starting balance report" $ balanceReport opts' precedingq j + where + opts' | tree_ opts = opts{no_elide_=True} + | otherwise = opts{flat_=True} + startingBalanceFor a = fromMaybe nullmixedamt $ lookup a startacctbals + startAccts = dbg "startAccts" $ map fst startacctbals displayedAccts :: [ClippedAccountName] = dbg "displayedAccts" $ (if tree_ opts then expandAccountNames else id) $ - nub $ map (clipAccountName depth) postedAccts + nub $ map (clipAccountName depth) $ + if empty_ opts then nub $ sort $ startAccts ++ postedAccts else postedAccts acctBalChangesPerSpan :: [[(ClippedAccountName, MixedAmount)]] = dbg "acctBalChangesPerSpan" $ @@ -133,15 +142,6 @@ multiBalanceReport opts q j = MultiBalanceReport (displayspans, items, totals) dbg "acctBalChanges" $ [(a, map snd abs) | abs@((a,_):_) <- transpose acctBalChangesPerSpan] -- never null, or used when null... - -- starting balances and accounts from transactions before the report start date - startacctbals = dbg "startacctbals" $ map (\((a,_,_),b) -> (a,b)) $ startbalanceitems - where - (startbalanceitems,_) = dbg "starting balance report" $ balanceReport opts' precedingq j - where - opts' | tree_ opts = opts{no_elide_=True} - | otherwise = opts{flat_=True} - startingBalanceFor a = fromMaybe nullmixedamt $ lookup a startacctbals - items :: [MultiBalanceReportRow] = dbg "items" $ [((a, accountLeafName a, accountNameLevel a), displayedBals)