hledger-lib-1.3: Core data types, parsers and functionality for the hledger accounting tools

Safe Haskell | None
Language | Haskell2010

Hledger.Data.Posting

Contents

- Posting
- operations
- date operations
- account name operations
- transaction description operations
- arithmetic
- rendering
- misc.
- Orphan instances

Description

A `Posting` represents a change (by some `MixedAmount`) of the balance in some `Account`. Each `Transaction` contains two or more postings which should add up to 0. Postings reference their parent transaction, so we can look up the date or description there.

Synopsis

- nullposting :: Posting
- posting :: Posting
- post :: AccountName -> Amount -> Posting
- originalPosting :: Posting -> Posting
- postingStatus :: Posting -> Status
- isReal :: Posting -> Bool
- isVirtual :: Posting -> Bool
- isBalancedVirtual :: Posting -> Bool
- isEmptyPosting :: Posting -> Bool
- isAssignment :: Posting -> Bool
- hasAmount :: Posting -> Bool
- postingAllTags :: Posting -> [Tag]
- transactionAllTags :: Transaction -> [Tag]
- postingAllImplicitTags :: Posting -> [Tag]
- relatedPostings :: Posting -> [Posting]
- removePrices :: Posting -> Posting
- postingDate :: Posting -> Day
- postingDate2 :: Posting -> Day
- isPostingInDateSpan :: DateSpan -> Posting -> Bool
- isPostingInDateSpan' :: WhichDate -> DateSpan -> Posting -> Bool
- postingsDateSpan :: [Posting] -> DateSpan
- postingsDateSpan' :: WhichDate -> [Posting] -> DateSpan
- accountNamesFromPostings :: [Posting] -> [AccountName]
- accountNamePostingType :: AccountName -> PostingType
- accountNameWithoutPostingType :: AccountName -> AccountName
- accountNameWithPostingType :: PostingType -> AccountName -> AccountName
- joinAccountNames :: AccountName -> AccountName -> AccountName
- concatAccountNames :: [AccountName] -> AccountName
- accountNameApplyAliases :: [AccountAlias] -> AccountName -> AccountName
- accountNameApplyAliasesMemo :: [AccountAlias] -> AccountName -> AccountName
- transactionPayee :: Transaction -> Text
- transactionNote :: Transaction -> Text
- payeeAndNoteFromDescription :: Text -> (Text, Text)
- sumPostings :: [Posting] -> MixedAmount
- showPosting :: Posting -> String
- showComment :: Text -> String
- tests_Hledger_Data_Posting :: Test

# Posting

nullposting :: Posting #

posting :: Posting #

post :: AccountName -> Amount -> Posting #

# operations

originalPosting :: Posting -> Posting #

postingStatus :: Posting -> Status #

Get a posting's status. This is cleared or pending if those are explicitly set on the posting, otherwise the status of its parent transaction, or unmarked if there is no parent transaction. (Note the ambiguity, unmarked can mean "posting and transaction are both unmarked" or "posting is unmarked and don't know about the transaction".

isReal :: Posting -> Bool #

isVirtual :: Posting -> Bool #

isBalancedVirtual :: Posting -> Bool #

isEmptyPosting :: Posting -> Bool #

isAssignment :: Posting -> Bool #

hasAmount :: Posting -> Bool #

postingAllTags :: Posting -> [Tag] #

Tags for this posting including any inherited from its parent transaction.

transactionAllTags :: Transaction -> [Tag] #

Tags for this transaction including any from its postings.

postingAllImplicitTags :: Posting -> [Tag] #

Tags for this posting including implicit and any inherited from its parent transaction.

relatedPostings :: Posting -> [Posting] #

removePrices :: Posting -> Posting #

Remove all prices of a posting

# date operations

postingDate :: Posting -> Day #

Get a posting's (primary) date - it's own primary date if specified, otherwise the parent transaction's primary date, or the null date if there is no parent transaction.

postingDate2 :: Posting -> Day #

Get a posting's secondary (secondary) date, which is the first of: posting's secondary date, transaction's secondary date, posting's primary date, transaction's primary date, or the null date if there is no parent transaction.

isPostingInDateSpan :: DateSpan -> Posting -> Bool #

Does this posting fall within the given date span ?

isPostingInDateSpan' :: WhichDate -> DateSpan -> Posting -> Bool #

postingsDateSpan :: [Posting] -> DateSpan #

Get the minimal date span which contains all the postings, or the null date span if there are none.

postingsDateSpan' :: WhichDate -> [Posting] -> DateSpan #

# account name operations

accountNamesFromPostings :: [Posting] -> [AccountName] #

accountNamePostingType :: AccountName -> PostingType #

accountNameWithoutPostingType :: AccountName -> AccountName #

accountNameWithPostingType :: PostingType -> AccountName -> AccountName #

joinAccountNames :: AccountName -> AccountName -> AccountName #

Prefix one account name to another, preserving posting type indicators like concatAccountNames.

concatAccountNames :: [AccountName] -> AccountName #

Join account names into one. If any of them has () or [] posting type indicators, these (the first type encountered) will also be applied to the resulting account name.

accountNameApplyAliases :: [AccountAlias] -> AccountName -> AccountName #

Rewrite an account name using all matching aliases from the given list, in sequence. Each alias sees the result of applying the previous aliases.

accountNameApplyAliasesMemo :: [AccountAlias] -> AccountName -> AccountName #

Memoising version of accountNameApplyAliases, maybe overkill.

# transaction description operations

transactionPayee :: Transaction -> Text #

transactionNote :: Transaction -> Text #

payeeAndNoteFromDescription :: Text -> (Text, Text) #

Parse a transaction's description into payee and note (aka narration) fields, assuming a convention of separating these with | (like Beancount). Ie, everything up to the first | is the payee, everything after it is the note. When there's no |, payee == note == description.

# arithmetic

sumPostings :: [Posting] -> MixedAmount #

# rendering

showPosting :: Posting -> String #

# misc.

showComment :: Text -> String #

tests_Hledger_Data_Posting :: Test #

# Orphan instances

Show Posting # |
Methods showsPrec :: Int -> Posting -> ShowS # show :: Posting -> String # showList :: [Posting] -> ShowS #