ref: ReportOptions{infer_value_} renamed to infer_prices_

For more consistency with the flag name (--infer-market-prices).
And BalancingOpts{infer_prices_} is now infer_transaction_prices_.
This commit is contained in:
Simon Michael 2021-09-09 12:17:34 -10:00
parent daa9fddec9
commit 326d6e8dae
7 changed files with 13 additions and 12 deletions

View File

@ -358,14 +358,14 @@ transactionsPostings = concatMap tpostings
data BalancingOpts = BalancingOpts
{ ignore_assertions_ :: Bool -- ^ Ignore balance assertions
, infer_prices_ :: Bool -- ^ Infer prices in unbalanced multicommodity amounts
, infer_transaction_prices_ :: Bool -- ^ Infer prices in unbalanced multicommodity amounts
, commodity_styles_ :: Maybe (M.Map CommoditySymbol AmountStyle) -- ^ commodity display styles
} deriving (Show)
defbalancingopts :: BalancingOpts
defbalancingopts = BalancingOpts
{ ignore_assertions_ = False
, infer_prices_ = True
, infer_transaction_prices_ = True
, commodity_styles_ = Nothing
}
@ -450,7 +450,7 @@ balanceTransactionHelper ::
-> Either String (Transaction, [(AccountName, MixedAmount)])
balanceTransactionHelper bopts t = do
(t', inferredamtsandaccts) <- inferBalancingAmount (fromMaybe M.empty $ commodity_styles_ bopts) $
if infer_prices_ bopts then inferBalancingPrices t else t
if infer_transaction_prices_ bopts then inferBalancingPrices t else t
case transactionCheckBalanced bopts t' of
[] -> Right (txnTieKnot t', inferredamtsandaccts)
errs -> Left $ transactionBalanceError t' errs

View File

@ -227,7 +227,7 @@ rawOptsToInputOpts day rawopts =
,auto_ = boolopt "auto" rawopts
,balancingopts_ = defbalancingopts{
ignore_assertions_ = boolopt "ignore-assertions" rawopts
, infer_prices_ = not noinferprice
, infer_transaction_prices_ = not noinferprice
, commodity_styles_ = Just commodity_styles
}
,strict_ = boolopt "strict" rawopts

View File

@ -103,7 +103,7 @@ type ClippedAccountName = AccountName
-- by the bs/cf/is commands.
multiBalanceReport :: ReportSpec -> Journal -> MultiBalanceReport
multiBalanceReport rspec j = multiBalanceReportWith rspec j (journalPriceOracle infer j)
where infer = infer_value_ $ _rsReportOpts rspec
where infer = infer_prices_ $ _rsReportOpts rspec
-- | A helper for multiBalanceReport. This one takes an extra argument,
-- a PriceOracle to be used for looking up market prices. Commands which
@ -134,7 +134,7 @@ multiBalanceReportWith rspec' j priceoracle = report
compoundBalanceReport :: ReportSpec -> Journal -> [CBCSubreportSpec a]
-> CompoundPeriodicReport a MixedAmount
compoundBalanceReport rspec j = compoundBalanceReportWith rspec j (journalPriceOracle infer j)
where infer = infer_value_ $ _rsReportOpts rspec
where infer = infer_prices_ $ _rsReportOpts rspec
-- | A helper for compoundBalanceReport, similar to multiBalanceReportWith.
compoundBalanceReportWith :: ReportSpec -> Journal -> PriceOracle

View File

@ -116,7 +116,7 @@ data ReportOpts = ReportOpts {
,statuses_ :: [Status] -- ^ Zero, one, or two statuses to be matched
,cost_ :: Costing -- ^ Should we convert amounts to cost, when present?
,value_ :: Maybe ValuationType -- ^ What value should amounts be converted to ?
,infer_value_ :: Bool -- ^ Infer market prices from transactions ?
,infer_prices_ :: Bool -- ^ Infer market prices from transactions ?
,depth_ :: Maybe Int
,date2_ :: Bool
,empty_ :: Bool
@ -171,7 +171,7 @@ defreportopts = ReportOpts
, statuses_ = []
, cost_ = NoCost
, value_ = Nothing
, infer_value_ = False
, infer_prices_ = False
, depth_ = Nothing
, date2_ = False
, empty_ = False
@ -223,7 +223,7 @@ rawOptsToReportOpts d rawopts =
,statuses_ = statusesFromRawOpts rawopts
,cost_ = costing
,value_ = valuation
,infer_value_ = boolopt "infer-market-prices" rawopts
,infer_prices_ = boolopt "infer-market-prices" rawopts
,depth_ = maybeposintopt "depth" rawopts
,date2_ = boolopt "date2" rawopts
,empty_ = boolopt "empty" rawopts
@ -494,7 +494,7 @@ flat_ = not . tree_
journalApplyValuationFromOpts :: ReportSpec -> Journal -> Journal
journalApplyValuationFromOpts rspec j =
journalApplyValuationFromOptsWith rspec j priceoracle
where priceoracle = journalPriceOracle (infer_value_ $ _rsReportOpts rspec) j
where priceoracle = journalPriceOracle (infer_prices_ $ _rsReportOpts rspec) j
-- | Like journalApplyValuationFromOpts, but takes PriceOracle as an argument.
journalApplyValuationFromOptsWith :: ReportSpec -> Journal -> PriceOracle -> Journal

View File

@ -77,7 +77,7 @@ tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec
t = transactionMapPostingAmounts mixedAmountSetFullPrecision t'
maincontent = Widget Greedy Greedy $ do
let
prices = journalPriceOracle (infer_value_ ropts) j
prices = journalPriceOracle (infer_prices_ ropts) j
styles = journalCommodityStyles j
periodlast =
fromMaybe (error' "TransactionScreen: expected a non-empty journal") $ -- PARTIAL: shouldn't happen

View File

@ -189,6 +189,7 @@ reportflags = [
-- 2021-02, --infer-market-price added, --infer-value deprecated
-- 2021-09, --infer-value hidden
-- --infer-market-price renamed to --infer-market-prices, old spelling still works
-- ReportOptions{infer_value_} renamed to infer_prices_ (and BalancingOpts{infer_prices_} renamed to infer_transaction_prices_)
,flagNone ["infer-market-prices"] (setboolopt "infer-market-prices")
"use transaction prices (recorded with @ or @@) as additional market prices, as if they were P directives"

View File

@ -62,7 +62,7 @@ roi CliOpts{rawopts_=rawopts, reportspec_=rspec@ReportSpec{_rsReportOpts=ReportO
-- We may be converting posting amounts to value, per hledger_options.m4.md "Effect of --value on reports".
let
today = _rsDay rspec
priceOracle = journalPriceOracle infer_value_ j
priceOracle = journalPriceOracle infer_prices_ j
styles = journalCommodityStyles j
mixedAmountValue periodlast date =
maybe id (mixedAmountApplyValuation priceOracle styles periodlast today date) value_