2008-10-10 07:32:12 +04:00
|
|
|
{-|
|
|
|
|
|
|
|
|
A ledger-compatible @print@ command.
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
2009-06-02 22:29:01 +04:00
|
|
|
module Commands.Print
|
2008-10-10 07:32:12 +04:00
|
|
|
where
|
2009-05-15 00:44:06 +04:00
|
|
|
import Prelude hiding (putStr)
|
2008-10-10 07:32:12 +04:00
|
|
|
import Ledger
|
|
|
|
import Options
|
2009-05-15 00:44:06 +04:00
|
|
|
import System.IO.UTF8
|
2008-10-10 07:32:12 +04:00
|
|
|
|
|
|
|
|
2009-04-03 14:58:05 +04:00
|
|
|
-- | Print ledger transactions in standard format.
|
2008-10-12 13:17:21 +04:00
|
|
|
print' :: [Opt] -> [String] -> Ledger -> IO ()
|
2009-04-03 14:58:05 +04:00
|
|
|
print' opts args l = putStr $ showLedgerTransactions opts args l
|
2008-10-12 13:17:21 +04:00
|
|
|
|
2009-04-03 14:58:05 +04:00
|
|
|
showLedgerTransactions :: [Opt] -> [String] -> Ledger -> String
|
|
|
|
showLedgerTransactions opts args l = concatMap showLedgerTransaction $ filteredtxns
|
2008-11-22 09:35:10 +03:00
|
|
|
where
|
2009-04-03 14:58:05 +04:00
|
|
|
filteredtxns = ledger_txns $
|
|
|
|
filterRawLedgerPostingsByDepth depth $
|
|
|
|
filterRawLedgerTransactionsByAccount apats $
|
2009-04-02 10:02:00 +04:00
|
|
|
rawledger l
|
|
|
|
depth = depthFromOpts opts
|
2009-04-04 13:14:04 +04:00
|
|
|
(apats,_) = parsePatternArgs args
|