From 0c23619ae73c7877c881ced3844dd7697828323c Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Thu, 17 Dec 2020 17:00:04 +1100 Subject: [PATCH] lib: Valuation has changed; and -V now acts like --value=end. --- hledger-lib/Hledger/Reports/MultiBalanceReport.hs | 4 ++-- hledger-lib/Hledger/Reports/ReportOptions.hs | 4 ++-- hledger/Hledger/Cli/CliOptions.hs | 5 ++--- hledger/hledger.m4.md | 2 +- hledger/test/journal/valuation.test | 8 ++++---- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs index 732bae622..e0b8b2ac8 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs @@ -145,7 +145,7 @@ compoundBalanceReportWith rspec' j priceoracle subreportspecs = cbr -- Queries, report/column dates. reportspan = dbg3 "reportspan" $ calculateReportSpan rspec' j rspec = dbg3 "reportopts" $ makeReportQuery rspec' reportspan - valuation = makeValuation rspec' j priceoracle -- Must use ropts' instead of ropts, + valuation = makeValuation rspec' j priceoracle -- Must use rspec' instead of rspec, -- so the reportspan isn't used for valuation -- Group postings into their columns. @@ -257,7 +257,7 @@ makeValuation rspec j priceoracle day = case value_ (rsOpts rspec) of where -- Some things needed if doing valuation. styles = journalCommodityStyles j - mreportlast = reportPeriodLastDay rspec + mreportlast = reportPeriodOrJournalLastDay rspec j multiperiod = interval_ (rsOpts rspec) /= NoInterval -- | Group postings, grouped by their column diff --git a/hledger-lib/Hledger/Reports/ReportOptions.hs b/hledger-lib/Hledger/Reports/ReportOptions.hs index 988a7513f..3d7fc6ae4 100644 --- a/hledger-lib/Hledger/Reports/ReportOptions.hs +++ b/hledger-lib/Hledger/Reports/ReportOptions.hs @@ -409,8 +409,8 @@ valuationTypeFromRawOpts = lastMay . collectopts valuationfromrawopt where valuationfromrawopt (n,v) -- option name, value | n == "B" = Just $ AtCost Nothing - | n == "V" = Just $ AtDefault Nothing - | n == "X" = Just $ AtDefault (Just $ T.pack v) + | n == "V" = Just $ AtEnd Nothing + | n == "X" = Just $ AtEnd (Just $ T.pack v) | n == "value" = Just $ valuation v | otherwise = Nothing valuation v diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 5c7d8a588..092597105 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -156,9 +156,8 @@ reportflags = [ "show amounts converted to their cost/selling amount, using the transaction price. Equivalent to --value=cost." ,flagNone ["V","market"] (setboolopt "V") (unwords - ["show amounts converted to current market value (single period reports)" - ,"or period-end market value (multiperiod reports) in their default valuation commodity." - ,"Equivalent to --value=now / --value=end." + ["show amounts converted to period-end market value in their default valuation commodity." + ,"Equivalent to --value=end." ]) ,flagReq ["X","exchange"] (\s opts -> Right $ setopt "X" s opts) "COMM" (unwords diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index 165043eae..e6f9821f3 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -1206,7 +1206,7 @@ market prices will be used. For single period reports, if an explicit [report end date](#report-start-end-date) is specified, that will be -used as the valuation date; otherwise the valuation date is "today". +used as the valuation date; otherwise the valuation date is the journal's end date. For [multiperiod reports](#report-intervals), each column/period is valued on the last day of the period, by default. diff --git a/hledger/test/journal/valuation.test b/hledger/test/journal/valuation.test index 9c9b56057..ddde3958f 100644 --- a/hledger/test/journal/valuation.test +++ b/hledger/test/journal/valuation.test @@ -46,7 +46,7 @@ $ hledger -f- bal -N -V a # 4. Market prices in the future are ignored when the valuation date -# is today, which is the default with -V. #453, #683 +# is today. #453, #683 < P 2000/1/1 $ €1.20 P 3000/1/1 $ €1.30 @@ -54,7 +54,7 @@ P 3000/1/1 $ €1.30 3000/01/01 (a) $100 -$ hledger -f- bal -N -V +$ hledger -f- bal -N --value=now €120.00 a @@ -300,7 +300,7 @@ $ hledger -f- reg --value=cost -M 2000-01 a 13 B 13 B 2000-02 a 8 B 21 B 2000-03 a 9 B 30 B - + # back to the original test journal: < P 2000/01/01 A 1 B @@ -360,7 +360,7 @@ $ hledger -f- bal -N --value=2000-01-15 $ hledger -f- bal -N --value=now 12 B a -# 33. single column balance report valued at default date (same as --value=now) +# 33. single column balance report valued at default date (same as --value=end) $ hledger -f- bal -N -V 12 B a