From 3ca6ebdf4634d0da00e4cd4b4b75773aab72e142 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 7 Jul 2007 09:05:35 +0000 Subject: [PATCH] output fixes, match ledger output for reg/bal/print commands --- LedgerEntry.hs | 20 ++++++++++---------- LedgerTransaction.hs | 4 ++-- Parse.hs | 5 ++++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/LedgerEntry.hs b/LedgerEntry.hs index fd45e7dfe..4187c630f 100644 --- a/LedgerEntry.hs +++ b/LedgerEntry.hs @@ -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 diff --git a/LedgerTransaction.hs b/LedgerTransaction.hs index 6a9fd07ec..5f281943e 100644 --- a/LedgerTransaction.hs +++ b/LedgerTransaction.hs @@ -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 diff --git a/Parse.hs b/Parse.hs index 64cbc4804..2c766f638 100644 --- a/Parse.hs +++ b/Parse.hs @@ -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