diff --git a/hledger-lib/Hledger/Data/Valuation.hs b/hledger-lib/Hledger/Data/Valuation.hs index a46365040..e38fd59aa 100644 --- a/hledger-lib/Hledger/Data/Valuation.hs +++ b/hledger-lib/Hledger/Data/Valuation.hs @@ -15,6 +15,7 @@ module Hledger.Data.Valuation ( ValuationType(..) ,PriceOracle ,journalPriceOracle + ,unsupportedValueThenError -- ,amountApplyValuation -- ,amountValueAtDate ,mixedAmountApplyValuation @@ -137,7 +138,7 @@ amountApplyValuation priceoracle styles periodlast mreportlast today ismultiperi case v of AtCost Nothing -> amountToCost styles a AtCost mc -> amountValueAtDate priceoracle styles mc periodlast $ amountToCost styles a - AtThen _mc -> error' "Sorry, --value=then is not yet implemented for this kind of report." -- TODO + AtThen _mc -> error' unsupportedValueThenError -- TODO -- amountValueAtDate priceoracle styles mc periodlast a -- posting date unknown, handle like AtEnd AtEnd mc -> amountValueAtDate priceoracle styles mc periodlast a AtNow mc -> amountValueAtDate priceoracle styles mc today a @@ -145,6 +146,10 @@ amountApplyValuation priceoracle styles periodlast mreportlast today ismultiperi AtDefault mc -> amountValueAtDate priceoracle styles mc (fromMaybe today mreportlast) a AtDate d mc -> amountValueAtDate priceoracle styles mc d a +-- | Standard error message for a report not supporting --value=then. +unsupportedValueThenError :: String +unsupportedValueThenError = "Sorry, --value=then is not yet implemented for this kind of report." + -- | Find the market value of each component amount in the given -- commodity, or its default valuation commodity, at the given -- valuation date, using the given market price oracle. diff --git a/hledger-lib/Hledger/Reports/BudgetReport.hs b/hledger-lib/Hledger/Reports/BudgetReport.hs index ca4e11230..8977818bf 100644 --- a/hledger-lib/Hledger/Reports/BudgetReport.hs +++ b/hledger-lib/Hledger/Reports/BudgetReport.hs @@ -253,7 +253,7 @@ budgetReportAsText ropts@ReportOpts{..} budgetr = (showDateSpan $ periodicReportSpan budgetr) (case value_ of Just (AtCost _mc) -> ", valued at cost" - Just (AtThen _mc) -> error' "Sorry, --value=then is not yet implemented for this kind of report." -- TODO + Just (AtThen _mc) -> error' unsupportedValueThenError -- TODO Just (AtEnd _mc) -> ", valued at period ends" Just (AtNow _mc) -> ", current value" -- XXX duplicates the above diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index c977e57b0..747bbdd18 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -587,7 +587,7 @@ multiBalanceReportAsText ropts@ReportOpts{..} r = (showDateSpan $ periodicReportSpan r) (case value_ of Just (AtCost _mc) -> ", valued at cost" - Just (AtThen _mc) -> error' "Sorry, --value=then is not yet implemented for this kind of report." -- TODO -- ", valued at period ends" -- handled like AtEnd for now + Just (AtThen _mc) -> error' unsupportedValueThenError -- TODO -- ", valued at period ends" -- handled like AtEnd for now Just (AtEnd _mc) -> ", valued at period ends" Just (AtNow _mc) -> ", current value" -- XXX duplicates the above diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index ca1a0765a..b055b39ab 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -217,7 +217,7 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportopts_=r valuationdesc = case value_ of Just (AtCost _mc) -> ", valued at cost" - Just (AtThen _mc) -> error' "Sorry, --value=then is not yet implemented for this kind of report." -- TODO + Just (AtThen _mc) -> error' unsupportedValueThenError -- TODO Just (AtEnd _mc) -> ", valued at period ends" Just (AtNow _mc) -> ", current value" Just (AtDefault _mc) | multiperiod -> ", valued at period ends"