hledger-lib-1.19.1: A reusable library providing the core functionality of hledger

Safe Haskell | None
Language | Haskell2010

Hledger.Reports.ReportOptions

Description

Options common to most hledger reports.

Synopsis

- data ReportOpts = ReportOpts {
  - today_ :: Maybe Day
  - period_ :: Period
  - interval_ :: Interval
  - statuses_ :: [Status]
  - value_ :: Maybe ValuationType
  - infer_value_ :: Bool
  - depth_ :: Maybe Int
  - date2_ :: Bool
  - empty_ :: Bool
  - no_elide_ :: Bool
  - real_ :: Bool
  - format_ :: Maybe FormatStr
  - query_ :: String
  - average_ :: Bool
  - related_ :: Bool
  - txn_dates_ :: Bool
  - balancetype_ :: BalanceType
  - accountlistmode_ :: AccountListMode
  - drop_ :: Int
  - row_total_ :: Bool
  - no_total_ :: Bool
  - pretty_tables_ :: Bool
  - sort_amount_ :: Bool
  - percent_ :: Bool
  - invert_ :: Bool
  - normalbalance_ :: Maybe NormalSign
  - color_ :: Bool
  - forecast_ :: Maybe DateSpan
  - transpose_ :: Bool
  }
- data BalanceType
  - = PeriodChange
  - | CumulativeChange
  - | HistoricalBalance
- data AccountListMode
  - = ALFlat
  - | ALTree
- data ValuationType
  - = AtCost (Maybe CommoditySymbol)
  - | AtThen (Maybe CommoditySymbol)
  - | AtEnd (Maybe CommoditySymbol)
  - | AtNow (Maybe CommoditySymbol)
  - | AtDate Day (Maybe CommoditySymbol)
  - | AtDefault (Maybe CommoditySymbol)
- type FormatStr = String
- defreportopts :: ReportOpts
- rawOptsToReportOpts :: RawOpts -> IO ReportOpts
- checkReportOpts :: ReportOpts -> ReportOpts
- flat_ :: ReportOpts -> Bool
- tree_ :: ReportOpts -> Bool
- reportOptsToggleStatus :: Status -> ReportOpts -> ReportOpts
- simplifyStatuses :: Ord a => [a] -> [a]
- whichDateFromOpts :: ReportOpts -> WhichDate
- journalSelectingAmountFromOpts :: ReportOpts -> Journal -> Journal
- intervalFromRawOpts :: RawOpts -> Interval
- forecastPeriodFromRawOpts :: Day -> RawOpts -> Maybe DateSpan
- queryFromOpts :: Day -> ReportOpts -> Query
- queryFromOptsOnly :: Day -> ReportOpts -> Query
- queryOptsFromOpts :: Day -> ReportOpts -> [QueryOpt]
- transactionDateFn :: ReportOpts -> Transaction -> Day
- postingDateFn :: ReportOpts -> Posting -> Day
- reportSpan :: Journal -> ReportOpts -> IO DateSpan
- reportStartDate :: Journal -> ReportOpts -> IO (Maybe Day)
- reportEndDate :: Journal -> ReportOpts -> IO (Maybe Day)
- specifiedStartEndDates :: ReportOpts -> IO (Maybe Day, Maybe Day)
- specifiedStartDate :: ReportOpts -> IO (Maybe Day)
- specifiedEndDate :: ReportOpts -> IO (Maybe Day)
- reportPeriodStart :: ReportOpts -> Maybe Day
- reportPeriodOrJournalStart :: ReportOpts -> Journal -> Maybe Day
- reportPeriodLastDay :: ReportOpts -> Maybe Day
- reportPeriodOrJournalLastDay :: ReportOpts -> Journal -> Maybe Day
- valuationTypeIsCost :: ReportOpts -> Bool
- valuationTypeIsDefaultValue :: ReportOpts -> Bool
- tests_ReportOptions :: TestTree

# Documentation

data ReportOpts Source #

Standard options for customising report filtering and output. Most of these correspond to standard hledger command-line options or query arguments, but not all. Some are used only by certain commands, as noted below.

Constructors

ReportOpts |

Fields

