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:
parent
daa9fddec9
commit
326d6e8dae
@ -358,14 +358,14 @@ transactionsPostings = concatMap tpostings
|
|||||||
|
|
||||||
data BalancingOpts = BalancingOpts
|
data BalancingOpts = BalancingOpts
|
||||||
{ ignore_assertions_ :: Bool -- ^ Ignore balance assertions
|
{ 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
|
, commodity_styles_ :: Maybe (M.Map CommoditySymbol AmountStyle) -- ^ commodity display styles
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
defbalancingopts :: BalancingOpts
|
defbalancingopts :: BalancingOpts
|
||||||
defbalancingopts = BalancingOpts
|
defbalancingopts = BalancingOpts
|
||||||
{ ignore_assertions_ = False
|
{ ignore_assertions_ = False
|
||||||
, infer_prices_ = True
|
, infer_transaction_prices_ = True
|
||||||
, commodity_styles_ = Nothing
|
, commodity_styles_ = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ balanceTransactionHelper ::
|
|||||||
-> Either String (Transaction, [(AccountName, MixedAmount)])
|
-> Either String (Transaction, [(AccountName, MixedAmount)])
|
||||||
balanceTransactionHelper bopts t = do
|
balanceTransactionHelper bopts t = do
|
||||||
(t', inferredamtsandaccts) <- inferBalancingAmount (fromMaybe M.empty $ commodity_styles_ bopts) $
|
(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
|
case transactionCheckBalanced bopts t' of
|
||||||
[] -> Right (txnTieKnot t', inferredamtsandaccts)
|
[] -> Right (txnTieKnot t', inferredamtsandaccts)
|
||||||
errs -> Left $ transactionBalanceError t' errs
|
errs -> Left $ transactionBalanceError t' errs
|
||||||
|
|||||||
@ -227,7 +227,7 @@ rawOptsToInputOpts day rawopts =
|
|||||||
,auto_ = boolopt "auto" rawopts
|
,auto_ = boolopt "auto" rawopts
|
||||||
,balancingopts_ = defbalancingopts{
|
,balancingopts_ = defbalancingopts{
|
||||||
ignore_assertions_ = boolopt "ignore-assertions" rawopts
|
ignore_assertions_ = boolopt "ignore-assertions" rawopts
|
||||||
, infer_prices_ = not noinferprice
|
, infer_transaction_prices_ = not noinferprice
|
||||||
, commodity_styles_ = Just commodity_styles
|
, commodity_styles_ = Just commodity_styles
|
||||||
}
|
}
|
||||||
,strict_ = boolopt "strict" rawopts
|
,strict_ = boolopt "strict" rawopts
|
||||||
|
|||||||
@ -103,7 +103,7 @@ type ClippedAccountName = AccountName
|
|||||||
-- by the bs/cf/is commands.
|
-- by the bs/cf/is commands.
|
||||||
multiBalanceReport :: ReportSpec -> Journal -> MultiBalanceReport
|
multiBalanceReport :: ReportSpec -> Journal -> MultiBalanceReport
|
||||||
multiBalanceReport rspec j = multiBalanceReportWith rspec j (journalPriceOracle infer j)
|
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 helper for multiBalanceReport. This one takes an extra argument,
|
||||||
-- a PriceOracle to be used for looking up market prices. Commands which
|
-- 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]
|
compoundBalanceReport :: ReportSpec -> Journal -> [CBCSubreportSpec a]
|
||||||
-> CompoundPeriodicReport a MixedAmount
|
-> CompoundPeriodicReport a MixedAmount
|
||||||
compoundBalanceReport rspec j = compoundBalanceReportWith rspec j (journalPriceOracle infer j)
|
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.
|
-- | A helper for compoundBalanceReport, similar to multiBalanceReportWith.
|
||||||
compoundBalanceReportWith :: ReportSpec -> Journal -> PriceOracle
|
compoundBalanceReportWith :: ReportSpec -> Journal -> PriceOracle
|
||||||
|
|||||||
@ -116,7 +116,7 @@ data ReportOpts = ReportOpts {
|
|||||||
,statuses_ :: [Status] -- ^ Zero, one, or two statuses to be matched
|
,statuses_ :: [Status] -- ^ Zero, one, or two statuses to be matched
|
||||||
,cost_ :: Costing -- ^ Should we convert amounts to cost, when present?
|
,cost_ :: Costing -- ^ Should we convert amounts to cost, when present?
|
||||||
,value_ :: Maybe ValuationType -- ^ What value should amounts be converted to ?
|
,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
|
,depth_ :: Maybe Int
|
||||||
,date2_ :: Bool
|
,date2_ :: Bool
|
||||||
,empty_ :: Bool
|
,empty_ :: Bool
|
||||||
@ -171,7 +171,7 @@ defreportopts = ReportOpts
|
|||||||
, statuses_ = []
|
, statuses_ = []
|
||||||
, cost_ = NoCost
|
, cost_ = NoCost
|
||||||
, value_ = Nothing
|
, value_ = Nothing
|
||||||
, infer_value_ = False
|
, infer_prices_ = False
|
||||||
, depth_ = Nothing
|
, depth_ = Nothing
|
||||||
, date2_ = False
|
, date2_ = False
|
||||||
, empty_ = False
|
, empty_ = False
|
||||||
@ -223,7 +223,7 @@ rawOptsToReportOpts d rawopts =
|
|||||||
,statuses_ = statusesFromRawOpts rawopts
|
,statuses_ = statusesFromRawOpts rawopts
|
||||||
,cost_ = costing
|
,cost_ = costing
|
||||||
,value_ = valuation
|
,value_ = valuation
|
||||||
,infer_value_ = boolopt "infer-market-prices" rawopts
|
,infer_prices_ = boolopt "infer-market-prices" rawopts
|
||||||
,depth_ = maybeposintopt "depth" rawopts
|
,depth_ = maybeposintopt "depth" rawopts
|
||||||
,date2_ = boolopt "date2" rawopts
|
,date2_ = boolopt "date2" rawopts
|
||||||
,empty_ = boolopt "empty" rawopts
|
,empty_ = boolopt "empty" rawopts
|
||||||
@ -494,7 +494,7 @@ flat_ = not . tree_
|
|||||||
journalApplyValuationFromOpts :: ReportSpec -> Journal -> Journal
|
journalApplyValuationFromOpts :: ReportSpec -> Journal -> Journal
|
||||||
journalApplyValuationFromOpts rspec j =
|
journalApplyValuationFromOpts rspec j =
|
||||||
journalApplyValuationFromOptsWith rspec j priceoracle
|
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.
|
-- | Like journalApplyValuationFromOpts, but takes PriceOracle as an argument.
|
||||||
journalApplyValuationFromOptsWith :: ReportSpec -> Journal -> PriceOracle -> Journal
|
journalApplyValuationFromOptsWith :: ReportSpec -> Journal -> PriceOracle -> Journal
|
||||||
|
|||||||
@ -77,7 +77,7 @@ tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec
|
|||||||
t = transactionMapPostingAmounts mixedAmountSetFullPrecision t'
|
t = transactionMapPostingAmounts mixedAmountSetFullPrecision t'
|
||||||
maincontent = Widget Greedy Greedy $ do
|
maincontent = Widget Greedy Greedy $ do
|
||||||
let
|
let
|
||||||
prices = journalPriceOracle (infer_value_ ropts) j
|
prices = journalPriceOracle (infer_prices_ ropts) j
|
||||||
styles = journalCommodityStyles j
|
styles = journalCommodityStyles j
|
||||||
periodlast =
|
periodlast =
|
||||||
fromMaybe (error' "TransactionScreen: expected a non-empty journal") $ -- PARTIAL: shouldn't happen
|
fromMaybe (error' "TransactionScreen: expected a non-empty journal") $ -- PARTIAL: shouldn't happen
|
||||||
|
|||||||
@ -189,6 +189,7 @@ reportflags = [
|
|||||||
-- 2021-02, --infer-market-price added, --infer-value deprecated
|
-- 2021-02, --infer-market-price added, --infer-value deprecated
|
||||||
-- 2021-09, --infer-value hidden
|
-- 2021-09, --infer-value hidden
|
||||||
-- --infer-market-price renamed to --infer-market-prices, old spelling still works
|
-- --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")
|
,flagNone ["infer-market-prices"] (setboolopt "infer-market-prices")
|
||||||
"use transaction prices (recorded with @ or @@) as additional market prices, as if they were P directives"
|
"use transaction prices (recorded with @ or @@) as additional market prices, as if they were P directives"
|
||||||
|
|
||||||
|
|||||||
@ -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".
|
-- We may be converting posting amounts to value, per hledger_options.m4.md "Effect of --value on reports".
|
||||||
let
|
let
|
||||||
today = _rsDay rspec
|
today = _rsDay rspec
|
||||||
priceOracle = journalPriceOracle infer_value_ j
|
priceOracle = journalPriceOracle infer_prices_ j
|
||||||
styles = journalCommodityStyles j
|
styles = journalCommodityStyles j
|
||||||
mixedAmountValue periodlast date =
|
mixedAmountValue periodlast date =
|
||||||
maybe id (mixedAmountApplyValuation priceOracle styles periodlast today date) value_
|
maybe id (mixedAmountApplyValuation priceOracle styles periodlast today date) value_
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user