diff --git a/Ledger.hs b/Ledger.hs index 9c3bab131..85dad880e 100644 --- a/Ledger.hs +++ b/Ledger.hs @@ -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 diff --git a/hledger.hs b/hledger.hs index f8ae36784..d641c6d97 100644 --- a/hledger.hs +++ b/hledger.hs @@ -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