Most data types are defined here to avoid import cycles. Here is an overview of the hledger data model:
Journal -- a journal is derived from one or more data files. It contains.. [Transaction] -- journal transactions, which have date, status, code, description and.. [Posting] -- multiple account postings (entries), which have account name and amount. [HistoricalPrice] -- historical commodity prices Ledger -- a ledger is derived from a journal, by applying a filter specification and doing some further processing. It contains.. Journal -- the filtered journal, containing only the transactions and postings we are interested in Tree AccountName -- account names referenced in the journal's transactions, as a tree Map AccountName Account -- per-account postings and balances from the journal's transactions, as a map from account name to account info
For more detailed documentation on each type, see the corresponding modules.
Evolution of transaction/entry/posting terminology:
- ledger 2: entries contain transactions
- hledger 0.4: Entrys contain RawTransactions (which are flattened to Transactions)
- ledger 3: transactions contain postings
- hledger 0.5: LedgerTransactions contain Postings (which are flattened to Transactions)
- hledger 0.8: Transactions contain Postings (referencing Transactions..)
- type SmartDate = (String, String, String)
- data WhichDate
- data DateSpan = DateSpan (Maybe Day) (Maybe Day)
- data Interval
- type AccountName = String
- data Side
- data Commodity = Commodity {}
- data Price
- data Amount = Amount {}
- newtype MixedAmount = Mixed [Amount]
- data PostingType
- data Posting = Posting {
- pstatus :: Bool
- paccount :: AccountName
- pamount :: MixedAmount
- pcomment :: String
- ptype :: PostingType
- pmetadata :: [(String, String)]
- ptransaction :: Maybe Transaction
- data Transaction = Transaction {}
- data ModifierTransaction = ModifierTransaction {
- mtvalueexpr :: String
- mtpostings :: [Posting]
- data PeriodicTransaction = PeriodicTransaction {
- ptperiodicexpr :: String
- ptpostings :: [Posting]
- data TimeLogCode
- = SetBalance
- | SetRequiredHours
- | In
- | Out
- | FinalOut
- data TimeLogEntry = TimeLogEntry {}
- data HistoricalPrice = HistoricalPrice {}
- type Year = Integer
- data JournalContext = Ctx {
- ctxYear :: !(Maybe Year)
- ctxCommodity :: !(Maybe Commodity)
- ctxAccount :: ![AccountName]
- data Journal = Journal {}
- type JournalUpdate = ErrorT String IO (Journal -> Journal)
- data Reader = Reader {}
- data Ledger = Ledger {}
- data Account = Account {
- aname :: AccountName
- apostings :: [Posting]
- abalance :: MixedAmount
- data FilterSpec = FilterSpec {}
Documentation
type AccountName = StringSource
Commodity | |
|
An amount's price may be written as @ unit price or @@ total price. Note although Price has a MixedAmount, it should hold only single-commodity amounts, cf costOfAmount.
newtype MixedAmount Source
data PostingType Source
Posting | |
|
data TimeLogCode Source
data TimeLogEntry Source
data JournalContext Source
A journal context is some data which can change in the course of parsing a journal. An example is the default year, which changes when a Y directive is encountered. At the end of parsing, the final context is saved for later use by eg the add command.
Ctx | |
|
Journal | |
|
type JournalUpdate = ErrorT String IO (Journal -> Journal)Source
A JournalUpdate is some transformation of a Journal. It can do I/O or raise an error.
A hledger journal reader is a triple of format name, format-detecting predicate, and a parser to Journal.
Account | |
|
data FilterSpec Source
A generic, pure specification of how to filter transactions and postings.
FilterSpec | |
|