move printentries/printregister to Ledger

This commit is contained in:
Simon Michael 2008-10-02 23:00:11 +00:00
parent 8045799664
commit 2ee9a341be
2 changed files with 11 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import Account
import AccountName
import Transaction
import RawLedger
import LedgerEntry
rawLedgerTransactions :: RawLedger -> [Transaction]
@ -116,6 +117,16 @@ ledgerAccountTree l depth =
addDataToAccountNameTree :: Ledger -> Tree AccountName -> Tree Account
addDataToAccountNameTree = treemap . ledgerAccount
-- | for the print command
printentries :: Ledger -> IO ()
printentries l = putStr $ showEntries $ setprecisions $ entries $ rawledger l
where setprecisions = map (entrySetPrecision (lprecision l))
-- | for the register command
printregister :: Ledger -> IO ()
printregister l = putStr $ showTransactionsWithBalances
(sortBy (comparing date) $ ledgerTransactions l)
nullamt{precision=lprecision l}
{-|
This and the functions below help generate ledger-compatible balance

View File

@ -76,18 +76,9 @@ selftest opts pats = do
print_ :: Command
print_ opts pats = parseLedgerAndDo opts pats printentries
printentries :: Ledger -> IO ()
printentries l = putStr $ showEntries $ setprecisions $ entries $ rawledger l
where setprecisions = map (entrySetPrecision (lprecision l))
register :: Command
register opts pats = parseLedgerAndDo opts pats printregister
printregister :: Ledger -> IO ()
printregister l = putStr $ showTransactionsWithBalances
(sortBy (comparing date) $ ledgerTransactions l)
nullamt{precision=lprecision l}
balance :: Command
balance opts pats = do
parseLedgerAndDo opts pats printbalance