output fixes, match ledger output for reg/bal/print commands

This commit is contained in:
Simon Michael 2007-07-07 09:05:35 +00:00
parent b5087b88c5
commit 3ca6ebdf46
3 changed files with 16 additions and 13 deletions

View File

@ -39,29 +39,29 @@ autofillEntry e =
-- account name 1..................... ...$amount1[ ; comment...............]
-- account name 2..................... ..$-amount1[ ; comment...............]
--
-- codewidth = 10
-- descwidth = 20
-- acctwidth = 35
-- amtwidth = 11
-- commentwidth = 22
-- pcodewidth = no limit -- 10
-- pdescwidth = no limit -- 20
-- pacctwidth = 35 minimum, no maximum
-- pamtwidth = 11
-- pcommentwidth = no limit -- 22
showEntry :: LedgerEntry -> String
showEntry e =
unlines $ ["", description] ++ (showtxns $ etransactions e)
where
description = concat [date, status, code, desc, comment]
description = concat [date, status, code, desc] -- , comment]
date = showDate $ edate e
status = if estatus e then " *" else ""
code = if (length $ ecode e) > 0 then (printf " (%s)" $ ecode e) else ""
desc = " " ++ (elideRight 20 $ edescription e)
desc = " " ++ edescription e
comment = if (length $ ecomment e) > 0 then " ; "++(ecomment e) else ""
showtxns (t1:t2:[]) = [showtxn t1, showtxnnoamt t2]
showtxns ts = map showtxn ts
showtxn t = showacct t ++ " " ++ (showamount $ tamount t) ++ (showcomment $ tcomment t)
showtxnnoamt t = showacct t ++ " " ++ (showcomment $ tcomment t)
showtxnnoamt t = showacct t ++ " " ++ (showcomment $ tcomment t)
showacct t = " " ++ (showaccountname $ taccount t)
showamount = printf "%11s" . showAmountRounded
showaccountname = printf "%-35s" . elideRight 35
showamount = printf "%12s" . showAmountRounded
showaccountname s = printf "%-34s" s
showcomment s = if (length s) > 0 then " ; "++s else ""
showEntries :: [LedgerEntry] -> String

View File

@ -9,10 +9,10 @@ import Amount
instance Show LedgerTransaction where show = showLedgerTransaction
showLedgerTransaction :: LedgerTransaction -> String
showLedgerTransaction t = (showaccountname $ taccount t) ++ " " ++ (showamount $ tamount t)
showLedgerTransaction t = (showaccountname $ taccount t) ++ " " ++ (showamount $ tamount t)
where
showaccountname = printf "%-22s" . elideRight 22
showamount = printf "%11s" . showAmountRoundedOrZero
showamount = printf "%12s" . showAmountRoundedOrZero
elideRight width s =
case length s > width of

View File

@ -195,7 +195,10 @@ ledgerentry = do
date <- ledgerdate
status <- ledgerstatus
code <- ledgercode
description <- many (noneOf ";\n") <?> "description"
-- ledger treats entry comments as part of the description, we too for now
-- desc <- many (noneOf ";\n") <?> "description"
-- let description = reverse $ dropWhile (==' ') $ reverse desc
description <- many (noneOf "\n") <?> "description"
comment <- ledgercomment
restofline
transactions <- ledgertransactions