hledger
Safe HaskellNone
LanguageGHC2021

Hledger.Cli.CompoundBalanceCommand

Description

Common helpers for making multi-section balance report commands like balancesheet, cashflow, and incomestatement.

Synopsis

Documentation

data CompoundBalanceCommandSpec Source #

Description of a compound balance report command, from which we generate the command's cmdargs mode and IO action. A compound balance report command shows one or more sections/subreports, each with its own title and subtotals row, in a certain order, plus a grand totals row if there's more than one section. Examples are the balancesheet, cashflow and incomestatement commands.

Compound balance reports do sign normalisation: they show all account balances as normally positive, unlike the ordinary BalanceReport and most hledger commands which show incomeliabilityequity balances as normally negative. Each subreport specifies the normal sign of its amounts, and whether it should be added to or subtracted from the grand total.

Constructors

CompoundBalanceCommandSpec 

Fields

compoundBalanceCommandMode :: CompoundBalanceCommandSpec -> Mode RawOpts Source #

Generate a cmdargs option-parsing mode from a compound balance command specification.

compoundBalanceCommand :: CompoundBalanceCommandSpec -> CliOpts -> Journal -> IO () Source #

Generate a runnable command from a compound balance command specification.

compoundBalanceReportTitle :: CompoundBalanceCommandSpec -> ReportOpts -> Maybe BalanceAccumulation -> CompoundPeriodicReport a b -> Text Source #

The title of a compound balance report: the interval and report name, the dates, a note when the accumulation mode was overridden or the calculation is not the plain one, and the valuation. The report options are the command line's, with any accumulation override given separately, since the title says which it was.

titleInterval :: Interval -> Interval Source #

Merge the intervals that a report title does not distinguish: twelve months is a year, and a quarter is three months.

applySubreportTitles :: ReportOpts -> CompoundPeriodicReport a b -> CompoundPeriodicReport a b Source #

Apply --subreport-titles overrides to a compound report's subreports. A `|`-separated argument overrides the corresponding subreport titles, in order; subreports beyond the supplied list keep their default title. An explicit empty argument suppresses all default subreport titles.

compoundBalanceSectionTypes :: [CBCSubreportSpec a] -> [Maybe AccountType] Source #

Each section's account type, from its query, if that is a simple type query (for colouring charts).

data CompoundBalanceReportParts Source #

The parts of a compound balance report as spreadsheet cells, to be laid out as one table, or as a table with sections as hledger-web does.

Constructors

CompoundBalanceReportParts 

Fields

  • cbrpLeadingHeaders :: [Cell NumLines Text]

    The heading row's first cell(s): the account column's, and the tidy and bare layouts' extra columns'.

  • cbrpDataHeaders :: [Cell NumLines Text]

    Then a heading per data column: each period, linking to the register for it, then the row total and average when shown. In the bare-wide layout each of these spans the commodity columns.

  • cbrpSections :: [(Text, [[Cell NumLines Text]], [[Cell NumLines Text]])]

    Each section's title, body rows, and totals rows.

  • cbrpNetRows :: [[Cell NumLines Text]]

    The net total rows; none when there is one section or no totals.

compoundBalanceReportAsSpreadsheetParts :: AmountFormat -> Text -> ReportOpts -> [CBCSubreportSpec DisplayName] -> CompoundPeriodicReport DisplayName MixedAmount -> CompoundBalanceReportParts Source #

Render a compound balance report's parts as spreadsheet cells. The subreport specs it was made from say how each section's figures link: a section is rendered with its own report options, so that its links say when its figures are negated, and its totals link to the registers of its account types.

allCommoditiesFromSubreports :: [(text, PeriodicReport a MixedAmount, bool)] -> [CommoditySymbol] Source #

All commodities appearing in any of these subreports, sorted. Used as the commodity column order for LayoutBareWide across the whole compound report; it must cover every row rendered, including the totals row, see setDisplayCommodityBare in Hledger.Cli.Commands.Balance.Internal.