HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulehledger-lib-1.52.4GHC2021

Hledger.Data.Transaction

A Transaction represents a movement of some commodity(ies) between two or more accounts. It consists of multiple account Postings which balance to zero, a date, and optional extras like description, cleared status, and tags.

  • 1 type
  • 37 values
  • Packagehledger-lib-1.52.4
  • Exports38
  • LanguageGHC2021
  • LicenceGPL-3.0-or-later
  • SourceTransaction.hs

Transaction

4 declarations

operations

21 declarations

Find, associate, and tag the corresponding equity conversion postings and costful or potentially costful postings in this transaction. With a true addcosts argument, also generate and add any equivalent costs that are missing. The (previously detected) names of all equity conversion accounts should be provided.

For every pair of adjacent conversion postings, this first searches for a posting with equivalent cost (1). If no such posting is found, it then searches the costless postings, for one matching one of the conversion amounts (2). If either of these found a candidate posting, it is tagged with costPostingTagName. Then if in addcosts mode, if a costless posting was found, a cost equivalent to the conversion amounts is added to it.

The name reflects the complexity of this and its helpers; clarification is ongoing.

helpers

3 declarations

How to determine the precision used for checking that transactions are balanced. See #2402.

Constructors

  • TBPOld

    Legacy behaviour, as in hledger <1.50, included to ease upgrades. use precision inferred from the whole journal, overridable by commodity directive or -c. Display precision is also transaction balancing precision; increasing it can break journal reading. Some valid journals are rejected until commodity directives are added. Small unbalanced remainders can be hidden, and in accounts that are never reconciled, can accumulate over time.

  • TBPExact

    Simpler, more robust behaviour, as in Ledger: use precision inferred from the transaction. Display precision and transaction balancing precision are independent; display precision never affects journal reading. Valid journals from ledger or beancount are accepted without needing commodity directives. Every imbalance in a transaction is visibly accounted for in that transaction's journal entry.

Instances6Bounded, Enum, Eq, Ord, Read, Show

Parse a transaction's description into payee and note (aka narration) fields, assuming a convention of separating these with | (like Beancount). Ie, everything up to the first | is the payee, everything after it is the note. When there's no |, payee == note == description.

date operations

2 declarations

transaction description parts

2 declarations

rendering

4 declarations

Render a journal transaction as text similar to the style of Ledger's print command.

Adapted from Ledger 2.x and 3.x standard format:

yyyy-mm-dd[ *][ CODE] description.........          [  ; comment...............]
    account name 1.....................  ...$amount1[  ; comment...............]
    account name 2.....................  ..$-amount1[  ; comment...............]

pcodewidth    = no limit -- 10          -- mimicking ledger layout.
pdescwidth    = no limit -- 20          -- I don't remember what these mean,
pacctwidth    = 35 minimum, no maximum  -- they were important at the time.
pamtwidth     = 11
pcommentwidth = no limit -- 22

The output will be parseable journal syntax. To facilitate this, postings with explicit multi-commodity amounts are displayed as multiple similar postings, one per commodity. (Normally does not happen with this function).

transaction errors

1 declaration

tests

1 declaration

Orphan instances

1 instance