hledger
Safe HaskellNone
LanguageGHC2021

Hledger.Cli.Anchor

Description

Links from report cells to hledger-web's register: for hledger-web's own report pages, and for HTML and FODS output with --base-url. A figure links to the register that derives it, an account name to the account's register, a period heading to the register for that period.

Synopsis

Documentation

data LinkOpts Source #

What a report's register links need to know about the report, besides its query and the base url.

Constructors

LinkOpts 

Fields

  • loAccum :: BalanceAccumulation

    With historical balances, the register starts from the balance before the period, so that it ends on the figure in the cell.

  • loSpan :: DateSpan

    The whole report span. A cumulative figure's register runs from its start.

  • loDate2 :: Bool

    Does the report use secondary dates ? Then so must the register.

  • loIncludesSubs :: Bool

    Does the row's figure include subaccounts, or not (subs=0) ?

  • loNegated :: Bool

    Are the figures shown with the opposite sign to the register's ?

  • loValue :: Maybe Text

    The register's value parameter, for figures converted to cost or to market value (see valueParam).

linkParams :: LinkOpts -> [(Text, Text)] Source #

The query parameters a link carries besides q: the register's accumulation mode, when it is not the register's default, and how it converts amounts, when the report converts them.

valueParam :: Maybe ConversionOp -> Maybe ValuationType -> Maybe Text Source #

The value parameter that asks hledger-web's register to convert amounts as a report does, mirroring --value's WHEN[,COMM] syntax: "cost" for -B, "end" for -V, "end,COMM" for -X COMM, "then", "now", or a date for the other valuations. A register converting them the same way ends on the figure a link was clicked on. Cost combined with a valuation has none, and such links open the register as it is.

composeAnchor :: Maybe Text -> [Text] -> Text Source #

>>> composeAnchor Nothing ["date:2024"]
""
>>> composeAnchor (Just "") ["date:2024"]
"register?q=date:2024"
>>> composeAnchor (Just "/") ["date:2024"]
"/register?q=date:2024"
>>> composeAnchor (Just "foo") ["date:2024"]
"foo/register?q=date:2024"
>>> composeAnchor (Just "foo/") ["date:2024"]
"foo/register?q=date:2024"

composeAnchorWith :: [(Text, Text)] -> Maybe Text -> [Text] -> Text Source #

Like composeAnchor, with query parameters after q.

>>> composeAnchorWith [("accum","historical")] (Just "") ["date:2024"]
"register?q=date:2024&accum=historical"

accountParams :: Bool -> Text -> [(Text, Text)] Source #

The query parameters naming the account a link's register is for: with its subaccounts, or with subs=0, without them. A depth 0 report's "..." row, all accounts in one, names none: its register is the register of everything.

dateTerm :: Bool -> DateSpan -> [Text] Source #

A date: term for the span (date2: for a report using secondary dates), or none for the unbounded span.

removeInacct :: [Text] -> [Text] Source #

Drop the terms naming an account for the register. A link names the account it is for, and the register reads only the first such term.

withLink :: Text -> Text -> Cell border text -> Cell border text Source #

Give a cell a link and its title, unless the link is empty (no base url).

setAccountAnchor :: Maybe Text -> [Text] -> Text -> Cell border text -> Cell border text Source #

setAccountAnchorWith :: LinkOpts -> Maybe Text -> [Text] -> Text -> Cell border text -> Cell border text Source #

Link an account's cell to the account's register, restricted to the given query. The query says which dates; the link options say whether subaccounts are included and how the register accumulates.

dateCell :: Lines border => Maybe Text -> [Text] -> Text -> Day -> Cell border Text Source #

A cell showing a date in an account's row, linking to the account's register for that day.

dateSpanCell :: Lines border => PeriodTitles -> Maybe Text -> [Text] -> Text -> DateSpan -> Cell border Text Source #

dateSpanCellWith :: Lines border => LinkOpts -> PeriodTitles -> Maybe Text -> [Text] -> Text -> DateSpan -> Cell border Text Source #

A cell showing a period in an account's row, linking to the account's register for that period.

totalDateSpanCell :: Lines border => LinkOpts -> PeriodTitles -> Maybe Text -> [Text] -> [Text] -> DateSpan -> Cell border Text Source #

A cell for a period in a totals row, linking to the register of everything in the report's query, restricted by the given terms (a section's account types, say), for that period.

headerDateSpanCell :: Bool -> PeriodTitles -> Maybe Text -> [Text] -> DateSpan -> Cell () Text Source #

A column heading for the period, linking to the register for it. The link's date term is the span as a period expression, which can differ from the heading text: a query reads the end date of 2025-01-15..2025-02-14 as exclusive, and reads no week names.

renderPeriodHeading :: PeriodTitles -> DateSpan -> Text Source #

Render a DateSpan as a period heading according to the requested style.

amountPhrase :: LinkOpts -> Bool -> Text Source #

The title of a link from a figure to the register that derives it, with a note when the report shows figures with the opposite sign.