- today_ :: Maybe Day

  The current date. A late addition to ReportOpts. Optional, but when set it may affect some reports: Reports use it when picking a -V valuation date. This is not great, adds indeterminacy.

- period_ :: Period
- interval_ :: Interval
- statuses_ :: [Status]

  Zero, one, or two statuses to be matched

- value_ :: Maybe ValuationType

  What value should amounts be converted to ?

- infer_value_ :: Bool

  Infer market prices from transactions ?

- depth_ :: Maybe Int
- date2_ :: Bool
- empty_ :: Bool
- no_elide_ :: Bool
- real_ :: Bool
- format_ :: Maybe FormatStr
- query_ :: String

  All query arguments space sepeareted and quoted if needed (see `quoteIfNeeded`)

- average_ :: Bool
- related_ :: Bool
- txn_dates_ :: Bool
- balancetype_ :: BalanceType
- accountlistmode_ :: AccountListMode
- drop_ :: Int
- row_total_ :: Bool
- no_total_ :: Bool
- pretty_tables_ :: Bool
- sort_amount_ :: Bool
- percent_ :: Bool
- invert_ :: Bool

  if true, flip all amount signs in reports

- normalbalance_ :: Maybe NormalSign

  This can be set when running balance reports on a set of accounts with the same normal balance type (eg all assets, or all incomes). - It helps --sort-amount know how to sort negative numbers (eg in the income section of an income statement) - It helps compound balance report commands (is, bs etc.) do sign normalisation, converting normally negative subreports to normally positive for a more conventional display.

- color_ :: Bool

  Whether to use ANSI color codes in text output. Influenced by the --color/colour flag (cf CliOptions), whether stdout is an interactive terminal, and the value of TERM and existence of NO_COLOR environment variables.

- forecast_ :: Maybe DateSpan
- transpose_ :: Bool

#### Instances

Instances details

Show ReportOpts Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods showsPrec :: Int -> ReportOpts -> ShowS Source # show :: ReportOpts -> String Source # showList :: [ReportOpts] -> ShowS Source #
Default ReportOpts Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods def :: ReportOpts #

data BalanceType Source #

Which "balance" is being shown in a balance report.

Constructors

PeriodChange | The change of balance in each period.
CumulativeChange | The accumulated change across multiple periods.
HistoricalBalance | The historical ending balance, including the effect of all postings before the report period. Unless altered by, a query, this is what you would see on a bank statement.

#### Instances

Instances details

Eq BalanceType Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods (==) :: BalanceType -> BalanceType -> Bool Source # (/=) :: BalanceType -> BalanceType -> Bool Source #
Show BalanceType Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods showsPrec :: Int -> BalanceType -> ShowS Source # show :: BalanceType -> String Source # showList :: [BalanceType] -> ShowS Source #
Default BalanceType Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods def :: BalanceType #

data AccountListMode Source #

Should accounts be displayed: in the command's default style, hierarchically, or as a flat list ?

Constructors

ALFlat |
ALTree |

#### Instances

Instances details

Eq AccountListMode Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods (==) :: AccountListMode -> AccountListMode -> Bool Source # (/=) :: AccountListMode -> AccountListMode -> Bool Source #
Show AccountListMode Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods showsPrec :: Int -> AccountListMode -> ShowS Source # show :: AccountListMode -> String Source # showList :: [AccountListMode] -> ShowS Source #
Default AccountListMode Source # |
Instance details Defined in Hledger.Reports.ReportOptions Methods def :: AccountListMode #

data ValuationType Source #

What kind of value conversion should be done on amounts ? CLI: --value=cost|then|end|now|DATE[,COMM]

Constructors

AtCost (Maybe CommoditySymbol) | convert to cost commodity using transaction prices, then optionally to given commodity using market prices at posting date
AtThen (Maybe CommoditySymbol) | convert to default or given valuation commodity, using market prices at each posting's date
AtEnd (Maybe CommoditySymbol) | convert to default or given valuation commodity, using market prices at period end(s)
AtNow (Maybe CommoditySymbol) | convert to default or given valuation commodity, using current market prices
AtDate Day (Maybe CommoditySymbol) | convert to default or given valuation commodity, using market prices on some date
AtDefault (Maybe CommoditySymbol) | works like AtNow in single period reports, like AtEnd in multiperiod reports

