another balance report test, another step closer
This commit is contained in:
parent
a64d320c84
commit
b9b9ce7d51
@ -93,9 +93,10 @@ Some notes for the implementation:
|
|||||||
- zero-balance leaf accounts are removed
|
- zero-balance leaf accounts are removed
|
||||||
|
|
||||||
- the resulting account tree is displayed with each account's aggregated
|
- the resulting account tree is displayed with each account's aggregated
|
||||||
balance, with boring parents prefixed to the next line. A boring parent
|
balance, with boring parents prefixed to the next line
|
||||||
has the same balance as its single child and is not explicitly matched
|
|
||||||
by the display options.
|
- a boring parent has the same balance as its child and is not explicitly
|
||||||
|
matched by the display options.
|
||||||
|
|
||||||
- the sum of the balances shown is displayed at the end, if it is non-zero
|
- the sum of the balances shown is displayed at the end, if it is non-zero
|
||||||
|
|
||||||
@ -177,7 +178,7 @@ showAccountTreeWithBalances matchedacctnames =
|
|||||||
showbal = printf "%20s" $ show bal
|
showbal = printf "%20s" $ show bal
|
||||||
indent = replicate (indentlevel * 2) ' '
|
indent = replicate (indentlevel * 2) ' '
|
||||||
leafname = accountLeafName fullname
|
leafname = accountLeafName fullname
|
||||||
isboringparent = numsubs == 1 && (bal == subbal || not matched)
|
|
||||||
numsubs = length subs
|
numsubs = length subs
|
||||||
subbal = abalance $ root $ head subs
|
subbal = abalance $ root $ head subs
|
||||||
matched = fullname `elem` matchedacctnames
|
matched = fullname `elem` matchedacctnames
|
||||||
|
isboringparent = numsubs >= 1 && (bal == subbal || not matched)
|
||||||
|
|||||||
12
Tests.hs
12
Tests.hs
@ -182,6 +182,18 @@ balancecommandtests =
|
|||||||
\ $1 liabilities:debts\n\
|
\ $1 liabilities:debts\n\
|
||||||
\" --"
|
\" --"
|
||||||
(balancereport [] ["e"] l)
|
(balancereport [] ["e"] l)
|
||||||
|
,
|
||||||
|
|
||||||
|
"balance report with unmatched parent of two matched subaccounts" ~: do
|
||||||
|
rl <- rawledgerfromfile "sample.ledger"
|
||||||
|
let l = cacheLedger (regexFor ["cash","saving"]) $ filterRawLedgerEntries "" "" wildcard rl
|
||||||
|
assertequal
|
||||||
|
" $-2 assets:cash\n\
|
||||||
|
\ $1 assets:saving\n\
|
||||||
|
\--------------------\n\
|
||||||
|
\ $-1\n\
|
||||||
|
\" --"
|
||||||
|
(balancereport [] ["cash","saving"] l)
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | Assert a parsed thing equals some expected thing, or print a parse error.
|
-- | Assert a parsed thing equals some expected thing, or print a parse error.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user