hledger-lib
Safe HaskellNone
LanguageGHC2021

Hledger.Reports.MultiBalanceReport

Description

Multi-column balance reports, used by the balance command.

Synopsis

Documentation

type MultiBalanceReport = PeriodicReport DisplayName MixedAmount Source #

A multi balance report is a kind of periodic report, where the amounts correspond to balance changes or ending balances in a given period. It has:

  1. a list of each column's period (date span)
  2. a list of rows, each containing:
  • the full account name, display name, and display depth
  • A list of amounts, one for each column.
  • the total of the row's amounts for a periodic report
  • the average of the row's amounts
  1. the column totals, and the overall grand total (or zero for cumulative/historical reports) and grand average.

multiBalanceReport :: ReportSpec -> Journal -> MultiBalanceReport Source #

Generate a multicolumn balance report for the matched accounts, showing the change of balance, accumulated balance, or historical balance in each of the specified periods. If the normalbalance_ option is set, it adjusts the sorting and sign of amounts (see ReportOpts and CompoundBalanceCommand). hledger's most powerful and useful report, used by the balance command (in multiperiod mode) and (via compoundBalanceReport) by the bscfis commands.

multiBalanceReportWith :: ReportSpec -> Journal -> PriceOracle -> MultiBalanceReport Source #

A helper for multiBalanceReport. This one takes some extra arguments, a PriceOracle to be used for looking up market prices, and a set of AccountNames which should not be elided. Commands which run multiple reports (bs etc.) can generate the price oracle just once for efficiency, passing it to each report by calling this function directly.

compoundBalanceReport :: ReportSpec -> Journal -> [CBCSubreportSpec a] -> CompoundPeriodicReport a MixedAmount Source #

Generate a compound balance report from a list of CBCSubreportSpec. This shares postings between the subreports.

compoundBalanceReportWith :: ReportSpec -> Journal -> PriceOracle -> [CBCSubreportSpec a] -> CompoundPeriodicReport a MixedAmount Source #

A helper for compoundBalanceReport, similar to multiBalanceReportWith.

Helper functions

makeReportQuery :: ReportSpec -> DateSpan -> ReportSpec Source #

Remove any date queries and insert queries from the report span. The user's query expanded to the report span if there is one (otherwise any date queries are left as-is, which handles the hledger-ui+future txns case above).

balanceReportStyles :: ReportOpts -> Journal -> Map CommoditySymbol AmountStyle Source #

The display styles to apply to a balance report's amounts: the journal's commodity styles, hard-rounded, except for counts, which keep their own (see generateMultiBalanceReport).

getPostings :: ReportSpec -> Journal -> PriceOracle -> DateSpan -> [Posting] Source #

Gather postings matching the query within the report period.

accountRowAmounts :: ReportSpec -> Journal -> PriceOracle -> Maybe DayPartition -> [Posting] -> Map AccountName (MixedAmount, MixedAmount) Source #

Each account's own change over the report period, and own balance at the end of it, from these postings (clipped to the report's depth), which may include postings before the report start (see getPostings); those count in the balances only. If valuation is to be done after summing, the amounts are valued at the report end date.

generateMultiBalanceAccount :: ReportSpec -> Journal -> PriceOracle -> Maybe DayPartition -> [Posting] -> Account BalanceData Source #

Generate the Account for the requested multi-balance report from a list of Postings.

generatePeriodicReport :: Show c => (forall a. ReportOpts -> (BalanceData -> MixedAmount) -> a -> Account b -> PeriodicReportRow a c) -> (b -> MixedAmount) -> (c -> MixedAmount) -> ReportOpts -> Maybe DayPartition -> Account b -> PeriodicReport DisplayName c Source #

Lay out a set of postings grouped by date span into a regular matrix with rows given by AccountName and columns by DateSpan, then generate a MultiBalanceReport from the columns.

makePeriodicReportRow :: c -> (Map Day c -> (c, c)) -> ReportOpts -> (b -> c) -> a -> Account b -> PeriodicReportRow a c Source #

Build a report row.

Calculate the column totals. These are always the sum of column amounts.

rowTotal :: ReportOpts -> c -> c -> Map Day c -> c Source #

A report row's total, given its amounts and their sum (or a null amount, for an empty row): the sum, or for a cumulative or historical report, the last amount.