hledger-lib-1.20.1: A reusable library providing the core functionality of hledger

Hledger.Data.Posting

Description

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.

Synopsis

# Posting

Make a posting to an account.

Make a virtual (unbalanced) posting to an account.

Make a posting to an account, maybe with a balance assertion.

Make a virtual (unbalanced) posting to an account, maybe with a balance assertion.

Make a partial, exclusive balance assertion.

Make a total, exclusive balance assertion.

Make a partial, inclusive balance assertion.

Make a total, inclusive balance assertion.

# 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".

Tags for this posting including any inherited from its parent transaction.

Tags for this transaction including any from its postings.

Remove all prices of a posting

Apply some account aliases to the posting's account name, as described by accountNameApplyAliases. This can fail due to a bad replacement pattern in a regular expression alias.

# 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.

Does this posting fall within the given date span ?

# account name operations

Sorted unique account names referenced by these postings.

Prefix one account name to another, preserving posting type indicators like concatAccountNames.

Join account names into one. If any of them has () or [] posting type indicators, these (the first type encountered) will also be applied to the resulting account name.

Rewrite an account name using all matching aliases from the given list, in sequence. Each alias sees the result of applying the previous aliases. Or, return any error arising from a bad regular expression in the aliases.

Memoising version of accountNameApplyAliases, maybe overkill.

# comment/tag operations

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.

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

Add a tag on its own line to a comment, preserving any prior content. A space is inserted following the colon, before the value.

# misc.

Apply a transform function to this posting's amount.

Apply a specified valuation to this posting's amount, using the provided price oracle, commodity styles, reference dates, and whether this is for a multiperiod report or not. See amountApplyValuation.

Convert this posting's amount to cost, and apply the appropriate amount styles.