diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 32798a3f0..17dea6eb3 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -184,12 +184,17 @@ reportflags = [ ,"'now': convert to current market value, in default valuation commodity or COMM" ,"YYYY-MM-DD: convert to market value on the given date, in default valuation commodity or COMM" ]) - -- history of this flag: - -- originally --infer-value - -- 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_) + + -- history of this flag so far, lest we be confused: + -- originally --infer-value + -- 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_, BalancingOpts{infer_prices_} renamed to infer_transaction_prices_ + -- some related prices command changes + -- --costs deprecated and hidden, uses --infer-market-prices instead + -- --inverted-costs renamed to --infer-reverse-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" diff --git a/hledger/Hledger/Cli/Commands/Prices.hs b/hledger/Hledger/Cli/Commands/Prices.hs index 7a9609120..f1179fbe6 100755 --- a/hledger/Hledger/Cli/Commands/Prices.hs +++ b/hledger/Hledger/Cli/Commands/Prices.hs @@ -19,10 +19,13 @@ import System.Console.CmdArgs.Explicit pricesmode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Prices.txt") - [flagNone ["costs"] (setboolopt "costs") "print transaction prices from postings" - ,flagNone ["inverted-costs"] (setboolopt "inverted-costs") "print transaction inverted prices from postings also"] + [flagNone ["infer-reverse-prices"] (setboolopt "infer-reverse-prices") "also show prices obtained by inverting transaction prices" + ] [generalflagsgroup1] - hiddenflags + (hiddenflags ++ + [flagNone ["costs"] (setboolopt "infer-market-prices") "deprecated, use --infer-market-prices instead" + ,flagNone ["inverted-costs"] (setboolopt "infer-reverse-prices") "deprecated, use --infer-reverse-prices instead" + ]) ([], Just $ argsFlag "[QUERY]") -- XXX the original hledger-prices script always ignored assertions @@ -32,9 +35,18 @@ prices opts j = do q = _rsQuery $ reportspec_ opts ps = filter (matchesPosting q) $ allPostings j mprices = jpricedirectives j - cprices = map (stylePriceDirectiveExceptPrecision styles) $ concatMap postingsPriceDirectivesFromCosts ps - icprices = map (stylePriceDirectiveExceptPrecision styles) $ concatMap (postingsPriceDirectivesFromCosts . postingTransformAmount (mapMixedAmount invertPrice)) ps - allprices = mprices ++ ifBoolOpt "costs" cprices ++ ifBoolOpt "inverted-costs" icprices + cprices = + map (stylePriceDirectiveExceptPrecision styles) $ + concatMap postingsPriceDirectivesFromCosts ps + rcprices = + map (stylePriceDirectiveExceptPrecision styles) $ + concatMap (postingsPriceDirectivesFromCosts . postingTransformAmount (mapMixedAmount invertPrice)) + ps + allprices = + mprices + ++ ifBoolOpt "infer-market-prices" cprices + ++ ifBoolOpt "infer-reverse-prices" rcprices -- TODO: shouldn't this show reversed P prices also ? valuation will use them + mapM_ (T.putStrLn . showPriceDirective) $ sortOn pddate $ filter (matchesPriceDirective q) $ diff --git a/hledger/Hledger/Cli/Commands/Prices.md b/hledger/Hledger/Cli/Commands/Prices.md index 7f03ddbda..e5786de0d 100644 --- a/hledger/Hledger/Cli/Commands/Prices.md +++ b/hledger/Hledger/Cli/Commands/Prices.md @@ -1,8 +1,8 @@ prices\ Print [market price directives](https://hledger.org/manual#market-prices) from the journal. -With --costs, also print synthetic market prices based on [transaction prices](https://hledger.org/manual#transaction-prices). -With --inverted-costs, also print inverse prices based on transaction prices. -Prices (and postings providing prices) can be filtered by a query. -Price amounts are always displayed with their full precision. +With --infer-market-prices, generate additional market prices from [transaction prices](https://hledger.org/manual#transaction-prices). +With --infer-reverse-prices, also generate market prices by inverting transaction prices. +Prices (and postings providing transaction prices) can be filtered by a query. +Price amounts are displayed with their full precision. _FLAGS diff --git a/hledger/shell-completion/hledger-completion.bash b/hledger/shell-completion/hledger-completion.bash index 34924350a..1a3559dd4 100644 --- a/hledger/shell-completion/hledger-completion.bash +++ b/hledger/shell-completion/hledger-completion.bash @@ -1600,7 +1600,6 @@ read -r -d "" _hledger_complist_options_prices <<"__TEXT__" --cleared --color= --cost ---costs --daily --date2 --debug= @@ -1613,8 +1612,8 @@ read -r -d "" _hledger_complist_options_prices <<"__TEXT__" --help --ignore-assertions --infer-market-prices +--infer-reverse-prices --info ---inverted-costs --man --market --monthly diff --git a/hledger/test/prices.test b/hledger/test/prices.test index 18ae5c8b1..129ce4986 100644 --- a/hledger/test/prices.test +++ b/hledger/test/prices.test @@ -32,13 +32,13 @@ P 2016/2/1 EUR $1.05 2016/1/3 spend expenses 20 EUR @@ $21.45 assets:bank -$ hledger prices -f- --costs +$ hledger prices -f- --infer-market-prices P 2016-01-01 EUR $1.06 P 2016-01-02 EUR $1.07 P 2016-01-03 EUR $1.0725 P 2016-02-01 EUR $1.05 -# 3. inverted costs from postings can be calculated +# 3. inverted prices can be calculated < P 2016/1/1 EUR $1.06 P 2016/2/1 EUR $1.05 @@ -51,7 +51,7 @@ P 2016/2/1 EUR $1.05 2016/1/3 spend expenses $21.45 @@ 20.00 EUR assets:bank -$ hledger prices -f- --inverted-costs +$ hledger prices -f- --infer-reverse-prices P 2016-01-01 EUR $1.06 P 2016-01-03 EUR $1.0725 P 2016-02-01 EUR $1.05 @@ -74,7 +74,7 @@ P 2019-01-01 X 1.000,123 A P 2019-01-02 X 1.000,1 A # 5. Commodity styles aren't yet applied to prices inferred from transaction prices. -$ hledger -f- prices --costs +$ hledger -f- prices --infer-market-prices P 2019-01-01 X 1.000,123 A P 2019-01-02 X 1.000,1 A P 2019-02-01 X 1.000,2345 A