lib: clarify what postingsAsLines does (#931)

This commit is contained in:
Simon Michael 2018-11-29 13:32:59 -08:00
parent e06e300446
commit 6d0ee6a590

View File

@ -169,24 +169,22 @@ renderCommentLines t = case lines $ T.unpack t of ("":ls) -> "":map commentpref
commentprefix = indent . ("; "++) commentprefix = indent . ("; "++)
-- | Given a transaction and its postings, render the postings, suitable -- | Given a transaction and its postings, render the postings, suitable
-- for `print` output. -- for `print` output. Normally this output will be valid journal syntax which
-- hledger can reparse (though it may include no-longer-valid balance assertions).
-- --
-- Explicit amounts are shown, implicit amounts are not. -- Explicit amounts are shown, any implicit amounts are not.
-- If elide is true and there are multiple postings, all with explicit amounts,
-- and the transaction appears obviously balanced
-- (postings sum to 0, without needing to infer conversion prices),
-- the last posting's amount will be made implicit (and not shown).
-- --
-- The output will be parseable journal syntax. -- Setting elide to true forces the last posting's amount to be implicit, if:
-- To facilitate this, postings with explicit multi-commodity amounts -- there are other postings, all with explicit amounts, and the transaction
-- are displayed as multiple similar postings, one per commodity. -- appears balanced.
-- --
-- Explicit multi-commodity postings are shown as multiple similar postings, -- Postings with multicommodity explicit amounts are handled as follows:
-- one for each commodity, to help produce parseable journal syntax. -- if onelineamounts is true, these amounts are shown on one line,
-- Or if onelineamounts is true, such amounts are shown on one line, -- comma-separated, and the output will not be valid journal syntax.
-- comma-separated (and the output will not be valid journal syntax). -- Otherwise, they are shown as several similar postings, one per commodity.
-- --
-- Posting amounts will be aligned with each other. -- Posting amounts will be aligned with each other, starting about 4 columns
-- beyond the widest account name (see postingAsLines for details).
-- --
postingsAsLines :: Bool -> Bool -> Transaction -> [Posting] -> [String] postingsAsLines :: Bool -> Bool -> Transaction -> [Posting] -> [String]
postingsAsLines elide onelineamounts t ps postingsAsLines elide onelineamounts t ps