hledger-lib-1.21: A reusable library providing the core functionality of hledger
Safe HaskellNone
LanguageHaskell2010

Hledger.Reports.AccountTransactionsReport

Description

An account-centric transactions report.

Synopsis

Documentation

type AccountTransactionsReport = [AccountTransactionsReportItem] Source #

An account transactions report represents transactions affecting a particular account (or possibly several accounts, but we don't use that). It is used eg by hledger-ui's and hledger-web's register view, and hledger's aregister report, where we want to show one row per transaction, in the context of the current account. Report items consist of:

  • the transaction, unmodified
  • the transaction as seen in the context of the current account and query, which means:
  • the transaction date is set to the "transaction context date", which can be different from the transaction's general date: if postings to the current account (and matched by the report query) have their own dates, it's the earliest of these dates.
  • the transaction's postings are filtered, excluding any which are not matched by the report query
  • a text description of the other account(s) posted to/from
  • a flag indicating whether there's more than one other account involved
  • the total increase/decrease to the current account
  • the report transactions' running total after this transaction; or if historical balance is requested (-H), the historical running total. The historical running total includes transactions from before the report start date if one is specified, filtered by the report query. The historical running total may or may not be the account's historical running balance, depending on the report query.

Items are sorted by transaction register date (the earliest date the transaction posts to the current account), most recent first. Reporting intervals are currently ignored.

accountTransactionsReportItems :: Query -> Query -> MixedAmount -> (MixedAmount -> MixedAmount) -> [Transaction] -> [AccountTransactionsReportItem] Source #

Generate transactions report items from a list of transactions, using the provided user-specified report query, a query specifying which account to use as the focus, a starting balance, a sign-setting function and a balance-summing function. Or with a None current account query, this can also be used for the transactionsReport.

transactionRegisterDate :: Query -> Query -> Transaction -> Day Source #

What is the transaction's date in the context of a particular account (specified with a query) and report query, as in an account register ? It's normally the transaction's general date, but if any posting(s) matched by the report query and affecting the matched account(s) have their own earlier dates, it's the earliest of these dates. Secondary transaction/posting dates are ignored.