hledger-0.8: A command-line (or curses or web-based) double-entry accounting tool.Source codeContentsIndex
Ledger.Types
Description

Most data types are defined here to avoid import cycles. Here is an overview of the hledger data model:

 Ledger              -- hledger's ledger is a journal file plus cached/derived data
  Journal            -- a representation of the journal file, containing..
   [Transaction]     -- ..journal transactions, which have date, status, code, description and..
    [Posting]        -- ..two or more account postings (account name and amount)
  Tree AccountName   -- all account names as a tree
  Map AccountName Account -- a map from account name to account info (postings and balances)

For more detailed documentation on each type, see the corresponding modules.

Terminology has been in flux:

  • ledger 2 had entries containing transactions.
  • hledger 0.4 had Entrys containing RawTransactions, which were flattened to Transactions.
  • ledger 3 has transactions containing postings.
  • hledger 0.5 had LedgerTransactions containing Postings, which were flattened to Transactions.
  • hledger 0.8 has Transactions containing Postings, and no flattened type.
Synopsis
type SmartDate = (String, String, String)
data WhichDate
= ActualDate
| EffectiveDate
data DateSpan = DateSpan (Maybe Day) (Maybe Day)
data Interval
= NoInterval
| Daily
| Weekly
| Monthly
| Quarterly
| Yearly
type AccountName = String
data Side
= L
| R
data Commodity = Commodity {
symbol :: String
side :: Side
spaced :: Bool
comma :: Bool
precision :: Int
}
data Amount = Amount {
commodity :: Commodity
quantity :: Double
price :: Maybe MixedAmount
}
newtype MixedAmount = Mixed [Amount]
data PostingType
= RegularPosting
| VirtualPosting
| BalancedVirtualPosting
data Posting = Posting {
pstatus :: Bool
paccount :: AccountName
pamount :: MixedAmount
pcomment :: String
ptype :: PostingType
ptransaction :: Maybe Transaction
}
data Transaction = Transaction {
tdate :: Day
teffectivedate :: Maybe Day
tstatus :: Bool
tcode :: String
tdescription :: String
tcomment :: 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
}
data Journal = Journal {
jmodifiertxns :: [ModifierTransaction]
jperiodictxns :: [PeriodicTransaction]
jtxns :: [Transaction]
open_timelog_entries :: [TimeLogEntry]
historical_prices :: [HistoricalPrice]
final_comment_lines :: String
filepath :: FilePath
filereadtime :: ClockTime
jtext :: String
}
data Account = Account {
aname :: AccountName
apostings :: [Posting]
abalance :: MixedAmount
}
data Ledger = Ledger {
journal :: Journal
accountnametree :: Tree AccountName
accountmap :: Map AccountName Account
}
data FilterSpec = FilterSpec {
datespan :: DateSpan
cleared :: Maybe Bool
real :: Bool
empty :: Bool
costbasis :: Bool
acctpats :: [String]
descpats :: [String]
whichdate :: WhichDate
depth :: Maybe Int
}
Documentation
type SmartDate = (String, String, String)Source
data WhichDate Source
Constructors
ActualDate
EffectiveDate
show/hide Instances
data DateSpan Source
Constructors
DateSpan (Maybe Day) (Maybe Day)
show/hide Instances
data Interval Source
Constructors
NoInterval
Daily
Weekly
Monthly
Quarterly
Yearly
show/hide Instances
type AccountName = StringSource
data Side Source
Constructors
L
R
show/hide Instances
data Commodity Source
Constructors
Commodity
symbol :: Stringthe commodity's symbol display preferences for amounts of this commodity
side :: Sideshould the symbol appear on the left or the right
spaced :: Boolshould there be a space between symbol and quantity
comma :: Boolshould thousands be comma-separated
precision :: Intnumber of decimal places to display
show/hide Instances
data Amount Source
Constructors
Amount
commodity :: Commodity
quantity :: Double
price :: Maybe MixedAmountunit price/conversion rate for this amount at posting time
show/hide Instances
newtype MixedAmount Source
Constructors
Mixed [Amount]
show/hide Instances
data PostingType Source
Constructors
RegularPosting
VirtualPosting
BalancedVirtualPosting
show/hide Instances
data Posting Source
Constructors
Posting
pstatus :: Bool
paccount :: AccountName
pamount :: MixedAmount
pcomment :: String
ptype :: PostingType
ptransaction :: Maybe Transactionthis posting's parent transaction (co-recursive types). Tying this knot gets tedious, Maybe makes it easier/optional.
show/hide Instances
data Transaction Source
Constructors
Transaction
tdate :: Day
teffectivedate :: Maybe Day
tstatus :: Bool
tcode :: String
tdescription :: String
tcomment :: String
tpostings :: [Posting]
tpreceding_comment_lines :: String
show/hide Instances
data ModifierTransaction Source
Constructors
ModifierTransaction
mtvalueexpr :: String
mtpostings :: [Posting]
show/hide Instances
data PeriodicTransaction Source
Constructors
PeriodicTransaction
ptperiodicexpr :: String
ptpostings :: [Posting]
show/hide Instances
data TimeLogCode Source
Constructors
SetBalance
SetRequiredHours
In
Out
FinalOut
show/hide Instances
data TimeLogEntry Source
Constructors
TimeLogEntry
tlcode :: TimeLogCode
tldatetime :: LocalTime
tlcomment :: String
show/hide Instances
data HistoricalPrice Source
Constructors
HistoricalPrice
hdate :: Day
hsymbol :: String
hamount :: MixedAmount
show/hide Instances
data Journal Source
Constructors
Journal
jmodifiertxns :: [ModifierTransaction]
jperiodictxns :: [PeriodicTransaction]
jtxns :: [Transaction]
open_timelog_entries :: [TimeLogEntry]
historical_prices :: [HistoricalPrice]
final_comment_lines :: String
filepath :: FilePath
filereadtime :: ClockTime
jtext :: String
show/hide Instances
data Account Source
Constructors
Account
aname :: AccountName
apostings :: [Posting]transactions in this account
abalance :: MixedAmountsum of transactions in this account and subaccounts
show/hide Instances
data Ledger Source
Constructors
Ledger
journal :: Journal
accountnametree :: Tree AccountName
accountmap :: Map AccountName Account
show/hide Instances
data FilterSpec Source
A generic, pure specification of how to filter transactions/postings. This exists to keep app-specific options out of the hledger library.
Constructors
FilterSpec
datespan :: DateSpanonly include if in this date span
cleared :: Maybe Boolonly include if cleared/uncleared/don't care
real :: Boolonly include if real/don't care
empty :: Boolinclude if empty (ie amount is zero)
costbasis :: Boolconvert all amounts to cost basis
acctpats :: [String]only include if matching these account patterns
descpats :: [String]only include if matching these description patterns
whichdate :: WhichDatewhich dates to use (actual or effective)
depth :: Maybe Int
show/hide Instances
Produced by Haddock version 2.6.0