;refactor: extract --value=then error message
This commit is contained in:
		
							parent
							
								
									8b520b5c3e
								
							
						
					
					
						commit
						7f16d23898
					
				| @ -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. | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user