From 9d3eb8c069d3de51e56d4f9964fd356fb35883ec Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 24 Apr 2019 08:31:21 -0700 Subject: [PATCH] bal, reg, print: -V prefers non-future valuation dates again (#999) --- hledger-lib/Hledger/Reports/BalanceReport.hs | 4 ++-- hledger-lib/Hledger/Reports/EntriesReport.hs | 4 ++-- hledger-lib/Hledger/Reports/MultiBalanceReports.hs | 4 ++-- hledger-lib/Hledger/Reports/PostingsReport.hs | 4 ++-- tests/journal/market-prices.test | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hledger-lib/Hledger/Reports/BalanceReport.hs b/hledger-lib/Hledger/Reports/BalanceReport.hs index 789f312be..1de44f9af 100644 --- a/hledger-lib/Hledger/Reports/BalanceReport.hs +++ b/hledger-lib/Hledger/Reports/BalanceReport.hs @@ -173,10 +173,10 @@ brNegate (is, tot) = (map brItemNegate is, -tot) -- default valuation commodities. This means using the Journal's most -- recent applicable market prices before the valuation date. -- The valuation date is the specified report end date if any, --- otherwise the journal's end date. +-- otherwise the current date, otherwise the journal's end date. brValue :: ReportOpts -> Journal -> BalanceReport -> BalanceReport brValue ropts j r = - let mvaluationdate = periodEnd (period_ ropts) <|> journalEndDate False j + let mvaluationdate = periodEnd (period_ ropts) <|> today_ ropts <|> journalEndDate False j in case mvaluationdate of Nothing -> r Just d -> r' diff --git a/hledger-lib/Hledger/Reports/EntriesReport.hs b/hledger-lib/Hledger/Reports/EntriesReport.hs index deebd02f9..e423561e3 100644 --- a/hledger-lib/Hledger/Reports/EntriesReport.hs +++ b/hledger-lib/Hledger/Reports/EntriesReport.hs @@ -43,10 +43,10 @@ entriesReport opts q j = -- default valuation commodities. This means using the Journal's most -- recent applicable market prices before the valuation date. -- The valuation date is the specified report end date if any, --- otherwise the journal's end date. +-- otherwise the current date, otherwise the journal's end date. erValue :: ReportOpts -> Journal -> EntriesReport -> EntriesReport erValue ropts j ts = - let mvaluationdate = periodEnd (period_ ropts) <|> journalEndDate False j + let mvaluationdate = periodEnd (period_ ropts) <|> today_ ropts <|> journalEndDate False j in case mvaluationdate of Nothing -> ts Just d -> map valuetxn ts diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReports.hs b/hledger-lib/Hledger/Reports/MultiBalanceReports.hs index 32407afbc..5208a3b9f 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReports.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReports.hs @@ -277,10 +277,10 @@ multiBalanceReportSpan (MultiBalanceReport (colspans, _, _)) = DateSpan (spanSta -- default valuation commodities. This means using the Journal's most -- recent applicable market prices before the valuation date. -- The valuation date is the specified report end date if any, --- otherwise the journal's end date. +-- otherwise the current date, otherwise the journal's end date. mbrValue :: ReportOpts -> Journal -> MultiBalanceReport -> MultiBalanceReport mbrValue ropts j r = - let mvaluationdate = periodEnd (period_ ropts) <|> journalEndDate False j + let mvaluationdate = periodEnd (period_ ropts) <|> today_ ropts <|> journalEndDate False j in case mvaluationdate of Nothing -> r Just d -> r' diff --git a/hledger-lib/Hledger/Reports/PostingsReport.hs b/hledger-lib/Hledger/Reports/PostingsReport.hs index 557155710..95182c2ae 100644 --- a/hledger-lib/Hledger/Reports/PostingsReport.hs +++ b/hledger-lib/Hledger/Reports/PostingsReport.hs @@ -229,10 +229,10 @@ negatePostingAmount p = p { pamount = negate $ pamount p } -- default valuation commodities. This means using the Journal's most -- recent applicable market prices before the valuation date. -- The valuation date is the specified report end date if any, --- otherwise the journal's end date. +-- otherwise the current date, otherwise the journal's end date. prValue :: ReportOpts -> Journal -> PostingsReport -> PostingsReport prValue ropts j r = - let mvaluationdate = periodEnd (period_ ropts) <|> journalEndDate False j + let mvaluationdate = periodEnd (period_ ropts) <|> today_ ropts <|> journalEndDate False j in case mvaluationdate of Nothing -> r Just d -> r' diff --git a/tests/journal/market-prices.test b/tests/journal/market-prices.test index ce81fe06f..417b543b3 100644 --- a/tests/journal/market-prices.test +++ b/tests/journal/market-prices.test @@ -38,7 +38,7 @@ P 3000/1/1 $ €1.30 3000/01/01 (a) $100 >>> - €130.00 a + €120.00 a >>>=0 # 4. The market prices in effect at the report end date are used.