hledger-lib-0.21.3: Core data types, parsers and utilities for the hledger accounting tool.

Safe HaskellNone

Hledger.Data.Journal

Contents

Description

A Journal is a set of transactions, plus optional related data. This is hledger's primary data object. It is usually parsed from a journal file or other data format (see Hledger.Read).

Synopsis

Parsing helpers

journalApplyAliases :: [(AccountName, AccountName)] -> Journal -> JournalSource

Apply additional account aliases (eg from the command-line) to all postings in a journal.

journalBalanceTransactions :: Journal -> Either String JournalSource

Fill in any missing amounts and check that all journal transactions balance, or return an error message. This is done after parsing all amounts and working out the canonical commodities, since balancing depends on display precision. Reports only the first error encountered.

journalCanonicaliseAmounts :: Journal -> JournalSource

Convert all the journal's posting amounts (not price amounts) to their canonical display settings. Ie, all amounts in a given commodity will use (a) the display settings of the first, and (b) the greatest precision, of the posting amounts in that commodity.

journalConvertAmountsToCost :: Journal -> JournalSource

Convert all this journal's amounts to cost by applying their prices, if any.

journalFinalise :: ClockTime -> LocalTime -> FilePath -> String -> JournalContext -> Journal -> Either String JournalSource

Do post-parse processing on a journal to make it ready for use: check all transactions balance, canonicalise amount formats, close any open timelog entries and so on.

Filtering

filterJournalPostings :: Query -> Journal -> JournalSource

Keep only postings matching the query expression. This can leave unbalanced transactions.

filterJournalTransactions :: Query -> Journal -> JournalSource

Keep only transactions matching the query expression.

Querying

journalAccountNamesUsed :: Journal -> [AccountName]Source

All account names used in this journal.

journalAmounts :: Journal -> [Amount]Source

Get all this journal's component amounts, roughly in the order parsed.

journalDateSpan :: Journal -> DateSpanSource

The (fully specified) date span containing this journal's transactions, or DateSpan Nothing Nothing if there are none.

Standard account types

journalIncomeAccountQuery :: Journal -> QuerySource

A query for Income (Revenue) accounts in this journal. This is currently hard-coded to the case-insensitive regex ^(income|revenue)s?(:|$).

journalExpenseAccountQuery :: Journal -> QuerySource

A query for Expense accounts in this journal. This is currently hard-coded to the case-insensitive regex ^expenses?(:|$).

journalAssetAccountQuery :: Journal -> QuerySource

A query for Asset accounts in this journal. This is currently hard-coded to the case-insensitive regex ^assets?(:|$).

journalLiabilityAccountQuery :: Journal -> QuerySource

A query for Liability accounts in this journal. This is currently hard-coded to the case-insensitive regex ^liabilit(y|ies)(:|$).

journalEquityAccountQuery :: Journal -> QuerySource

A query for Equity accounts in this journal. This is currently hard-coded to the case-insensitive regex ^equity(:|$).

journalCashAccountQuery :: Journal -> QuerySource

A query for Cash (-equivalent) accounts in this journal (ie, accounts which appear on the cashflow statement.) This is currently hard-coded to be all the Asset accounts except for those containing the case-insensitive regex (receivable|A/R).

Misc

matchpats :: [String] -> String -> BoolSource

Check if a set of hledger account/description filter patterns matches the given account name or entry description. Patterns are case-insensitive regular expressions. Prefixed with not:, they become anti-patterns.

Tests