Safe Haskell | Safe-Infered |
---|
Most data types are defined here to avoid import cycles. Here is an overview of the hledger data model:
Journal -- a journal is read from one or more data files. It contains.. [Transaction] -- journal transactions (aka entries), which have date, status, code, description and.. [Posting] -- multiple account postings, 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 -- a filtered copy of the original journal, containing only the transactions and postings we are interested in Tree AccountName -- all accounts named by the journal's transactions, as a hierarchy Map AccountName Account -- the postings, and resulting balances, in each account
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 {}
- type Quantity = Double
- data Price
- data Amount = Amount {}
- newtype MixedAmount = Mixed [Amount]
- data PostingType
- type Tag = (String, String)
- data Posting = Posting {
- pstatus :: Bool
- paccount :: AccountName
- pamount :: MixedAmount
- pcomment :: String
- ptype :: PostingType
- ptags :: [Tag]
- 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]
- ctxAliases :: ![(AccountName, AccountName)]
- data Journal = Journal {}
- type JournalUpdate = ErrorT String IO (Journal -> Journal)
- type Format = String
- data Reader = Reader {}
- type ParseRules = CsvRules
- data CsvRules = CsvRules {
- dateField :: Maybe FieldPosition
- dateFormat :: Maybe String
- statusField :: Maybe FieldPosition
- codeField :: Maybe FieldPosition
- descriptionField :: [FormatString]
- amountField :: Maybe FieldPosition
- amountInField :: Maybe FieldPosition
- amountOutField :: Maybe FieldPosition
- currencyField :: Maybe FieldPosition
- baseCurrency :: Maybe String
- accountField :: Maybe FieldPosition
- account2Field :: Maybe FieldPosition
- effectiveDateField :: Maybe FieldPosition
- baseAccount :: AccountName
- accountRules :: [AccountRule]
- type FieldPosition = Int
- type AccountRule = ([(String, Maybe String)], AccountName)
- data HledgerFormatField
- data FormatString
- data Ledger = Ledger {}
- data Account = Account {
- aname :: AccountName
- apostings :: [Posting]
- abalance :: MixedAmount
Documentation
type AccountName = StringSource
Commodity | |
|
An amount's price in another commodity may be written as @ unit price or @@ total price. Note although a MixedAmount is used, it should be in a single commodity, also the amount should be positive; these are not enforced currently.
newtype MixedAmount Source
data PostingType Source
Posting | |
|
data Transaction Source
Transaction | |
|
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.
type ParseRules = CsvRulesSource
A set of data definitions and account-matching patterns sufficient to convert a particular CSV data file into meaningful journal transactions. See above.
type FieldPosition = IntSource
type AccountRule = ([(String, Maybe String)], AccountName)Source
data HledgerFormatField Source
data FormatString Source