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 AccountName
|
||||||
import Transaction
|
import Transaction
|
||||||
import RawLedger
|
import RawLedger
|
||||||
|
import LedgerEntry
|
||||||
|
|
||||||
|
|
||||||
rawLedgerTransactions :: RawLedger -> [Transaction]
|
rawLedgerTransactions :: RawLedger -> [Transaction]
|
||||||
@ -116,6 +117,16 @@ ledgerAccountTree l depth =
|
|||||||
addDataToAccountNameTree :: Ledger -> Tree AccountName -> Tree Account
|
addDataToAccountNameTree :: Ledger -> Tree AccountName -> Tree Account
|
||||||
addDataToAccountNameTree = treemap . ledgerAccount
|
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
|
This and the functions below help generate ledger-compatible balance
|
||||||
|
|||||||
@ -76,18 +76,9 @@ selftest opts pats = do
|
|||||||
print_ :: Command
|
print_ :: Command
|
||||||
print_ opts pats = parseLedgerAndDo opts pats printentries
|
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 :: Command
|
||||||
register opts pats = parseLedgerAndDo opts pats printregister
|
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 :: Command
|
||||||
balance opts pats = do
|
balance opts pats = do
|
||||||
parseLedgerAndDo opts pats printbalance
|
parseLedgerAndDo opts pats printbalance
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user