mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
output fixes, match ledger output for reg/bal/print commands
This commit is contained in:
parent
b5087b88c5
commit
3ca6ebdf46
@ -39,29 +39,29 @@ autofillEntry e =
|
|||||||
-- account name 1..................... ...$amount1[ ; comment...............]
|
-- account name 1..................... ...$amount1[ ; comment...............]
|
||||||
-- account name 2..................... ..$-amount1[ ; comment...............]
|
-- account name 2..................... ..$-amount1[ ; comment...............]
|
||||||
--
|
--
|
||||||
-- codewidth = 10
|
-- pcodewidth = no limit -- 10
|
||||||
-- descwidth = 20
|
-- pdescwidth = no limit -- 20
|
||||||
-- acctwidth = 35
|
-- pacctwidth = 35 minimum, no maximum
|
||||||
-- amtwidth = 11
|
-- pamtwidth = 11
|
||||||
-- commentwidth = 22
|
-- pcommentwidth = no limit -- 22
|
||||||
|
|
||||||
showEntry :: LedgerEntry -> String
|
showEntry :: LedgerEntry -> String
|
||||||
showEntry e =
|
showEntry e =
|
||||||
unlines $ ["", description] ++ (showtxns $ etransactions e)
|
unlines $ ["", description] ++ (showtxns $ etransactions e)
|
||||||
where
|
where
|
||||||
description = concat [date, status, code, desc, comment]
|
description = concat [date, status, code, desc] -- , comment]
|
||||||
date = showDate $ edate e
|
date = showDate $ edate e
|
||||||
status = if estatus e then " *" else ""
|
status = if estatus e then " *" else ""
|
||||||
code = if (length $ ecode e) > 0 then (printf " (%s)" $ ecode e) 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 ""
|
comment = if (length $ ecomment e) > 0 then " ; "++(ecomment e) else ""
|
||||||
showtxns (t1:t2:[]) = [showtxn t1, showtxnnoamt t2]
|
showtxns (t1:t2:[]) = [showtxn t1, showtxnnoamt t2]
|
||||||
showtxns ts = map showtxn ts
|
showtxns ts = map showtxn ts
|
||||||
showtxn t = showacct t ++ " " ++ (showamount $ tamount t) ++ (showcomment $ tcomment t)
|
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)
|
showacct t = " " ++ (showaccountname $ taccount t)
|
||||||
showamount = printf "%11s" . showAmountRounded
|
showamount = printf "%12s" . showAmountRounded
|
||||||
showaccountname = printf "%-35s" . elideRight 35
|
showaccountname s = printf "%-34s" s
|
||||||
showcomment s = if (length s) > 0 then " ; "++s else ""
|
showcomment s = if (length s) > 0 then " ; "++s else ""
|
||||||
|
|
||||||
showEntries :: [LedgerEntry] -> String
|
showEntries :: [LedgerEntry] -> String
|
||||||
|
@ -9,10 +9,10 @@ import Amount
|
|||||||
instance Show LedgerTransaction where show = showLedgerTransaction
|
instance Show LedgerTransaction where show = showLedgerTransaction
|
||||||
|
|
||||||
showLedgerTransaction :: LedgerTransaction -> String
|
showLedgerTransaction :: LedgerTransaction -> String
|
||||||
showLedgerTransaction t = (showaccountname $ taccount t) ++ " " ++ (showamount $ tamount t)
|
showLedgerTransaction t = (showaccountname $ taccount t) ++ " " ++ (showamount $ tamount t)
|
||||||
where
|
where
|
||||||
showaccountname = printf "%-22s" . elideRight 22
|
showaccountname = printf "%-22s" . elideRight 22
|
||||||
showamount = printf "%11s" . showAmountRoundedOrZero
|
showamount = printf "%12s" . showAmountRoundedOrZero
|
||||||
|
|
||||||
elideRight width s =
|
elideRight width s =
|
||||||
case length s > width of
|
case length s > width of
|
||||||
|
5
Parse.hs
5
Parse.hs
@ -195,7 +195,10 @@ ledgerentry = do
|
|||||||
date <- ledgerdate
|
date <- ledgerdate
|
||||||
status <- ledgerstatus
|
status <- ledgerstatus
|
||||||
code <- ledgercode
|
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
|
comment <- ledgercomment
|
||||||
restofline
|
restofline
|
||||||
transactions <- ledgertransactions
|
transactions <- ledgertransactions
|
||||||
|
Loading…
Reference in New Issue
Block a user