Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The Hledger.Data library allows parsing and querying of C++ ledger-style journal files. It generally provides a compatible subset of C++ ledger's functionality. This package re-exports all the Hledger.Data.* modules (except UTF8, which requires an explicit import.)
Synopsis
- module Hledger.Data.Account
- module Hledger.Data.AccountName
- module Hledger.Data.Amount
- module Hledger.Data.Balancing
- module Hledger.Data.Dates
- module Hledger.Data.Errors
- module Hledger.Data.Journal
- module Hledger.Data.JournalChecks
- module Hledger.Data.Json
- module Hledger.Data.Ledger
- module Hledger.Data.Period
- module Hledger.Data.PeriodicTransaction
- module Hledger.Data.Posting
- module Hledger.Data.RawOptions
- module Hledger.Data.StringFormat
- module Hledger.Data.Timeclock
- module Hledger.Data.Transaction
- module Hledger.Data.TransactionModifier
- type Year = Integer
- data Ledger = Ledger {}
- data NormalSign
- data Account = Account {}
- data AccountDeclarationInfo = AccountDeclarationInfo {
- adicomment :: Text
- aditags :: [Tag]
- adideclarationorder :: Int
- adisourcepos :: SourcePos
- newtype TagDeclarationInfo = TagDeclarationInfo {
- tdicomment :: Text
- data PayeeDeclarationInfo = PayeeDeclarationInfo {
- pdicomment :: Text
- pditags :: [Tag]
- type StorageFormat = String
- type ParsedJournal = Journal
- data Journal = Journal {
- jparsedefaultyear :: Maybe Year
- jparsedefaultcommodity :: Maybe (CommoditySymbol, AmountStyle)
- jparsedecimalmark :: Maybe DecimalMark
- jparseparentaccounts :: [AccountName]
- jparsealiases :: [AccountAlias]
- jparsetimeclockentries :: [TimeclockEntry]
- jincludefilestack :: [FilePath]
- jdeclaredpayees :: [(Payee, PayeeDeclarationInfo)]
- jdeclaredtags :: [(TagName, TagDeclarationInfo)]
- jdeclaredaccounts :: [(AccountName, AccountDeclarationInfo)]
- jdeclaredaccounttags :: Map AccountName [Tag]
- jdeclaredaccounttypes :: Map AccountType [AccountName]
- jaccounttypes :: Map AccountName AccountType
- jglobalcommoditystyles :: Map CommoditySymbol AmountStyle
- jcommodities :: Map CommoditySymbol Commodity
- jinferredcommodities :: Map CommoditySymbol AmountStyle
- jpricedirectives :: [PriceDirective]
- jinferredmarketprices :: [MarketPrice]
- jtxnmodifiers :: [TransactionModifier]
- jperiodictxns :: [PeriodicTransaction]
- jtxns :: [Transaction]
- jfinalcommentlines :: Text
- jfiles :: [(FilePath, Text)]
- jlastreadtime :: POSIXTime
- data MarketPrice = MarketPrice {
- mpdate :: Day
- mpfrom :: CommoditySymbol
- mpto :: CommoditySymbol
- mprate :: Quantity
- data PriceDirective = PriceDirective {}
- data TimeclockEntry = TimeclockEntry {
- tlsourcepos :: SourcePos
- tlcode :: TimeclockCode
- tldatetime :: LocalTime
- tlaccount :: AccountName
- tldescription :: Text
- tlcomment :: Text
- tltags :: [Tag]
- data TimeclockCode
- = SetBalance
- | SetRequiredHours
- | In
- | Out
- | FinalOut
- data PeriodicTransaction = PeriodicTransaction {
- ptperiodexpr :: Text
- ptinterval :: Interval
- ptspan :: DateSpan
- ptsourcepos :: (SourcePos, SourcePos)
- ptstatus :: Status
- ptcode :: Text
- ptdescription :: Text
- ptcomment :: Text
- pttags :: [Tag]
- ptpostings :: [Posting]
- data TMPostingRule = TMPostingRule {}
- data TransactionModifier = TransactionModifier {}
- data Transaction = Transaction {}
- data Posting = Posting {
- pdate :: Maybe Day
- pdate2 :: Maybe Day
- pstatus :: Status
- paccount :: AccountName
- pamount :: MixedAmount
- pcomment :: Text
- ptype :: PostingType
- ptags :: [Tag]
- pbalanceassertion :: Maybe BalanceAssertion
- ptransaction :: Maybe Transaction
- poriginal :: Maybe Posting
- data BalanceAssertion = BalanceAssertion {
- baamount :: Amount
- batotal :: Bool
- bainclusive :: Bool
- baposition :: SourcePos
- data Status
- type DateTag = (TagName, Day)
- type Tag = (TagName, TagValue)
- type TagValue = Text
- type TagName = Text
- data PostingType
- pattern MixedAmountKeyUnitPrice :: !CommoditySymbol -> !CommoditySymbol -> !Quantity -> MixedAmountKey
- pattern MixedAmountKeyNoPrice :: !CommoditySymbol -> MixedAmountKey
- pattern MixedAmountKeyTotalPrice :: !CommoditySymbol -> !CommoditySymbol -> MixedAmountKey
- data MixedAmount
- class HasAmounts a where
- styleAmounts :: Map CommoditySymbol AmountStyle -> a -> a
- data Amount = Amount {
- acommodity :: !CommoditySymbol
- aquantity :: !Quantity
- astyle :: !AmountStyle
- aprice :: !(Maybe AmountPrice)
- data Commodity = Commodity {}
- type CommoditySymbol = Text
- data DigitGroupStyle = DigitGroups !Char ![Word8]
- data Rounding
- data AmountPrecision
- data AmountStyle = AmountStyle {
- ascommodityside :: !Side
- ascommodityspaced :: !Bool
- asdigitgroups :: !(Maybe DigitGroupStyle)
- asdecimalmark :: !(Maybe Char)
- asprecision :: !AmountPrecision
- asrounding :: !Rounding
- data AmountPrice
- = UnitPrice !Amount
- | TotalPrice !Amount
- type Quantity = Decimal
- type DecimalMark = Char
- data Side
- data AccountAlias
- data AccountType
- type AccountName = Text
- type Payee = Text
- data Interval
- data Period
- data DateSpan = DateSpan (Maybe EFDay) (Maybe EFDay)
- data EFDay
- data WhichDate
- data SmartInterval
- data SmartDate
- type WeekDay = Int
- type MonthDay = Int
- type YearDay = Int
- type MonthWeek = Int
- type YearWeek = Int
- type Quarter = Int
- type Month = Int
- fromEFDay :: EFDay -> Day
- modifyEFDay :: (Day -> Day) -> EFDay -> EFDay
- isBalanceSheetAccountType :: AccountType -> Bool
- isIncomeStatementAccountType :: AccountType -> Bool
- isAccountSubtypeOf :: AccountType -> AccountType -> Bool
- isDecimalMark :: Char -> Bool
- maCompare :: MixedAmount -> MixedAmount -> Ordering
- nulltransactionmodifier :: TransactionModifier
- nullperiodictransaction :: PeriodicTransaction
- nullpayeedeclarationinfo :: PayeeDeclarationInfo
- nulltagdeclarationinfo :: TagDeclarationInfo
- nullaccountdeclarationinfo :: AccountDeclarationInfo
- module Hledger.Data.Valuation
- tests_Data :: TestTree
Documentation
module Hledger.Data.Account
module Hledger.Data.AccountName
module Hledger.Data.Amount
module Hledger.Data.Balancing
module Hledger.Data.Dates
module Hledger.Data.Errors
module Hledger.Data.Journal
module Hledger.Data.JournalChecks
module Hledger.Data.Json
module Hledger.Data.Ledger
module Hledger.Data.Period
module Hledger.Data.Posting
module Hledger.Data.RawOptions
module Hledger.Data.StringFormat
module Hledger.Data.Timeclock
module Hledger.Data.Transaction
A Ledger has the journal it derives from, and the accounts derived from that. Accounts are accessible both list-wise and tree-wise, since each one knows its parent and subs; the first account is the root of the tree and always exists.
Instances
ToJSON Ledger Source # | |
Generic Ledger Source # | |
Show Ledger Source # | |
type Rep Ledger Source # | |
Defined in Hledger.Data.Types type Rep Ledger = D1 ('MetaData "Ledger" "Hledger.Data.Types" "hledger-lib-1.32-78KesjPI2Gi6CIeTMg9npo" 'False) (C1 ('MetaCons "Ledger" 'PrefixI 'True) (S1 ('MetaSel ('Just "ljournal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Journal) :*: S1 ('MetaSel ('Just "laccounts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Account]))) |
data NormalSign Source #
Whether an account's balance is normally a positive number (in accounting terms, a debit balance) or a negative number (credit balance). Assets and expenses are normally positive (debit), while liabilities, equity and income are normally negative (credit). https://en.wikipedia.org/wiki/Normal_balance
Instances
Show NormalSign Source # | |
Defined in Hledger.Data.Types showsPrec :: Int -> NormalSign -> ShowS # show :: NormalSign -> String # showList :: [NormalSign] -> ShowS # | |
Eq NormalSign Source # | |
Defined in Hledger.Data.Types (==) :: NormalSign -> NormalSign -> Bool # (/=) :: NormalSign -> NormalSign -> Bool # |
An account, with its balances, parent/subaccount relationships, etc. Only the name is required; the other fields are added when needed.
Account | |
|
Instances
data AccountDeclarationInfo Source #
Extra information about an account that can be derived from its account directive (and the other account directives).
AccountDeclarationInfo | |
|
Instances
newtype TagDeclarationInfo Source #
Extra information found in a tag directive.
TagDeclarationInfo | |
|
Instances
data PayeeDeclarationInfo Source #
Extra information found in a payee directive.
PayeeDeclarationInfo | |
|
Instances
type StorageFormat = String Source #
The id of a data format understood by hledger, eg journal
or csv
.
The --output-format option selects one of these for output.
type ParsedJournal = Journal Source #
A journal in the process of being parsed, not yet finalised. The data is partial, and list fields are in reverse order.
A Journal, containing transactions and various other things. The basic data model for hledger.
This is used during parsing (as the type alias ParsedJournal), and then finalised/validated for use as a Journal. Some extra parsing-related fields are included for convenience, at least for now. In a ParsedJournal these are updated as parsing proceeds, in a Journal they represent the final state at end of parsing (used eg by the add command).
Journal | |
|
Instances
data MarketPrice Source #
A historical market price (exchange rate) from one commodity to another. A more concise form of a PriceDirective, without the amount display info.
MarketPrice | |
|
Instances
data PriceDirective Source #
A market price declaration made by the journal format's P directive. It declares two things: a historical exchange rate between two commodities, and an amount display style for the second commodity.
Instances
data TimeclockEntry Source #
TimeclockEntry | |
|
Instances
data TimeclockCode Source #
Instances
data PeriodicTransaction Source #
A periodic transaction rule, describing a transaction that recurs.
PeriodicTransaction | |
|
Instances
data TMPostingRule Source #
A transaction modifier transformation, which adds an extra posting to the matched posting's transaction. Can be like a regular posting, or can have the tmprIsMultiplier flag set, indicating that it's a multiplier for the matched posting's amount.
Instances
data TransactionModifier Source #
A transaction modifier rule. This has a query which matches postings in the journal, and a list of transformations to apply to those postings or their transactions. Currently there is one kind of transformation: the TMPostingRule, which adds a posting ("auto posting") to the transaction, optionally setting its amount to the matched posting's amount multiplied by a constant.
Instances
data Transaction Source #
Transaction | |
|
Instances
Posting | |
|
Instances
data BalanceAssertion Source #
A balance assertion is a declaration about an account's expected balance at a certain point (posting date and parse order). They provide additional error checking and readability to a journal file.
A balance assignments is an instruction to hledger to adjust an account's balance to a certain amount at a certain point.
The BalanceAssertion
type is used for representing both of these.
hledger supports multiple kinds of balance assertions/assignments, which differ in whether they refer to a single commodity or all commodities, and the (subaccount-)inclusive or exclusive account balance.
BalanceAssertion | |
|
Instances
The status of a transaction or posting, recorded with a status mark (nothing, !, or *). What these mean is ultimately user defined.
Instances
FromJSON Status Source # | |
Defined in Hledger.Data.Json | |
ToJSON Status Source # | |
Bounded Status Source # | |
Enum Status Source # | |
Defined in Hledger.Data.Types | |
Generic Status Source # | |
Show Status Source # | |
Eq Status Source # | |
Ord Status Source # | |
type Rep Status Source # | |
Defined in Hledger.Data.Types type Rep Status = D1 ('MetaData "Status" "Hledger.Data.Types" "hledger-lib-1.32-78KesjPI2Gi6CIeTMg9npo" 'False) (C1 ('MetaCons "Unmarked" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Pending" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Cleared" 'PrefixI 'False) (U1 :: Type -> Type))) |
data PostingType Source #
Instances
pattern MixedAmountKeyUnitPrice :: !CommoditySymbol -> !CommoditySymbol -> !Quantity -> MixedAmountKey Source #
pattern MixedAmountKeyNoPrice :: !CommoditySymbol -> MixedAmountKey Source #
pattern MixedAmountKeyTotalPrice :: !CommoditySymbol -> !CommoditySymbol -> MixedAmountKey Source #
data MixedAmount Source #
Instances
class HasAmounts a where Source #
Types with this class have one or more amounts, which can have display styles applied to them.
styleAmounts :: Map CommoditySymbol AmountStyle -> a -> a Source #
Instances
Amount | |
|
Instances
FromJSON Amount Source # | |
Defined in Hledger.Data.Json | |
ToJSON Amount Source # | |
Generic Amount Source # | |
Num Amount Source # | |
Show Amount Source # | |
Eq Amount Source # | |
Ord Amount Source # | |
HasAmounts Amount Source # | |
Defined in Hledger.Data.Amount styleAmounts :: Map CommoditySymbol AmountStyle -> Amount -> Amount Source # | |
type Rep Amount Source # | |
Defined in Hledger.Data.Types type Rep Amount = D1 ('MetaData "Amount" "Hledger.Data.Types" "hledger-lib-1.32-78KesjPI2Gi6CIeTMg9npo" 'False) (C1 ('MetaCons "Amount" 'PrefixI 'True) ((S1 ('MetaSel ('Just "acommodity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 CommoditySymbol) :*: S1 ('MetaSel ('Just "aquantity") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Quantity)) :*: (S1 ('MetaSel ('Just "astyle") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AmountStyle) :*: S1 ('MetaSel ('Just "aprice") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe AmountPrice))))) |
Instances
ToJSON Commodity Source # | |
Generic Commodity Source # | |
Show Commodity Source # | |
Eq Commodity Source # | |
type Rep Commodity Source # | |
Defined in Hledger.Data.Types type Rep Commodity = D1 ('MetaData "Commodity" "Hledger.Data.Types" "hledger-lib-1.32-78KesjPI2Gi6CIeTMg9npo" 'False) (C1 ('MetaCons "Commodity" 'PrefixI 'True) (S1 ('MetaSel ('Just "csymbol") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CommoditySymbol) :*: S1 ('MetaSel ('Just "cformat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe AmountStyle)))) |
type CommoditySymbol = Text Source #
data DigitGroupStyle Source #
A style for displaying digit groups in the integer part of a floating point number. It consists of the character used to separate groups (comma or period, whichever is not used as decimal point), and the size of each group, starting with the one nearest the decimal point. The last group size is assumed to repeat. Eg, comma between thousands is DigitGroups ',' [3].
DigitGroups !Char ![Word8] |
Instances
"Rounding strategy" - how to apply an AmountStyle's display precision to a posting amount (and its cost, if any). Mainly used to customise print's output, with --round=none|soft|hard|all.
NoRounding | keep display precisions unchanged in amt and cost |
SoftRounding | do soft rounding of amt and cost amounts (show more or fewer decimal zeros to approximate the target precision, but don't hide significant digits) |
HardRounding | do hard rounding of amt (use the exact target precision, possibly hiding significant digits), and soft rounding of cost |
AllRounding | do hard rounding of amt and cost |
Instances
FromJSON Rounding Source # | |
Defined in Hledger.Data.Json | |
ToJSON Rounding Source # | |
Generic Rounding Source # | |
Read Rounding Source # | |
Show Rounding Source # | |
Eq Rounding Source # | |
Ord Rounding Source # | |
Defined in Hledger.Data.Types | |
type Rep Rounding Source # | |
Defined in Hledger.Data.Types type Rep Rounding = D1 ('MetaData "Rounding" "Hledger.Data.Types" "hledger-lib-1.32-78KesjPI2Gi6CIeTMg9npo" 'False) ((C1 ('MetaCons "NoRounding" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SoftRounding" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HardRounding" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AllRounding" 'PrefixI 'False) (U1 :: Type -> Type))) |
data AmountPrecision Source #
The "display precision" for a hledger amount, by which we mean the number of decimal digits to display to the right of the decimal mark.
Precision !Word8 | show this many decimal digits (0..255) |
NaturalPrecision | show all significant decimal digits stored internally |
Instances
data AmountStyle Source #
Every Amount has one of these, influencing how the amount is displayed. Also, each Commodity can have one, which can be applied to its amounts for consistent display. See also Amount.AmountDisplayOpts.
AmountStyle | |
|
Instances
data AmountPrice Source #
An amount's per-unit or total cost/selling price in another
commodity, as recorded in the journal entry eg with or
@.
Cost, formerly AKA "transaction price". The amount is always positive.
Instances
type DecimalMark = Char Source #
One of the decimal marks we support: either period or comma.
data AccountAlias Source #
Instances
data AccountType Source #
Asset | |
Liability | |
Equity | |
Revenue | |
Expense | |
Cash | a subtype of Asset - liquid assets to show in cashflow report |
Conversion | a subtype of Equity - account in which to generate conversion postings for transaction prices |
Instances
type AccountName = Text Source #
NoInterval | |
Days Int | |
Weeks Int | |
Months Int | |
Quarters Int | |
Years Int | |
DayOfMonth Int | |
WeekdayOfMonth Int Int | |
DaysOfWeek [Int] | |
DayOfYear Int Int |
Instances
DayPeriod Day | |
WeekPeriod Day | |
MonthPeriod Year Month | |
QuarterPeriod Year Quarter | |
YearPeriod Year | |
PeriodBetween Day Day | |
PeriodFrom Day | |
PeriodTo Day | |
PeriodAll |
Instances
A possibly open-ended span of time, from an optional inclusive start date to an optional exclusive end date. Each date can be either exact or flexible. An "exact date span" is a Datepan with exact start and end dates.
Instances
ToJSON DateSpan Source # | |
Generic DateSpan Source # | |
Show DateSpan Source # | |
Default DateSpan Source # | |
Defined in Hledger.Data.Types | |
Eq DateSpan Source # | |
Ord DateSpan Source # | |
Defined in Hledger.Data.Types | |
type Rep DateSpan Source # | |
Defined in Hledger.Data.Types type Rep DateSpan = D1 ('MetaData "DateSpan" "Hledger.Data.Types" "hledger-lib-1.32-78KesjPI2Gi6CIeTMg9npo" 'False) (C1 ('MetaCons "DateSpan" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe EFDay)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe EFDay)))) |
A date which is either exact or flexible. Flexible dates are allowed to be adjusted in certain situations.
Instances
ToJSON EFDay Source # | |
Generic EFDay Source # | |
Show EFDay Source # | |
Eq EFDay Source # | |
Ord EFDay Source # | |
type Rep EFDay Source # | |
Defined in Hledger.Data.Types type Rep EFDay = D1 ('MetaData "EFDay" "Hledger.Data.Types" "hledger-lib-1.32-78KesjPI2Gi6CIeTMg9npo" 'False) (C1 ('MetaCons "Exact" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Day)) :+: C1 ('MetaCons "Flex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Day))) |
Instances
data SmartInterval Source #
Instances
Show SmartInterval Source # | |
Defined in Hledger.Data.Types showsPrec :: Int -> SmartInterval -> ShowS # show :: SmartInterval -> String # showList :: [SmartInterval] -> ShowS # |
A possibly incomplete year-month-day date provided by the user, to be
interpreted as either a date or a date span depending on context. Missing
parts "on the left" will be filled from the provided reference date, e.g. if
the year and month are missing, the reference date's year and month are used.
Missing parts "on the right" are assumed, when interpreting as a date, to be
1, (e.g. if the year and month are present but the day is missing, it means
first day of that month); or when interpreting as a date span, to be a
wildcard (so it would mean all days of that month). See the smartdate
parser for more examples.
Or, one of the standard periods and an offset relative to the reference date: (last|this|next) (day|week|month|quarter|year), where "this" means the period containing the reference date.
isAccountSubtypeOf :: AccountType -> AccountType -> Bool Source #
Check whether the first argument is a subtype of the second: either equal or one of the defined subtypes.
isDecimalMark :: Char -> Bool Source #
maCompare :: MixedAmount -> MixedAmount -> Ordering Source #
Compare two MixedAmounts, substituting 0 for the quantity of any missing commodities in either.
module Hledger.Data.Valuation