hledger-lib-0.14: Reusable types and utilities for the hledger accounting tool and financial apps in general.Source codeContentsIndex
Hledger.Data.Transaction
Description
A Transaction consists of two or more related Postings which balance to zero, representing a movement of some commodity(ies) between accounts, plus a date and optional metadata like description and cleared status.
Synopsis
nulltransaction :: Transaction
showTransaction :: Transaction -> String
showTransactionUnelided :: Transaction -> String
showTransactionForPrint :: Bool -> Transaction -> String
showTransaction' :: Bool -> Bool -> Transaction -> String
showAccountName :: Maybe Int -> PostingType -> AccountName -> String
realPostings :: Transaction -> [Posting]
virtualPostings :: Transaction -> [Posting]
balancedVirtualPostings :: Transaction -> [Posting]
transactionPostingBalances :: Transaction -> (MixedAmount, MixedAmount, MixedAmount)
isTransactionBalanced :: Maybe (Map String Commodity) -> Transaction -> Bool
balanceTransaction :: Maybe (Map String Commodity) -> Transaction -> Either String Transaction
nonzerobalanceerror :: Transaction -> String
journalTransactionWithDate :: WhichDate -> Transaction -> Transaction
txnTieKnot :: Transaction -> Transaction
settxn :: Transaction -> Posting -> Posting
Documentation
nulltransaction :: TransactionSource
showTransaction :: Transaction -> StringSource

Show a journal transaction, formatted for the print command. ledger 2.x's standard format looks like this:

yyyymmdd[ *][ 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
showTransactionUnelided :: Transaction -> StringSource
showTransactionForPrint :: Bool -> Transaction -> StringSource
showTransaction' :: Bool -> Bool -> Transaction -> StringSource
showAccountName :: Maybe Int -> PostingType -> AccountName -> StringSource
Show an account name, clipped to the given width if any, and appropriately bracketed/parenthesised for the given posting type.
realPostings :: Transaction -> [Posting]Source
virtualPostings :: Transaction -> [Posting]Source
balancedVirtualPostings :: Transaction -> [Posting]Source
transactionPostingBalances :: Transaction -> (MixedAmount, MixedAmount, MixedAmount)Source
Get the sums of a transaction's real, virtual, and balanced virtual postings.
isTransactionBalanced :: Maybe (Map String Commodity) -> Transaction -> BoolSource
Is this transaction balanced ? A balanced transaction's real (non-virtual) postings sum to 0, and any balanced virtual postings also sum to 0.
balanceTransaction :: Maybe (Map String Commodity) -> Transaction -> Either String TransactionSource

Ensure this transaction is balanced, possibly inferring a missing amount or a conversion price first, or return an error message.

Balancing is affected by the provided commodities' display precisions.

We can infer an amount when there are multiple real postings and exactly one of them is amountless; likewise for balanced virtual postings. Inferred amounts are converted to cost basis when possible.

We can infer a price when all amounts were specified and the sum of real postings' amounts is exactly two non-explicitly-priced amounts in different commodities; likewise for balanced virtual postings.

nonzerobalanceerror :: Transaction -> StringSource
journalTransactionWithDate :: WhichDate -> Transaction -> TransactionSource
Convert the primary date to either the actual or effective date.
txnTieKnot :: Transaction -> TransactionSource
Ensure a transaction's postings refer back to it.
settxn :: Transaction -> Posting -> PostingSource
Set a posting's parent transaction.
Produced by Haddock version 2.6.1