Hledger.Data.Journal
Description
A Journal
is a set of Transaction
s and related data, usually parsed
from a hledger/ledger journal file or timelog. This is the primary hledger
data object.
- nulljournal :: Journal
- nullctx :: JournalContext
- nullfilterspec :: FilterSpec
- journalFilePath :: Journal -> FilePath
- journalFilePaths :: Journal -> [FilePath]
- mainfile :: Journal -> (FilePath, String)
- addTransaction :: Transaction -> Journal -> Journal
- addModifierTransaction :: ModifierTransaction -> Journal -> Journal
- addPeriodicTransaction :: PeriodicTransaction -> Journal -> Journal
- addHistoricalPrice :: HistoricalPrice -> Journal -> Journal
- addTimeLogEntry :: TimeLogEntry -> Journal -> Journal
- journalPostings :: Journal -> [Posting]
- journalAccountNamesUsed :: Journal -> [AccountName]
- journalAccountNames :: Journal -> [AccountName]
- journalAccountNameTree :: Journal -> Tree AccountName
- filterJournalPostings2 :: Matcher -> Journal -> Journal
- filterJournalTransactions2 :: Matcher -> Journal -> Journal
- filterJournalTransactions :: FilterSpec -> Journal -> Journal
- filterJournalPostings :: FilterSpec -> Journal -> Journal
- filterJournalTransactionsByDescription :: [String] -> Journal -> Journal
- filterJournalTransactionsByDate :: DateSpan -> Journal -> Journal
- filterJournalTransactionsByClearedStatus :: Maybe Bool -> Journal -> Journal
- filterJournalPostingsByClearedStatus :: Maybe Bool -> Journal -> Journal
- filterJournalPostingsByRealness :: Bool -> Journal -> Journal
- filterJournalPostingsByEmpty :: Bool -> Journal -> Journal
- filterJournalTransactionsByDepth :: Maybe Int -> Journal -> Journal
- filterJournalPostingsByDepth :: Maybe Int -> Journal -> Journal
- filterJournalTransactionsByAccount :: [String] -> Journal -> Journal
- filterJournalPostingsByAccount :: [String] -> Journal -> Journal
- journalSelectingDate :: WhichDate -> Journal -> Journal
- journalApplyAliases :: [(AccountName, AccountName)] -> Journal -> Journal
- journalFinalise :: ClockTime -> LocalTime -> FilePath -> String -> JournalContext -> Journal -> Either String Journal
- journalBalanceTransactions :: Journal -> Either String Journal
- journalCanonicaliseAmounts :: Journal -> Journal
- journalApplyHistoricalPrices :: Journal -> Journal
- journalHistoricalPriceFor :: Journal -> Day -> Commodity -> Maybe MixedAmount
- journalCloseTimeLogEntries :: LocalTime -> Journal -> Journal
- journalConvertAmountsToCost :: Journal -> Journal
- journalCanonicalCommodities :: Journal -> Map String Commodity
- journalAmountCommodities :: Journal -> [Commodity]
- journalAmountAndPriceCommodities :: Journal -> [Commodity]
- amountCommodities :: Amount -> [Commodity]
- journalAmounts :: Journal -> [MixedAmount]
- journalDateSpan :: Journal -> DateSpan
- matchpats :: [String] -> String -> Bool
- journalAccountInfo :: Journal -> (Tree AccountName, Map AccountName Account)
- groupPostings :: [Posting] -> (Tree AccountName, AccountName -> [Posting], AccountName -> MixedAmount, AccountName -> MixedAmount)
- calculateBalances :: Tree AccountName -> (AccountName -> [Posting]) -> Tree (AccountName, (MixedAmount, MixedAmount))
- postingsByAccount :: [Posting] -> Map AccountName [Posting]
Documentation
journalFilePaths :: Journal -> [FilePath]Source
addTransaction :: Transaction -> Journal -> JournalSource
addTimeLogEntry :: TimeLogEntry -> Journal -> JournalSource
journalPostings :: Journal -> [Posting]Source
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 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 amounts in that commodity. Prices are canonicalised as well, so consider calling journalApplyHistoricalPrices before this.
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.