#### Instances

Instances details

Eq ValuationType Source # |
Instance details Defined in Hledger.Data.Valuation Methods (==) :: ValuationType -> ValuationType -> Bool Source # (/=) :: ValuationType -> ValuationType -> Bool Source #
Show ValuationType Source # |
Instance details Defined in Hledger.Data.Valuation Methods showsPrec :: Int -> ValuationType -> ShowS Source # show :: ValuationType -> String Source # showList :: [ValuationType] -> ShowS Source #

type FormatStr = String Source #

defreportopts :: ReportOpts Source #

rawOptsToReportOpts :: RawOpts -> IO ReportOpts Source #

checkReportOpts :: ReportOpts -> ReportOpts Source #

Do extra validation of report options, raising an error if there's a problem.

flat_ :: ReportOpts -> Bool Source #

tree_ :: ReportOpts -> Bool Source #

Legacy-compatible convenience aliases for accountlistmode_.

reportOptsToggleStatus :: Status -> ReportOpts -> ReportOpts Source #

Add/remove this status from the status list. Used by hledger-ui.

simplifyStatuses :: Ord a => [a] -> [a] Source #

Reduce a list of statuses to just one of each status, and if all statuses are present return the empty list.

whichDateFromOpts :: ReportOpts -> WhichDate Source #

Report which date we will report on based on --date2.

journalSelectingAmountFromOpts :: ReportOpts -> Journal -> Journal Source #

Convert this journal's postings' amounts to cost using their transaction prices, if specified by options (-B/--value=cost). Maybe soon superseded by newer valuation code.

intervalFromRawOpts :: RawOpts -> Interval Source #

Get the report interval, if any, specified by the last of -p/--period, -D--daily, -W--weekly, -M/--monthly etc. options. An interval from --period counts only if it is explicitly defined.

forecastPeriodFromRawOpts :: Day -> RawOpts -> Maybe DateSpan Source #

get period expression from --forecast option

queryFromOpts :: Day -> ReportOpts -> Query Source #

Convert report options and arguments to a query. If there is a parsing problem, this function calls error.

queryFromOptsOnly :: Day -> ReportOpts -> Query Source #

Convert report options to a query, ignoring any non-flag command line arguments.

queryOptsFromOpts :: Day -> ReportOpts -> [QueryOpt] Source #

Convert report options and arguments to query options. If there is a parsing problem, this function calls error.

transactionDateFn :: ReportOpts -> Transaction -> Day Source #

Select the Transaction date accessor based on --date2.

postingDateFn :: ReportOpts -> Posting -> Day Source #

Select the Posting date accessor based on --date2.

reportSpan :: Journal -> ReportOpts -> IO DateSpan Source #

The effective report span is the start and end dates specified by options or queries, or otherwise the earliest and latest transaction or posting dates in the journal. If no dates are specified by options/queries and the journal is empty, returns the null date span. Needs IO to parse smart dates in options/queries.

reportStartDate :: Journal -> ReportOpts -> IO (Maybe Day) Source #

reportEndDate :: Journal -> ReportOpts -> IO (Maybe Day) Source #

specifiedStartEndDates :: ReportOpts -> IO (Maybe Day, Maybe Day) Source #

The specified report start/end dates are the dates specified by options or queries, if any. Needs IO to parse smart dates in options/queries.

specifiedStartDate :: ReportOpts -> IO (Maybe Day) Source #

specifiedEndDate :: ReportOpts -> IO (Maybe Day) Source #

reportPeriodStart :: ReportOpts -> Maybe Day Source #

reportPeriodOrJournalStart :: ReportOpts -> Journal -> Maybe Day Source #

reportPeriodLastDay :: ReportOpts -> Maybe Day Source #

reportPeriodOrJournalLastDay :: ReportOpts -> Journal -> Maybe Day Source #

valuationTypeIsCost :: ReportOpts -> Bool Source #

valuationTypeIsDefaultValue :: ReportOpts -> Bool Source #

tests_ReportOptions :: TestTree Source #