diff --git a/hledger-lib/Hledger/Data/Valuation.hs b/hledger-lib/Hledger/Data/Valuation.hs index d9971eea5..2e047d490 100644 --- a/hledger-lib/Hledger/Data/Valuation.hs +++ b/hledger-lib/Hledger/Data/Valuation.hs @@ -314,6 +314,7 @@ pricesAtDate pricedirectives transactionimpliedmarketprices d = -- trace ("pricesAtDate ("++show d++")") $ PriceGraph{prGraph=g, prNodemap=m, prDefaultValuationCommodities=defaultdests} where + declaredprices = map priceDirectiveToMarketPrice $ filter ((<=d).pddate) pricedirectives declaredandimpliedprices = latestPriceForEachPairOn pricedirectives transactionimpliedmarketprices d -- infer any additional reverse prices not already declared or implied @@ -331,9 +332,10 @@ pricesAtDate pricedirectives transactionimpliedmarketprices d = prices = declaredandimpliedprices ++ reverseprices allcomms = map mpfrom prices - -- save the forward prices' destinations as the default valuation - -- commodity for those source commodities - defaultdests = M.fromList [(mpfrom,mpto) | MarketPrice{..} <- declaredandimpliedprices] + -- save the forward prices' destinations (but only from declared + -- market prices) as the default valuation commodity for those + -- source commodities + defaultdests = M.fromList [(mpfrom,mpto) | MarketPrice{..} <- declaredprices] -- From a list of price directives in parse order, and a list of -- transaction-implied market prices in parse order, get the effective diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index be2aae481..9713db9e7 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -1153,9 +1153,9 @@ their *default valuation commodity*, using the [market prices](#market-prices) in effect on a *default valuation date*. (More on these below.) The default valuation commodity is the one referenced in the latest -applicable market price dated on or before the valuation date. -Typically your P declarations or currency exchange transactions -reference a single base currency, and -V will pick that. +applicable market price (declared by a P directive, for the source +commodity, dated on or before the valuation date). Typically your P +declarations reference a single base currency, and -V will pick that. The default valuation date is today for single period reports (equivalent to `--value=now`), or the last day of each subperiod for [multiperiod reports](#report-intervals) (equivalent to `--value=end`).