-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A ledger-compatible text-based accounting tool. -- -- hledger is a minimal haskell clone of John Wiegley's ledger -- text-based accounting tool -- (http:newartisans.comsoftwareledger.html). hledger -- generates ledger-compatible register & balance reports from a -- plain text ledger file, and demonstrates a functional implementation -- of ledger. @package hledger @version 0.2 -- | Types for Dates and DateTimes, implemented in terms of UTCTime module Ledger.Dates newtype Date Date :: UTCTime -> Date newtype DateTime DateTime :: UTCTime -> DateTime mkDate :: Day -> Date mkDateTime :: Day -> TimeOfDay -> DateTime -- | Parse a date-time string to a time type, or raise an error. parsedatetime :: String -> DateTime -- | Parse a date string to a time type, or raise an error. parsedate :: String -> Date -- | Parse a time string to a time type using the provided pattern, or -- return the default. parsetimewith :: (ParseTime t) => String -> String -> t -> t datetimeToDate :: DateTime -> Date elapsedSeconds :: (Fractional a) => DateTime -> DateTime -> a today :: IO Date dateToUTC :: Date -> UTCTime dateComponents :: Date -> (Integer, Int, Int) instance Ord DateTime instance Eq DateTime instance Ord Date instance Eq Date instance Show DateTime instance Show Date -- | Provide a number of standard modules and utilities. module Ledger.Utils -- | Join multi-line strings as side-by-side rectangular strings of the -- same height, top-padded. concatTopPadded :: [String] -> String -- | Join multi-line strings as side-by-side rectangular strings of the -- same height, bottom-padded. concatBottomPadded :: [String] -> String -- | Convert a multi-line string to a rectangular string top-padded to the -- specified height. padtop :: Int -> String -> String -- | Convert a multi-line string to a rectangular string bottom-padded to -- the specified height. padbottom :: Int -> String -> String -- | Convert a multi-line string to a rectangular string left-padded to the -- specified width. padleft :: Int -> String -> String -- | Convert a multi-line string to a rectangular string right-padded to -- the specified width. padright :: Int -> String -> String difforzero :: (Num a, Ord a) => a -> a -> a containsRegex :: Regex -> String -> Bool splitAtElement :: (Eq a) => a -> [a] -> [[a]] -- | get the sub-tree rooted at the first (left-most, depth-first) -- occurrence of the specified node value subtreeat :: (Eq a) => a -> Tree a -> Maybe (Tree a) -- | get the sub-tree for the specified node value in the first tree in -- forest in which it occurs. subtreeinforest :: (Eq a) => a -> [Tree a] -> Maybe (Tree a) -- | remove all nodes past a certain depth treeprune :: Int -> Tree a -> Tree a -- | apply f to all tree nodes treemap :: (a -> b) -> Tree a -> Tree b -- | remove all subtrees whose nodes do not fulfill predicate treefilter :: (a -> Bool) -> Tree a -> Tree a -- | is predicate true in any node of tree ? treeany :: (a -> Bool) -> Tree a -> Bool -- | show a compact ascii representation of a tree showtree :: (Show a) => Tree a -> String -- | show a compact ascii representation of a forest showforest :: (Show a) => Forest a -> String instance Show Regex -- | All the main data types, defined here to avoid import cycles. See the -- corresponding modules for documentation. module Ledger.Types type AccountName = String data Side L :: Side R :: Side data Commodity Commodity :: String -> Side -> Bool -> Bool -> Int -> Commodity -- | the commodity's symbol symbol :: Commodity -> String -- | should the symbol appear on the left or the right side :: Commodity -> Side -- | should there be a space between symbol and quantity spaced :: Commodity -> Bool -- | should thousands be comma-separated comma :: Commodity -> Bool -- | number of decimal places to display precision :: Commodity -> Int data Amount Amount :: Commodity -> Double -> Maybe MixedAmount -> Amount commodity :: Amount -> Commodity quantity :: Amount -> Double -- | optional per-unit price for this amount at the time of entry price :: Amount -> Maybe MixedAmount newtype MixedAmount Mixed :: [Amount] -> MixedAmount data TransactionType RegularTransaction :: TransactionType VirtualTransaction :: TransactionType BalancedVirtualTransaction :: TransactionType data RawTransaction RawTransaction :: AccountName -> MixedAmount -> String -> TransactionType -> RawTransaction taccount :: RawTransaction -> AccountName tamount :: RawTransaction -> MixedAmount tcomment :: RawTransaction -> String rttype :: RawTransaction -> TransactionType -- | a ledger modifier entry. Currently ignored. data ModifierEntry ModifierEntry :: String -> [RawTransaction] -> ModifierEntry valueexpr :: ModifierEntry -> String m_transactions :: ModifierEntry -> [RawTransaction] -- | a ledger periodic entry. Currently ignored. data PeriodicEntry PeriodicEntry :: String -> [RawTransaction] -> PeriodicEntry periodexpr :: PeriodicEntry -> String p_transactions :: PeriodicEntry -> [RawTransaction] data Entry Entry :: Date -> Bool -> String -> String -> String -> [RawTransaction] -> String -> Entry edate :: Entry -> Date estatus :: Entry -> Bool ecode :: Entry -> String edescription :: Entry -> String ecomment :: Entry -> String etransactions :: Entry -> [RawTransaction] epreceding_comment_lines :: Entry -> String data RawLedger RawLedger :: [ModifierEntry] -> [PeriodicEntry] -> [Entry] -> String -> RawLedger modifier_entries :: RawLedger -> [ModifierEntry] periodic_entries :: RawLedger -> [PeriodicEntry] entries :: RawLedger -> [Entry] final_comment_lines :: RawLedger -> String data TimeLogEntry TimeLogEntry :: Char -> DateTime -> String -> TimeLogEntry tlcode :: TimeLogEntry -> Char tldatetime :: TimeLogEntry -> DateTime tlcomment :: TimeLogEntry -> String data TimeLog TimeLog :: [TimeLogEntry] -> TimeLog timelog_entries :: TimeLog -> [TimeLogEntry] data Transaction Transaction :: Int -> Date -> String -> AccountName -> MixedAmount -> TransactionType -> Transaction entryno :: Transaction -> Int date :: Transaction -> Date description :: Transaction -> String account :: Transaction -> AccountName amount :: Transaction -> MixedAmount ttype :: Transaction -> TransactionType data Account Account :: AccountName -> [Transaction] -> MixedAmount -> Account aname :: Account -> AccountName atransactions :: Account -> [Transaction] abalance :: Account -> MixedAmount data Ledger Ledger :: RawLedger -> Tree AccountName -> Map AccountName Account -> Ledger rawledger :: Ledger -> RawLedger accountnametree :: Ledger -> Tree AccountName accountmap :: Ledger -> Map AccountName Account instance Eq Transaction instance Eq TimeLog instance Eq TimeLogEntry instance Ord TimeLogEntry instance Eq RawLedger instance Eq Entry instance Eq PeriodicEntry instance Eq ModifierEntry instance Eq RawTransaction instance Eq TransactionType instance Show TransactionType instance Eq MixedAmount instance Eq Amount instance Eq Commodity instance Show Commodity instance Ord Commodity instance Eq Side instance Show Side instance Ord Side -- | A Commodity is a symbol representing a currency or some other -- kind of thing we are tracking, and some display preferences that tell -- how to display Amounts of the commodity - is the symbol on the -- left or right, are thousands separated by comma, significant decimal -- places and so on. module Ledger.Commodity -- | Look up one of the hard-coded default commodities. For use in tests. comm :: String -> Commodity -- | Find the conversion rate between two commodities. Currently returns 1. conversionRate :: Commodity -> Commodity -> Double -- | An Amount is some quantity of money, shares, or anything else. -- -- A simple amount is a Commodity, quantity pair: -- --
-- $1 -- -50 -- EUR 3.44 -- GOOG 500 -- 1.5h -- 90apples -- 0 ---- -- A MixedAmount is zero or more simple amounts: -- --
-- $50, EUR 3, AAPL 500 -- 16h, $13.55, oranges 6 ---- -- Not implemented: Commodities may be convertible or not. A mixed amount -- containing only convertible commodities can be converted to a simple -- amount. Arithmetic examples: -- --
-- $1 - $5 = $-4 -- $1 + EUR 0.76 = $2 -- EUR0.76 + $1 = EUR 1.52 -- EUR0.76 - $1 = 0 -- ($5, 2h) + $1 = ($6, 2h) -- ($50, EUR 3, AAPL 500) + ($13.55, oranges 6) = $67.51, AAPL 500, oranges 6 -- ($50, EUR 3) * $-1 = $-53.96 -- ($50, AAPL 500) * $-1 = error --module Ledger.Amount -- | Apply a binary arithmetic operator to two amounts - converting to the -- second one's commodity, adopting the lowest precision, and discarding -- any price information. (Using the second commodity is best since sum -- and other folds start with a no-commodity amount.) amountop :: (Double -> Double -> Double) -> Amount -> Amount -> Amount -- | Convert an amount to the commodity of its saved price, if any. costOfAmount :: Amount -> Amount -- | Convert an amount to the specified commodity using the appropriate -- exchange rate (which is currently always 1). convertAmountTo :: Commodity -> Amount -> Amount -- | Get the string representation of an amount, based on its commodity's -- display settings. showAmount :: Amount -> String -- | Add thousands-separating commas to a decimal number string punctuatethousands :: String -> String -- | Does this amount appear to be zero when displayed with its given -- precision ? isZeroAmount :: Amount -> Bool -- | Access a mixed amount's components. amounts :: MixedAmount -> [Amount] -- | Does this mixed amount appear to be zero - empty, or containing only -- simple amounts which appear to be zero ? isZeroMixedAmount :: MixedAmount -> Bool -- | Get the string representation of a mixed amount, showing each of its -- component amounts. showMixedAmount :: MixedAmount -> String -- | Get the string representation of a mixed amount, and if it appears to -- be all zero just show a bare 0, ledger-style. showMixedAmountOrZero :: MixedAmount -> String -- | Simplify a mixed amount by combining any component amounts which have -- the same commodity and the same price. normaliseMixedAmount :: MixedAmount -> MixedAmount -- | Convert a mixed amount's component amounts to the commodity of their -- saved price, if any. costOfMixedAmount :: MixedAmount -> MixedAmount -- | The empty simple amount. nullamt :: Amount -- | The empty mixed amount. nullmixedamt :: MixedAmount -- | A temporary value for parsed transactions which had no amount -- specified. missingamt :: MixedAmount instance Ord MixedAmount instance Num MixedAmount instance Ord Amount instance Num Amount instance Show MixedAmount instance Show Amount -- | A TimeLog is a parsed timelog file (see timeclock.el or the -- command-line version) containing zero or more TimeLogEntrys. It -- can be converted to a RawLedger for querying. module Ledger.TimeLog -- | Convert a time log to a ledger. ledgerFromTimeLog :: TimeLog -> RawLedger -- | Convert time log entries to ledger entries. entriesFromTimeLogEntries :: [TimeLogEntry] -> [Entry] -- | When there is a trailing clockin entry, provide the missing clockout. -- An entry for now is what we want but this requires IO so for now use -- the clockin time, ie don't count the current clocked-in period. clockoutFor :: TimeLogEntry -> TimeLogEntry -- | Convert a timelog clockin and clockout entry to an equivalent ledger -- entry, representing the time expenditure. Note this entry is not -- balanced, since we omit the "assets:time" transaction for simpler -- output. entryFromTimeLogInOut :: TimeLogEntry -> TimeLogEntry -> Entry instance Show TimeLog instance Show TimeLogEntry -- | AccountNames are strings like assets:cash:petty. From -- a set of these we derive the account hierarchy. module Ledger.AccountName accountNameComponents :: AccountName -> [String] accountNameFromComponents :: [String] -> AccountName accountLeafName :: AccountName -> String accountNameLevel :: AccountName -> Int -- | expandAccountNames :: [AccountName] -> [AccountName] -- | topAccountNames :: [AccountName] -> [AccountName] parentAccountName :: AccountName -> AccountName parentAccountNames :: AccountName -> [AccountName] isAccountNamePrefixOf :: AccountName -> AccountName -> Bool isSubAccountNameOf :: AccountName -> AccountName -> Bool subAccountNamesFrom :: [AccountName] -> AccountName -> [AccountName] -- | We could almost get by with just the AccountName manipulations above, -- but we need smarter structures to eg display the account tree with -- boring accounts elided. This converts a list of AccountName to a tree -- (later we will convert that to a tree of Account.) accountNameTreeFrom :: [AccountName] -> Tree AccountName -- | Elide an account name to fit in the specified width. From the ledger -- 2.6 news: -- --
-- What Ledger now does is that if an account name is too long, it will -- start abbreviating the first parts of the account name down to two -- letters in length. If this results in a string that is still too -- long, the front will be elided -- not the end. For example: -- -- Expenses:Cash ; OK, not too long -- Ex:Wednesday:Cash ; Expenses was abbreviated to fit -- Ex:We:Afternoon:Cash ; Expenses and Wednesday abbreviated -- ; Expenses:Wednesday:Afternoon:Lunch:Snack:Candy:Chocolate:Cash -- ..:Af:Lu:Sn:Ca:Ch:Cash ; Abbreviated and elided! --elideAccountName :: Int -> AccountName -> AccountName -- | Check if a set of ledger account/description patterns matches the -- given account name or entry description. Patterns are case-insensitive -- regular expression strings; those beginning with - are anti-patterns. matchpats :: [String] -> String -> Bool -- | Similar to matchpats, but follows the special behaviour of ledger -- 2.6's balance command: positive patterns which do not contain : match -- the account leaf name, other patterns match the full account name. matchpats_balance :: [String] -> String -> Bool -- | Do the positives in these patterns permit a match for this string ? match_positive_pats :: [String] -> String -> Bool -- | Do the negatives in these patterns prevent a match for this string ? match_negative_pats :: [String] -> String -> Bool -- | A RawTransaction represents a single transaction line within a -- ledger entry. We call it raw to distinguish from the cached -- Transaction. module Ledger.RawTransaction showRawTransaction :: RawTransaction -> String isReal :: RawTransaction -> Bool hasAmount :: RawTransaction -> Bool instance Show RawTransaction -- | An Entry represents a regular entry in the ledger file. It -- normally contains two or more balanced RawTransactions. module Ledger.Entry -- | Show a ledger entry, formatted for the print command. ledger 2.x's -- standard format looks like this: -- --
-- yyyymmdd[ *][ CODE] description......... [ ; comment...............] -- account name 1..................... ...$amount1[ ; comment...............] -- account name 2..................... ..$-amount1[ ; comment...............] -- -- pcodewidth = no limit -- 10 -- mimicking ledger layout. -- pdescwidth = no limit -- 20 -- I don't remember what these mean, -- pacctwidth = 35 minimum, no maximum -- they were important at the time. -- pamtwidth = 11 -- pcommentwidth = no limit -- 22 --showEntry :: Entry -> String isEntryBalanced :: Entry -> Bool -- | Fill in a missing balance in this entry, if we have enough information -- to do that. Excluding virtual transactions, there should be at most -- one missing balance. Otherwise, raise an error. The new balance will -- be converted to cost basis if possible. balanceEntry :: Entry -> Entry instance Show PeriodicEntry instance Show ModifierEntry instance Show Entry -- | Parsers for standard ledger and timelog files. module Ledger.Parse parseLedgerFile :: String -> IO (Either ParseError RawLedger) printParseError :: (Show a) => a -> IO () -- | Parse a RawLedger from either a ledger file or a timelog file. It -- tries first the timelog parser then the ledger parser; this means -- parse errors for ledgers are useful while those for timelogs are not. ledgerfile :: Parser RawLedger -- | Parse a ledger file. Here is the ledger grammar from the ledger 2.5 -- manual: -- --
-- The ledger file format is quite simple, but also very flexible. It supports -- many options, though typically the user can ignore most of them. They are -- summarized below. The initial character of each line determines what the -- line means, and how it should be interpreted. Allowable initial characters -- are: -- -- NUMBER A line beginning with a number denotes an entry. It may be followed by any -- number of lines, each beginning with whitespace, to denote the entrys account -- transactions. The format of the first line is: -- -- DATE[=EDATE] [*|!] [(CODE)] DESC -- -- If * appears after the date (with optional eective date), it indicates the entry -- is cleared, which can mean whatever the user wants it t omean. If ! appears -- after the date, it indicates d the entry is pending; i.e., tentatively cleared from -- the users point of view, but not yet actually cleared. If a CODE appears in -- parentheses, it may be used to indicate a check number, or the type of the -- transaction. Following these is the payee, or a description of the transaction. -- The format of each following transaction is: -- -- ACCOUNT AMOUNT [; NOTE] -- -- The ACCOUNT may be surrounded by parentheses if it is a virtual -- transactions, or square brackets if it is a virtual transactions that must -- balance. The AMOUNT can be followed by a per-unit transaction cost, -- by specifying AMOUNT, or a complete transaction cost with @ AMOUNT. -- Lastly, the NOTE may specify an actual and/or eective date for the -- transaction by using the syntax [ACTUAL_DATE] or [=EFFECTIVE_DATE] or -- [ACTUAL_DATE=EFFECtIVE_DATE]. -- -- = An automated entry. A value expression must appear after the equal sign. -- After this initial line there should be a set of one or more transactions, just as -- if it were normal entry. If the amounts of the transactions have no commodity, -- they will be applied as modifiers to whichever real transaction is matched by -- the value expression. -- -- ~ A period entry. A period expression must appear after the tilde. -- After this initial line there should be a set of one or more transactions, just as -- if it were normal entry. -- -- ! A line beginning with an exclamation mark denotes a command directive. It -- must be immediately followed by the command word. The supported commands -- are: -- -- !include -- Include the stated ledger file. -- !account -- The account name is given is taken to be the parent of all transac- -- tions that follow, until !end is seen. -- !end Ends an account block. -- -- ; A line beginning with a colon indicates a comment, and is ignored. -- -- Y If a line begins with a capital Y, it denotes the year used for all subsequent -- entries that give a date without a year. The year should appear immediately -- after the Y, for example: Y2004. This is useful at the beginning of a file, to -- specify the year for that file. If all entries specify a year, however, this command -- has no eect. -- -- P Specifies a historical price for a commodity. These are usually found in a pricing -- history file (see the -Q option). The syntax is: -- -- P DATE SYMBOL PRICE -- -- N SYMBOL Indicates that pricing information is to be ignored for a given symbol, nor will -- quotes ever be downloaded for that symbol. Useful with a home currency, such -- as the dollar ($). It is recommended that these pricing options be set in the price -- database file, which defaults to ~/.pricedb. The syntax for this command is: -- -- N SYMBOL -- -- D AMOUNT Specifies the default commodity to use, by specifying an amount in the expected -- format. The entry command will use this commodity as the default when none -- other can be determined. This command may be used multiple times, to set -- the default flags for dierent commodities; whichever is seen last is used as the -- default commodity. For example, to set US dollars as the default commodity, -- while also setting the thousands flag and decimal flag for that commodity, use: -- -- D $1,000.00 -- -- C AMOUNT1 = AMOUNT2 -- Specifies a commodity conversion, where the first amount is given to be equiv- -- alent to the second amount. The first amount should use the decimal precision -- desired during reporting: -- -- C 1.00 Kb = 1024 bytes -- -- i, o, b, h -- These four relate to timeclock support, which permits ledger to read timelog -- files. See the timeclocks documentation for more info on the syntax of its -- timelog files. ---- -- See Tests for sample data. ledger :: Parser RawLedger ledgernondatalines :: Parser [String] ledgerdirective :: Parser String blankline :: Parser String commentline :: Parser String ledgercomment :: Parser String ledgermodifierentry :: Parser ModifierEntry ledgerperiodicentry :: Parser PeriodicEntry ledgerentry :: Parser Entry ledgerday :: Parser Day ledgerdate :: Parser Date ledgerdatetime :: Parser DateTime ledgerstatus :: Parser Bool ledgercode :: Parser String ledgertransactions :: Parser [RawTransaction] ledgertransaction :: Parser RawTransaction virtualtransaction :: Parser RawTransaction balancedvirtualtransaction :: Parser RawTransaction -- | account names may have single spaces inside them, and are terminated -- by two or more spaces ledgeraccountname :: Parser String transactionamount :: Parser MixedAmount leftsymbolamount :: Parser MixedAmount rightsymbolamount :: Parser MixedAmount nosymbolamount :: Parser MixedAmount commoditysymbol :: Parser String priceamount :: Parser (Maybe MixedAmount) -- | parse a ledger-style numeric quantity and also return the number of -- digits to the right of the decimal point and whether thousands are -- separated by comma. amountquantity :: Parser (Double, Int, Bool) -- | parse the two strings of digits before and after a possible decimal -- point. The integer part may contain commas, or either part may be -- empty, or there may be no point. numberparts :: Parser (String, String) numberpartsstartingwithdigit :: Parser (String, String) numberpartsstartingwithpoint :: Parser (String, String) spacenonewline :: Parser Char restofline :: Parser String whiteSpace1 :: Parser () -- | Parse a timelog file. Here is the timelog grammar, from timeclock.el -- 2.6: -- --
-- A timelog contains data in the form of a single entry per line. -- Each entry has the form: -- -- CODE YYYYMMDD HH:MM:SS [COMMENT] -- -- CODE is one of: b, h, i, o or O. COMMENT is optional when the code is -- i, o or O. The meanings of the codes are: -- -- b Set the current time balance, or "time debt". Useful when -- archiving old log data, when a debt must be carried forward. -- The COMMENT here is the number of seconds of debt. -- -- h Set the required working time for the given day. This must -- be the first entry for that day. The COMMENT in this case is -- the number of hours in this workday. Floating point amounts -- are allowed. -- -- i Clock in. The COMMENT in this case should be the name of the -- project worked on. -- -- o Clock out. COMMENT is unnecessary, but can be used to provide -- a description of how the period went, for example. -- -- O Final clock out. Whatever project was being worked on, it is -- now finished. Useful for creating summary reports. ---- -- Example: -- -- i 20070310 12:26:00 hledger o 20070310 17:26:02 timelog :: Parser TimeLog timelogentry :: Parser TimeLogEntry ledgerfromtimelog :: Parser RawLedger -- | Parse a date in any of the formats allowed in ledger's period -- expressions: -- --
-- 2004 -- 2004/10 -- 2004/10/1 -- 10/1 -- october -- oct -- this week # or day, month, quarter, year -- next week -- last week --smartdate :: Parser (String, String, String) ymd :: Parser (String, String, String) ym :: Parser (String, String, String) y :: Parser (String, String, String) -- | Parse a flexible date string, with awareness of the current time, | -- and return a Date or raise an error. smartparsedate :: String -> Date -- | A Transaction is a RawTransaction with its parent -- Entry 's date and description attached. These are what we -- actually query when doing reports. module Ledger.Transaction showTransaction :: Transaction -> String -- | Convert a Entry to two or more Transactions. An id -- number is attached to the transactions to preserve their grouping - it -- should be unique per entry. flattenEntry :: (Entry, Int) -> [Transaction] accountNamesFromTransactions :: [Transaction] -> [AccountName] sumTransactions :: [Transaction] -> MixedAmount instance Show Transaction -- | A RawLedger is a parsed ledger file. We call it raw to -- distinguish from the cached Ledger. module Ledger.RawLedger rawLedgerTransactions :: RawLedger -> [Transaction] rawLedgerAccountNamesUsed :: RawLedger -> [AccountName] rawLedgerAccountNames :: RawLedger -> [AccountName] rawLedgerAccountNameTree :: RawLedger -> Tree AccountName -- | Remove ledger entries we are not interested in. Keep only those which -- fall between the begin and end dates, and match the description -- pattern, and are cleared or real if those options are active. filterRawLedger :: Maybe Date -> Maybe Date -> [String] -> Bool -> Bool -> RawLedger -> RawLedger -- | Keep only entries whose description matches the description patterns. filterRawLedgerEntriesByDescription :: [String] -> RawLedger -> RawLedger -- | Keep only entries which fall between begin and end dates. We include -- entries on the begin date and exclude entries on the end date, like -- ledger. An empty date string means no restriction. filterRawLedgerEntriesByDate :: Maybe Date -> Maybe Date -> RawLedger -> RawLedger -- | Keep only entries with cleared status, if the flag is true, otherwise -- do no filtering. filterRawLedgerEntriesByClearedStatus :: Bool -> RawLedger -> RawLedger -- | Strip out any virtual transactions, if the flag is true, otherwise do -- no filtering. filterRawLedgerTransactionsByRealness :: Bool -> RawLedger -> RawLedger -- | Keep only entries which affect accounts matched by the account -- patterns. filterRawLedgerEntriesByAccount :: [String] -> RawLedger -> RawLedger -- | Give all a ledger's amounts their canonical display settings. That is, -- in each commodity, amounts will use the display settings of the first -- amount detected, and the greatest precision of the amounts detected. -- Also, amounts are converted to cost basis if that flag is active. canonicaliseAmounts :: Bool -> RawLedger -> RawLedger -- | Get all amount commodities with a given symbol, in the order parsed. -- Must be called with a good symbol or it will fail. rawLedgerCommoditiesWithSymbol :: RawLedger -> String -> [Commodity] -- | Get just the ammount commodities from a ledger, in the order parsed. rawLedgerCommodities :: RawLedger -> [Commodity] -- | Get just the amounts from a ledger, in the order parsed. rawLedgerAmounts :: RawLedger -> [MixedAmount] -- | Get just the amount precisions from a ledger, in the order parsed. rawLedgerPrecisions :: RawLedger -> [Int] instance Show RawLedger -- | An Account stores, for efficiency: an AccountName, all -- transactions in the account (excluding subaccounts), and the account -- balance (including subaccounts). module Ledger.Account instance Eq Account instance Show Account -- | A Ledger stores, for efficiency, a RawLedger plus its -- tree of account names, and a map from account names to -- Accounts. It may also have had uninteresting Entrys and -- Transactions filtered out. module Ledger.Ledger -- | Convert a raw ledger to a more efficient cached type, described above. cacheLedger :: [String] -> RawLedger -> Ledger filtertxns :: [String] -> [Transaction] -> [Transaction] -- | List a ledger's account names. accountnames :: Ledger -> [AccountName] -- | Get the named account from a ledger. ledgerAccount :: Ledger -> AccountName -> Account -- | List a ledger's accounts, in tree order accounts :: Ledger -> [Account] -- | List a ledger's top-level accounts, in tree order topAccounts :: Ledger -> [Account] -- | Accounts in ledger whose name matches the pattern, in tree order. accountsMatching :: [String] -> Ledger -> [Account] -- | List a ledger account's immediate subaccounts subAccounts :: Ledger -> Account -> [Account] -- | List a ledger's transactions. ledgerTransactions :: Ledger -> [Transaction] -- | Get a ledger's tree of accounts to the specified depth. ledgerAccountTree :: Int -> Ledger -> Tree Account -- | Get a ledger's tree of accounts rooted at the specified account. ledgerAccountTreeAt :: Ledger -> Account -> Maybe (Tree Account) instance Show Ledger -- | The Ledger package allows parsing and querying of ledger files. It -- generally provides a compatible subset of C++ ledger's functionality. module Ledger