fix the print command
This commit is contained in:
parent
1312992000
commit
1607661b87
@ -49,7 +49,7 @@ pcommentwidth = no limit -- 22
|
|||||||
-}
|
-}
|
||||||
showEntry :: Entry -> String
|
showEntry :: Entry -> String
|
||||||
showEntry e =
|
showEntry e =
|
||||||
unlines $ [precedingcomment ++ description] ++ (showtxns $ etransactions e) ++ [""]
|
unlines $ [{-precedingcomment ++ -}description] ++ (showtxns $ etransactions e) ++ [""]
|
||||||
where
|
where
|
||||||
precedingcomment = epreceding_comment_lines e
|
precedingcomment = epreceding_comment_lines e
|
||||||
description = concat [date, status, code, desc] -- , comment]
|
description = concat [date, status, code, desc] -- , comment]
|
||||||
|
|||||||
@ -50,7 +50,7 @@ filterRawLedger begin end pats clearedonly realonly =
|
|||||||
filterRawLedgerEntriesByDate begin end .
|
filterRawLedgerEntriesByDate begin end .
|
||||||
filterRawLedgerEntriesByDescription pats
|
filterRawLedgerEntriesByDescription pats
|
||||||
|
|
||||||
-- | Keep only entries whose description matches the description pattern.
|
-- | Keep only entries whose description matches the description patterns.
|
||||||
filterRawLedgerEntriesByDescription :: [String] -> RawLedger -> RawLedger
|
filterRawLedgerEntriesByDescription :: [String] -> RawLedger -> RawLedger
|
||||||
filterRawLedgerEntriesByDescription pats (RawLedger ms ps es f) =
|
filterRawLedgerEntriesByDescription pats (RawLedger ms ps es f) =
|
||||||
RawLedger ms ps (filter matchdesc es) f
|
RawLedger ms ps (filter matchdesc es) f
|
||||||
@ -80,6 +80,11 @@ filterRawLedgerTransactionsByRealness True (RawLedger ms ps es f) =
|
|||||||
RawLedger ms ps (map filtertxns es) f
|
RawLedger ms ps (map filtertxns es) f
|
||||||
where filtertxns e@Entry{etransactions=ts} = e{etransactions=filter isReal ts}
|
where filtertxns e@Entry{etransactions=ts} = e{etransactions=filter isReal ts}
|
||||||
|
|
||||||
|
-- | Keep only entries which affect accounts matched by the account patterns.
|
||||||
|
filterRawLedgerEntriesByAccount :: [String] -> RawLedger -> RawLedger
|
||||||
|
filterRawLedgerEntriesByAccount apats (RawLedger ms ps es f) =
|
||||||
|
RawLedger ms ps (filter (any (matchpats apats . taccount) . etransactions) es) f
|
||||||
|
|
||||||
-- | Give all a ledger's amounts their canonical display settings. That
|
-- | Give all a ledger's amounts their canonical display settings. That
|
||||||
-- is, in each commodity, amounts will use the display settings of the
|
-- is, in each commodity, amounts will use the display settings of the
|
||||||
-- first amount detected, and the greatest precision of the amounts
|
-- first amount detected, and the greatest precision of the amounts
|
||||||
|
|||||||
3
NOTES
3
NOTES
@ -6,8 +6,6 @@ implementations were its consequences." --Niklaus Wirth
|
|||||||
|
|
||||||
* to do
|
* to do
|
||||||
** errors
|
** errors
|
||||||
*** make account balances reflect account filtering
|
|
||||||
*** print command doesn't filter by account ?
|
|
||||||
*** ? in description or amount gives "too many blank transactions"
|
*** ? in description or amount gives "too many blank transactions"
|
||||||
*** parse commented lines at end of file
|
*** parse commented lines at end of file
|
||||||
*** display mixed amounts vertically, not horizontally
|
*** display mixed amounts vertically, not horizontally
|
||||||
@ -67,6 +65,7 @@ implementations were its consequences." --Niklaus Wirth
|
|||||||
*** ledger shows description comments as part of description
|
*** ledger shows description comments as part of description
|
||||||
*** ledger shows small time amounts in minutes
|
*** ledger shows small time amounts in minutes
|
||||||
*** ledger can get timelog entry balance wrong, see mail list
|
*** ledger can get timelog entry balance wrong, see mail list
|
||||||
|
*** hledger print puts a blank line after the entry, not before it
|
||||||
** things I want to know
|
** things I want to know
|
||||||
*** time
|
*** time
|
||||||
where have I been spending my time in recent weeks ?
|
where have I been spending my time in recent weeks ?
|
||||||
|
|||||||
@ -15,4 +15,7 @@ print' :: [Opt] -> [String] -> Ledger -> IO ()
|
|||||||
print' opts args l = putStr $ showEntries opts args l
|
print' opts args l = putStr $ showEntries opts args l
|
||||||
|
|
||||||
showEntries :: [Opt] -> [String] -> Ledger -> String
|
showEntries :: [Opt] -> [String] -> Ledger -> String
|
||||||
showEntries opts args l = concatMap showEntry $ entries $ rawledger l
|
showEntries opts args l = concatMap showEntry $ filteredentries
|
||||||
|
where
|
||||||
|
filteredentries = entries $ filterRawLedgerEntriesByAccount apats $ rawledger l
|
||||||
|
(apats,_) = parseAccountDescriptionArgs args
|
||||||
|
|||||||
15
Tests.hs
15
Tests.hs
@ -30,6 +30,7 @@ tests = [TestList []
|
|||||||
,misc_tests
|
,misc_tests
|
||||||
,balancereportacctnames_tests
|
,balancereportacctnames_tests
|
||||||
,balancecommand_tests
|
,balancecommand_tests
|
||||||
|
,printcommand_tests
|
||||||
,registercommand_tests
|
,registercommand_tests
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -271,6 +272,20 @@ balancecommand_tests = TestList [
|
|||||||
l <- ledgerfromfile pats "sample.ledger"
|
l <- ledgerfromfile pats "sample.ledger"
|
||||||
assertequal e (showBalanceReport opts pats l)
|
assertequal e (showBalanceReport opts pats l)
|
||||||
|
|
||||||
|
printcommand_tests = TestList [
|
||||||
|
"print with account patterns" ~:
|
||||||
|
do
|
||||||
|
let pats = ["expenses"]
|
||||||
|
l <- ledgerfromfile pats "sample.ledger"
|
||||||
|
assertequal (
|
||||||
|
"2007/01/01 * eat & shop\n" ++
|
||||||
|
" expenses:food $1\n" ++
|
||||||
|
" expenses:supplies $1\n" ++
|
||||||
|
" assets:cash $-2\n" ++
|
||||||
|
"\n")
|
||||||
|
$ showEntries [] pats l
|
||||||
|
]
|
||||||
|
|
||||||
registercommand_tests = TestList [
|
registercommand_tests = TestList [
|
||||||
"register report" ~:
|
"register report" ~:
|
||||||
do
|
do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user