lib: Valuation has changed; and -V now acts like --value=end.

This commit is contained in:
Stephen Morgan 2020-12-17 17:00:04 +11:00 committed by Simon Michael
parent 8981b3e196
commit 0c23619ae7
5 changed files with 11 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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