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

Hledger.Data.Journal

Description

A Journal is a set of Transactions and related data, usually parsed from a hledger/ledger journal file or timelog. This is the primary hledger data object.

Synopsis

Documentation

filterJournalPostings2 :: Matcher -> Journal -> JournalSource

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

filterJournalTransactions2 :: Matcher -> Journal -> JournalSource

Keep only transactions matching the query expression.

filterJournalTransactions :: FilterSpec -> Journal -> JournalSource

Keep only transactions we are interested in, as described by the filter specification.

filterJournalPostings :: FilterSpec -> Journal -> JournalSource

Keep only postings we are interested in, as described by the filter specification. This can leave unbalanced transactions.

filterJournalTransactionsByDescription :: [String] -> Journal -> JournalSource

Keep only transactions whose description matches the description patterns.

filterJournalTransactionsByDate :: DateSpan -> Journal -> JournalSource

Keep only transactions which fall between begin and end dates. We include transactions on the begin date and exclude transactions on the end date, like ledger. An empty date string means no restriction.

filterJournalTransactionsByClearedStatus :: Maybe Bool -> Journal -> JournalSource

Keep only transactions which have the requested cleared/uncleared status, if there is one.

filterJournalPostingsByClearedStatus :: Maybe Bool -> Journal -> JournalSource

Keep only postings which have the requested cleared/uncleared status, if there is one.

filterJournalPostingsByRealness :: Bool -> Journal -> JournalSource

Strip out any virtual postings, if the flag is true, otherwise do no filtering.

filterJournalPostingsByEmpty :: Bool -> Journal -> JournalSource

Strip out any postings with zero amount, unless the flag is true.

filterJournalTransactionsByDepth :: Maybe Int -> Journal -> JournalSource

Keep only transactions which affect accounts deeper than the specified depth.

filterJournalPostingsByDepth :: Maybe Int -> Journal -> JournalSource

Strip out any postings to accounts deeper than the specified depth (and any transactions which have no postings as a result).

filterJournalTransactionsByAccount :: [String] -> Journal -> JournalSource

Keep only transactions which affect accounts matched by the account patterns. More precisely: each positive account pattern excludes transactions which do not contain a posting to a matched account, and each negative account pattern excludes transactions containing a posting to a matched account.

filterJournalPostingsByAccount :: [String] -> Journal -> JournalSource

Keep only postings which affect accounts matched by the account patterns. This can leave transactions unbalanced.

journalSelectingDate :: WhichDate -> Journal -> JournalSource

Convert this journal's transactions' primary date to either the actual or effective date.

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

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

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

Do post-parse processing on a journal, to make it ready for use.

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.

journalApplyHistoricalPrices :: Journal -> JournalSource

Apply this journal's historical price records to unpriced amounts where possible.

journalHistoricalPriceFor :: Journal -> Day -> Commodity -> Maybe MixedAmountSource

Get the price for a commodity on the specified day from the price database, if known. Does only one lookup step, ie will not look up the price of a price.

journalCloseTimeLogEntries :: LocalTime -> Journal -> JournalSource

Close any open timelog sessions in this journal using the provided current time.

journalConvertAmountsToCost :: Journal -> JournalSource

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

journalCanonicalCommodities :: Journal -> Map String CommoditySource

Get this journal's unique, display-preference-canonicalised commodities, by symbol.

journalAmountCommodities :: Journal -> [Commodity]Source

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

journalAmountAndPriceCommodities :: Journal -> [Commodity]Source

Get all this journal's amount and price commodities, in the order parsed.

amountCommodities :: Amount -> [Commodity]Source

Get this amount's commodity and any commodities referenced in its price.

journalAmounts :: Journal -> [MixedAmount]Source

Get all this journal's amounts, 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.

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.

journalAccountInfo :: Journal -> (Tree AccountName, Map AccountName Account)Source

Calculate the account tree and all account balances from a journal's postings, returning the results for efficient lookup.

groupPostings :: [Posting] -> (Tree AccountName, AccountName -> [Posting], AccountName -> MixedAmount, AccountName -> MixedAmount)Source

Given a list of postings, return an account name tree and three query functions that fetch postings, subaccount-excluding-balance and subaccount-including-balance by account name.

calculateBalances :: Tree AccountName -> (AccountName -> [Posting]) -> Tree (AccountName, (MixedAmount, MixedAmount))Source

Add subaccount-excluding and subaccount-including balances to a tree of account names somewhat efficiently, given a function that looks up transactions by account name.

postingsByAccount :: [Posting] -> Map AccountName [Posting]Source

Convert a list of postings to a map from account name to that account's postings.