mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-18 17:57:11 +03:00
move printentries/printregister to Ledger
This commit is contained in:
parent
8045799664
commit
2ee9a341be
11
Ledger.hs
11
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user