Hledger.Data.Types
Description
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
- = NoInterval
- | Days Int
- | Weeks Int
- | Months Int
- | Quarters Int
- | Years Int
- | DayOfMonth Int
- | DayOfWeek Int
- type AccountName = String
- data Side
- data Commodity = Commodity {
- symbol :: String
- side :: Side
- spaced :: Bool
- precision :: Int
- decimalpoint :: Char
- separator :: Char
- separatorpositions :: [Int]
- 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 {
- tdate :: Day
- teffectivedate :: Maybe Day
- tstatus :: Bool
- tcode :: String
- tdescription :: String
- tcomment :: String
- tmetadata :: [(String, String)]
- tpostings :: [Posting]
- tpreceding_comment_lines :: String
- data ModifierTransaction = ModifierTransaction {
- mtvalueexpr :: String
- mtpostings :: [Posting]
- data PeriodicTransaction = PeriodicTransaction {
- ptperiodicexpr :: String
- ptpostings :: [Posting]
- data TimeLogCode
- = SetBalance
- | SetRequiredHours
- | In
- | Out
- | FinalOut
- data TimeLogEntry = TimeLogEntry {
- tlcode :: TimeLogCode
- tldatetime :: LocalTime
- tlcomment :: String
- data HistoricalPrice = HistoricalPrice {
- hdate :: Day
- hsymbol :: String
- hamount :: MixedAmount
- type Year = Integer
- data JournalContext = Ctx {
- ctxYear :: !(Maybe Year)
- ctxCommodity :: !(Maybe Commodity)
- ctxAccount :: ![AccountName]
- ctxAliases :: ![(AccountName, AccountName)]
- data Journal = Journal {
- jmodifiertxns :: [ModifierTransaction]
- jperiodictxns :: [PeriodicTransaction]
- jtxns :: [Transaction]
- open_timelog_entries :: [TimeLogEntry]
- historical_prices :: [HistoricalPrice]
- final_comment_lines :: String
- jContext :: JournalContext
- files :: [(FilePath, String)]
- filereadtime :: ClockTime
- type JournalUpdate = ErrorT String IO (Journal -> Journal)
- data Reader = Reader {}
- data Ledger = Ledger {
- journal :: Journal
- accountnametree :: Tree AccountName
- accountmap :: Map AccountName Account
- data Account = Account {
- aname :: AccountName
- apostings :: [Posting]
- abalance :: MixedAmount
- data FilterSpec = FilterSpec {}
Documentation
Constructors
| DateSpan (Maybe Day) (Maybe Day) |
Constructors
| NoInterval | |
| Days Int | |
| Weeks Int | |
| Months Int | |
| Quarters Int | |
| Years Int | |
| DayOfMonth Int | |
| DayOfWeek Int |
type AccountName = StringSource
Constructors
| Commodity | |
Fields
| |
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.
Constructors
| UnitPrice MixedAmount | |
| TotalPrice MixedAmount |
Constructors
| Amount | |
newtype MixedAmount Source
Instances
| Eq MixedAmount | |
| Num MixedAmount | |
| Ord MixedAmount | |
| Show MixedAmount |
data PostingType Source
Constructors
| RegularPosting | |
| VirtualPosting | |
| BalancedVirtualPosting |
Instances
| Eq PostingType | |
| Show PostingType |
Constructors
| Posting | |
Fields
| |
data Transaction Source
Constructors
| Transaction | |
Fields
| |
Instances
| Eq Transaction | |
| Show Transaction |
data ModifierTransaction Source
Constructors
| ModifierTransaction | |
Fields
| |
Instances
data PeriodicTransaction Source
Constructors
| PeriodicTransaction | |
Fields
| |
Instances
data TimeLogCode Source
Constructors
| SetBalance | |
| SetRequiredHours | |
| In | |
| Out | |
| FinalOut |
Instances
| Eq TimeLogCode | |
| Ord TimeLogCode | |
| Read TimeLogCode | |
| Show TimeLogCode |
data TimeLogEntry Source
Constructors
| TimeLogEntry | |
Fields
| |
Instances
| Eq TimeLogEntry | |
| Ord TimeLogEntry | |
| Show TimeLogEntry |
data HistoricalPrice Source
Constructors
| HistoricalPrice | |
Fields
| |
Instances
| Eq HistoricalPrice | |
| Show HistoricalPrice |
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.
Constructors
| Ctx | |
Fields
| |
Instances
| Eq JournalContext | |
| Read JournalContext | |
| Show JournalContext |
Constructors
| Journal | |
Fields
| |
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.
Constructors
| Ledger | |
Fields
| |
Instances
| Show Ledger |
Constructors
| Account | |
Fields
| |
data FilterSpec Source
A generic, pure specification of how to filter (or search) transactions and postings.
Constructors
| FilterSpec | |
Fields
| |
Instances
| Show FilterSpec |