| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Hledger.Reports.AccountTransactionsReport
Contents
Description
An account-centric transactions report.
Synopsis
- type AccountTransactionsReport = [AccountTransactionsReportItem]
- type AccountTransactionsReportItem = (Transaction, Transaction, Bool, [AccountName], MixedAmount, MixedAmount)
- accountTransactionsReport :: ReportSpec -> Journal -> Query -> AccountTransactionsReport
- accountTransactionsReportWithStart :: ReportSpec -> Journal -> Query -> (MixedAmount, AccountTransactionsReport)
- accountTransactionsReportItems :: Query -> Query -> Query -> (Int -> MixedAmount -> MixedAmount -> MixedAmount) -> Int -> MixedAmount -> MixedAmount -> (MixedAmount -> MixedAmount) -> (AccountName -> Maybe AccountType) -> [(Day, Transaction)] -> [AccountTransactionsReportItem]
- transactionRegisterDate :: WhichDate -> Query -> Query -> Transaction -> Day
- transactionRegisterDateExtra :: (AccountName -> Maybe AccountType) -> WhichDate -> Query -> Query -> Transaction -> Day
- triOrigTransaction :: (a, b, c, d, e, f) -> a
- triDate :: (a, Transaction, c, d, e, f) -> Day
- triAmount :: (a, b, c, d, e, f) -> e
- triBalance :: (a, b, c, d, e, f) -> f
- triCommodityAmount :: CommoditySymbol -> (a, b, c, d, MixedAmount, f) -> MixedAmount
- triCommodityBalance :: CommoditySymbol -> (a, b, c, d, e, MixedAmount) -> MixedAmount
- accountTransactionsReportByCommodity :: AccountTransactionsReport -> [(CommoditySymbol, AccountTransactionsReport)]
- filterAccountTransactionsReportByCommodity :: CommoditySymbol -> AccountTransactionsReport -> AccountTransactionsReport
- tests_AccountTransactionsReport :: TestTree
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": the earliest of the transaction date and any other posting dates of postings to the current account (matched by the report query).
- 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; or if average is requested (-A), the running average change per transaction (also including transactions before the report start date, with -H). 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.
type AccountTransactionsReportItem = (Transaction, Transaction, Bool, [AccountName], MixedAmount, MixedAmount) Source #
accountTransactionsReportWithStart :: ReportSpec -> Journal -> Query -> (MixedAmount, AccountTransactionsReport) Source #
The account transactions report, and the balance its running total starts from: zero, or, with historical balances and a start date in the query, the sum of the account's postings before that date (with --average, their average per transaction). A register can show the latter as a balance brought forward.
accountTransactionsReportItems :: Query -> Query -> Query -> (Int -> MixedAmount -> MixedAmount -> MixedAmount) -> Int -> MixedAmount -> MixedAmount -> (MixedAmount -> MixedAmount) -> (AccountName -> Maybe AccountType) -> [(Day, Transaction)] -> [AccountTransactionsReportItem] Source #
Generate transactions report items from a list of transactions, using the provided user-specified report query, the report query's change:/balance: terms (selecting items by their change to the account, or the account's real balance after them; hidden items still count in the running total), a query specifying which account to use as the focus, a running calculation function (see registerRunningCalculationFn), the starting item number, the running total/average and the real balance before the first item, and a sign-setting function. Each transaction is accompanied by the date that should be shown for it in the report. This is not necessarily the transaction date - see transactionRegisterDate.
transactionRegisterDate :: WhichDate -> Query -> Query -> Transaction -> Day Source #
What date should be shown for a transaction in an account register report ? This will be in context of a particular account (the "this account" query) and any additional report query. It could be:
- if postings are matched by both thisacctq and reportq, the earliest of those matched postings' dates (or their secondary dates if --date2 was used)
- the transaction date, or its secondary date if --date2 was used.
transactionRegisterDateExtra :: (AccountName -> Maybe AccountType) -> WhichDate -> Query -> Query -> Transaction -> Day Source #
Like transactionRegisterDate, but given the accounts' types, so
that a type: term in the report query matches postings here as it
does in the report itself.
triOrigTransaction :: (a, b, c, d, e, f) -> a Source #
triDate :: (a, Transaction, c, d, e, f) -> Day Source #
triBalance :: (a, b, c, d, e, f) -> f Source #
triCommodityAmount :: CommoditySymbol -> (a, b, c, d, MixedAmount, f) -> MixedAmount Source #
triCommodityBalance :: CommoditySymbol -> (a, b, c, d, e, MixedAmount) -> MixedAmount Source #
accountTransactionsReportByCommodity :: AccountTransactionsReport -> [(CommoditySymbol, AccountTransactionsReport)] Source #
Split an account transactions report whose items may involve several commodities, into one or more single-commodity account transactions reports.
filterAccountTransactionsReportByCommodity :: CommoditySymbol -> AccountTransactionsReport -> AccountTransactionsReport Source #
Remove account transaction report items and item amount (and running balance amount) components that don't involve the specified commodity. Other item fields such as the transaction are left unchanged.