HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulehledger-lib-1.52.4GHC2021

Hledger.Data.Posting

A Posting represents a change (by some MixedAmount) of the balance in some Account. Each Transaction contains two or more postings which should add up to 0. Postings reference their parent transaction, so we can look up the date or description there.

Contents
  1. Posting
  2. operations
  3. date operations
  4. account name operations
  5. comment/tag operations
  6. arithmetic
  7. rendering
  8. misc.
Synopsis

Posting

operations

Get a posting's status. This is cleared or pending if those are explicitly set on the posting, otherwise the status of its parent transaction, or unmarked if there is no parent transaction. (Note the ambiguity, unmarked can mean "posting and transaction are both unmarked" or "posting is unmarked and don't know about the transaction".

Add tags to a posting, discarding any for which the posting already has a value. Note this does not add tags to the posting's comment.

date operations

Get a posting's (primary) date - it's own primary date if specified, otherwise the parent transaction's primary date, or the null date if there is no parent transaction.

Get a posting's secondary (secondary) date, which is the first of: posting's secondary date, transaction's secondary date, posting's primary date, transaction's primary date, or the null date if there is no parent transaction.

account name operations

comment/tag operations

valuecommentJoin :: Text -> Text -> Text

Join two parts of a comment, eg a tag and another tag, or a tag and a non-tag, on a single line. Interpolates a comma and space unless one of the parts is empty.

valuecommentAddTag :: Text -> Tag -> Text

Add a tag to a comment, comma-separated from any prior content. A space is inserted following the colon, before the value.

Special tags hledger sometimes adds to mark various things. These should be hidden tag names, beginning with _. With --verbose-tags, the equivalent visible tags will also be added. These tag names are mentioned in docs and can be matched by user queries, so consider the impact before changing them.

Special tags hledger sometimes adds to mark various things. These should be hidden tag names, beginning with _. With --verbose-tags, the equivalent visible tags will also be added. These tag names are mentioned in docs and can be matched by user queries, so consider the impact before changing them.

Special tags hledger sometimes adds to mark various things. These should be hidden tag names, beginning with _. With --verbose-tags, the equivalent visible tags will also be added. These tag names are mentioned in docs and can be matched by user queries, so consider the impact before changing them.

Special tags hledger sometimes adds to mark various things. These should be hidden tag names, beginning with _. With --verbose-tags, the equivalent visible tags will also be added. These tag names are mentioned in docs and can be matched by user queries, so consider the impact before changing them.

Special tags hledger sometimes adds to mark various things. These should be hidden tag names, beginning with _. With --verbose-tags, the equivalent visible tags will also be added. These tag names are mentioned in docs and can be matched by user queries, so consider the impact before changing them.

arithmetic

rendering

valuepostingAsLines
  1. :: Bool
  2. -> Bool
  3. -> Int
  4. -> Int
  5. -> Posting
  6. -> ([Text], Int, Int)

Render one posting, on one or more lines, suitable for print output. Also returns the widths calculated for the account and amount fields.

There will be an indented account name, plus one or more of status flag, posting amount, balance assertion, same-line comment, next-line comments.

If the posting's amount is implicit or if elideamount is true, no amount is shown. If the posting's amount is explicit and multi-commodity, multiple similar postings are shown, one for each commodity, to help produce parseable journal syntax. Or if onelineamounts is true, such amounts are shown on one line, comma-separated (and the output will not be valid journal syntax).

If an amount is zero, any commodity symbol attached to it is shown (and the corresponding commodity display style is used).

By default, 4 spaces (2 if there's a status flag) are shown between account name and start of amount area, which is typically 12 chars wide and contains a right-aligned amount (so 10-12 visible spaces between account name and amount is typical). When given a list of postings to be aligned with, the whitespace will be increased if needed to match the posting with the longest account name. This is used to align the amounts of a transaction's postings.

valuepostingsAsLines :: Bool -> [Posting] -> [Text]

Render a transaction's postings as indented lines, suitable for print output.

Normally these will be in valid journal syntax which hledger can reparse (though they may include no-longer-valid balance assertions). Explicit amounts are shown, implicit amounts are not.

Postings with multicommodity explicit amounts are handled as follows: if onelineamounts is true, these amounts are shown on one line, comma-separated, and the output will not be valid journal syntax. Otherwise, they are shown as several similar postings, one per commodity. When the posting has a balance assertion, it is attached to the last of these postings.

Posting amounts will be aligned with each other, starting about 4 columns beyond the widest account name (see postingAsLines for details). The postings will appear balanced (amounts summing to zero). Amounts' display precisions, which may have been limited by commodity directives, will be increased if necessary to ensure this.

Render a transaction or posting's comment as indented, semicolon-prefixed comment lines. The first line (unless empty) will have leading space, subsequent lines will have a larger indent.

misc.

Orphan instances

2 instances