hledger-lib-0.18.2: Core data types, parsers and utilities for the hledger accounting tool.

Safe HaskellSafe-Infered

Hledger.Read.JournalReader

Contents

Description

A reader for hledger's journal file format (http://hledger.org/MANUAL.html#the-journal-file). hledger's journal format is a compatible subset of c++ ledger's (http://ledger-cli.org/3.0/doc/ledger3.html#Journal-Format), so this reader should handle many ledger files as well. Example:

2012/3/24 gift
    expenses:gifts  $10
    assets:cash

Synopsis

Reader

Parsers used elsewhere

parseJournalWith :: GenParser Char JournalContext (JournalUpdate, JournalContext) -> FilePath -> String -> ErrorT String IO JournalSource

Given a JournalUpdate-generating parsec parser, file path and data string, parse and post-process a Journal so that it's ready to use, or give an error.

journal :: GenParser Char JournalContext (JournalUpdate, JournalContext)Source

Top-level journal parser. Returns a single composite, I/O performing, error-raising JournalUpdate (and final JournalContext) which can be applied to an empty journal to get the final result.

datetime :: GenParser Char JournalContext LocalTimeSource

Parse a date and time in YYYYMMDD HH:MM[:SS][+-ZZZZ] format. Any timezone will be ignored; the time is treated as local time. Fewer digits are allowed, except in the timezone. The year may be omitted if a default year has already been set.

accountname :: GenParser Char st AccountNameSource

Parse an account name. Account names may have single spaces inside them, and are terminated by two or more spaces. They should have one or more components of at least one character, separated by the account separator char.

amount :: GenParser Char JournalContext MixedAmountSource

Parse an amount, with an optional left or right currency symbol and optional price.

amount' :: String -> MixedAmountSource

Run the amount parser on a string to get the result or an error.

Tests