mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-27 20:36:07 +03:00
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.
This commit is contained in:
parent
8aec855d04
commit
528913d1bd
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user