From e406cebcce112f4e27307cd82a1ba1f46a89d30c Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Thu, 17 Dec 2020 21:45:41 +1100 Subject: [PATCH] lib: Remove unused AtDefault constructor for ValuationType. --- hledger-lib/Hledger/Data/Posting.hs | 1 - hledger-lib/Hledger/Data/Valuation.hs | 2 -- hledger-lib/Hledger/Reports/BudgetReport.hs | 4 ---- .../Hledger/Reports/MultiBalanceReport.hs | 1 - hledger-ui/Hledger/UI/UIState.hs | 4 ++-- hledger/Hledger/Cli/Commands/Balance.hs | 20 +++++++------------ hledger/Hledger/Cli/CompoundBalanceCommand.hs | 11 +++------- 7 files changed, 12 insertions(+), 31 deletions(-) diff --git a/hledger-lib/Hledger/Data/Posting.hs b/hledger-lib/Hledger/Data/Posting.hs index 56c2c173e..0cced45f3 100644 --- a/hledger-lib/Hledger/Data/Posting.hs +++ b/hledger-lib/Hledger/Data/Posting.hs @@ -342,7 +342,6 @@ postingApplyValuation priceoracle styles periodlast today p v = AtThen mc -> postingValueAtDate priceoracle styles mc (postingDate p) p AtEnd mc -> postingValueAtDate priceoracle styles mc periodlast p AtNow mc -> postingValueAtDate priceoracle styles mc today p - AtDefault mc -> postingValueAtDate priceoracle styles mc periodlast p AtDate d mc -> postingValueAtDate priceoracle styles mc d p -- | Convert this posting's amount to cost, and apply the appropriate amount styles. diff --git a/hledger-lib/Hledger/Data/Valuation.hs b/hledger-lib/Hledger/Data/Valuation.hs index 0e4c15bf5..ee4db98f9 100644 --- a/hledger-lib/Hledger/Data/Valuation.hs +++ b/hledger-lib/Hledger/Data/Valuation.hs @@ -57,7 +57,6 @@ data ValuationType = | AtEnd (Maybe CommoditySymbol) -- ^ convert to default or given valuation commodity, using market prices at period end(s) | AtNow (Maybe CommoditySymbol) -- ^ convert to default or given valuation commodity, using current market prices | AtDate Day (Maybe CommoditySymbol) -- ^ convert to default or given valuation commodity, using market prices on some date - | AtDefault (Maybe CommoditySymbol) -- ^ works like AtNow in single period reports, like AtEnd in multiperiod reports deriving (Show,Eq) -- | A price oracle is a magic memoising function that efficiently @@ -141,7 +140,6 @@ amountApplyValuation priceoracle styles periodlast today v a = -- 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 - AtDefault mc -> amountValueAtDate priceoracle styles mc periodlast a AtDate d mc -> amountValueAtDate priceoracle styles mc d a -- | Standard error message for a report not supporting --value=then. diff --git a/hledger-lib/Hledger/Reports/BudgetReport.hs b/hledger-lib/Hledger/Reports/BudgetReport.hs index 776d9745f..e738d7064 100644 --- a/hledger-lib/Hledger/Reports/BudgetReport.hs +++ b/hledger-lib/Hledger/Reports/BudgetReport.hs @@ -224,7 +224,6 @@ budgetReportAsText ropts@ReportOpts{..} budgetr = renderTable def{tableBorders=False,prettyTable=pretty_tables_} (alignCell TopLeft) (alignCell TopRight) (uncurry showcell) displayTableWithWidths where - multiperiod = interval_ /= NoInterval title = printf "Budget performance in %s%s:" (showDateSpan $ periodicReportSpan budgetr) (case value_ of @@ -232,9 +231,6 @@ budgetReportAsText ropts@ReportOpts{..} budgetr = Just (AtThen _mc) -> error' unsupportedValueThenError -- PARTIAL: Just (AtEnd _mc) -> ", valued at period ends" Just (AtNow _mc) -> ", current value" - -- XXX duplicates the above - Just (AtDefault _mc) | multiperiod -> ", valued at period ends" - Just (AtDefault _mc) -> ", current value" Just (AtDate d _mc) -> ", valued at "++showDate d Nothing -> "") diff --git a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs index 3be0d96fe..ff915dd5f 100644 --- a/hledger-lib/Hledger/Reports/MultiBalanceReport.hs +++ b/hledger-lib/Hledger/Reports/MultiBalanceReport.hs @@ -360,7 +360,6 @@ accumValueAmounts ropts valuation colspans startbals acctchanges = -- PARTIAL: fixedValuationDate = case value_ ropts of Just (AtCost (Just _)) -> singleperiod Just (AtEnd _) -> singleperiod - Just (AtDefault _) -> singleperiod _ -> True where singleperiod = interval_ ropts == NoInterval diff --git a/hledger-ui/Hledger/UI/UIState.hs b/hledger-ui/Hledger/UI/UIState.hs index 7daf1d295..b7e8307ca 100644 --- a/hledger-ui/Hledger/UI/UIState.hs +++ b/hledger-ui/Hledger/UI/UIState.hs @@ -128,8 +128,8 @@ valuationToggleCost _ = Just $ AtCost Nothing -- | Basic toggling of -V, for hledger-ui. valuationToggleValue :: Maybe ValuationType -> Maybe ValuationType -valuationToggleValue (Just (AtDefault _)) = Nothing -valuationToggleValue _ = Just $ AtDefault Nothing +valuationToggleValue (Just (AtEnd _)) = Nothing +valuationToggleValue _ = Just $ AtEnd Nothing -- | Set hierarchic account tree mode. setTree :: UIState -> UIState diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 1d1af76b4..775741f97 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -566,28 +566,22 @@ multiBalanceReportAsText ropts@ReportOpts{..} r = title = mtitle <> " in " <> showDateSpan (periodicReportSpan r) <> valuationdesc <> ":" mtitle = case balancetype_ of - PeriodChange | changingValuation -> "Period-end value changes" - PeriodChange -> "Balance changes" - CumulativeChange -> "Ending balances (cumulative)" - HistoricalBalance -> "Ending balances (historical)" + PeriodChange | changingValuation -> "Period-end value changes" + PeriodChange -> "Balance changes" + CumulativeChange -> "Ending balances (cumulative)" + HistoricalBalance -> "Ending balances (historical)" valuationdesc = case value_ of Just (AtCost _mc) -> ", valued at cost" Just (AtThen _mc) -> error' unsupportedValueThenError -- TODO -- ", valued at period ends" -- handled like AtEnd for now -- PARTIAL: Just (AtEnd _mc) | changingValuation -> "" Just (AtEnd _mc) -> ", valued at period ends" Just (AtNow _mc) -> ", current value" - -- XXX duplicates the above - Just (AtDefault _mc) | changingValuation -> "" - Just (AtDefault _mc) | multiperiod -> ", valued at period ends" - Just (AtDefault _mc) -> ", current value" Just (AtDate d _mc) -> ", valued at "++showDate d Nothing -> "" - multiperiod = interval_ /= NoInterval - changingValuation - | PeriodChange <- balancetype_, Just (AtEnd _mc) <- value_ = multiperiod - | PeriodChange <- balancetype_, Just (AtDefault _mc) <- value_ = multiperiod - | otherwise = False + changingValuation = case (balancetype_, value_) of + (PeriodChange, Just (AtEnd _)) -> interval_ /= NoInterval + _ -> False -- | Build a 'Table' from a multi-column balance report. balanceReportAsTable :: ReportOpts -> MultiBalanceReport -> Table String String MixedAmount diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index f6cada00f..3160707cf 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -137,17 +137,12 @@ compoundBalanceCommand CompoundBalanceCommandSpec{..} opts@CliOpts{reportspec_=r Just (AtEnd _mc) | changingValuation -> "" Just (AtEnd _mc) -> ", valued at period ends" Just (AtNow _mc) -> ", current value" - Just (AtDefault _mc) | changingValuation -> "" - Just (AtDefault _mc) | multiperiod -> ", valued at period ends" - Just (AtDefault _mc) -> ", current value" Just (AtDate today _mc) -> ", valued at "++showDate today Nothing -> "" - multiperiod = interval_ /= NoInterval - changingValuation - | PeriodChange <- balancetype_, Just (AtEnd _mc) <- value_ = multiperiod - | PeriodChange <- balancetype_, Just (AtDefault _mc) <- value_ = multiperiod - | otherwise = False + changingValuation = case (balancetype_, value_) of + (PeriodChange, Just (AtEnd _)) -> interval_ /= NoInterval + _ -> False -- make a CompoundBalanceReport. cbr' = compoundBalanceReport rspec{rsOpts=ropts'} j cbcqueries