remove dead code, rename function

This commit is contained in:
Simon Michael 2008-10-10 12:04:20 +00:00
parent a30154b401
commit 9dc9c9dd76
2 changed files with 6 additions and 12 deletions

View File

@ -131,19 +131,13 @@ showLedgerAccountBalances l maxdepth =
then "" then ""
else printf "--------------------\n%20s\n" $ showAmountRounded total else printf "--------------------\n%20s\n" $ showAmountRounded total
where where
acctbranches = branches $ pruneBoringBranches $ ledgerAccountTree maxdepth l acctbranches = branches $ pruneZeroBalanceBranches $ ledgerAccountTree maxdepth l
filteredacctbranches = branches $ ledgerFilteredAccountTree maxdepth (acctpat l) l filteredacctbranches = branches $ ledgerFilteredAccountTree maxdepth (acctpat l) l
total = sum $ map (abalance . root) filteredacctbranches total = sum $ map (abalance . root) filteredacctbranches
-- | Remove boring branches and leaves from a tree of accounts. -- | Remove all-zero-balance branches and leaves from a tree of accounts.
-- A boring branch contains only accounts which have a 0 balance. pruneZeroBalanceBranches :: Tree Account -> Tree Account
pruneBoringBranches :: Tree Account -> Tree Account pruneZeroBalanceBranches = treefilter (not . isZeroAmount . abalance)
pruneBoringBranches =
-- treefilter hastxns .
treefilter hasbalance
where
hasbalance = not . isZeroAmount . abalance
hastxns = (> 0) . length . atransactions
-- | Get the string representation of a tree of accounts. -- | Get the string representation of a tree of accounts.
-- The ledger from which the accounts come is required so that -- The ledger from which the accounts come is required so that

View File

@ -93,10 +93,10 @@ tests =
assertparseequal (Amount (getcurrency "$") 47.18 2) (parsewith ledgeramount " $47.18") assertparseequal (Amount (getcurrency "$") 47.18 2) (parsewith ledgeramount " $47.18")
assertparseequal (Amount (getcurrency "$") 1 0) (parsewith ledgeramount " $1.") assertparseequal (Amount (getcurrency "$") 1 0) (parsewith ledgeramount " $1.")
,"pruneBoringBranches" ~: do ,"pruneZeroBalanceBranches" ~: do
atree <- liftM (ledgerAccountTree 99) $ ledgerfromfile "sample.ledger" atree <- liftM (ledgerAccountTree 99) $ ledgerfromfile "sample.ledger"
assertequal 13 (length $ flatten $ atree) assertequal 13 (length $ flatten $ atree)
assertequal 12 (length $ flatten $ pruneBoringBranches $ atree) assertequal 12 (length $ flatten $ pruneZeroBalanceBranches $ atree)
] ]
balancecommandtests = balancecommandtests =