From 46093b8de7d35a464032c3c7aa9c64ebf946abb1 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Thu, 17 Dec 2020 17:26:22 +1100 Subject: [PATCH] lib,ui: For hledger-ui, do valuation for all valuation types, not just AtCost and AtDefault. Remove unused valuationTypeIs* functions. --- hledger-lib/Hledger/Reports/BudgetReport.hs | 4 +++- hledger-lib/Hledger/Reports/ReportOptions.hs | 14 -------------- hledger-ui/Hledger/UI/TransactionScreen.hs | 4 +--- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/hledger-lib/Hledger/Reports/BudgetReport.hs b/hledger-lib/Hledger/Reports/BudgetReport.hs index dee7ba58a..776d9745f 100644 --- a/hledger-lib/Hledger/Reports/BudgetReport.hs +++ b/hledger-lib/Hledger/Reports/BudgetReport.hs @@ -284,7 +284,9 @@ budgetReportAsText ropts@ReportOpts{..} budgetr = _ -> -- trace (pshow $ (maybecost actual, maybecost budget)) -- debug missing percentage Nothing where - maybecost = if valuationTypeIsCost ropts then mixedAmountCost else id + maybecost = case value_ of + Just (AtCost _) -> mixedAmountCost + _ -> id maybetranspose | transpose_ = \(Table rh ch vals) -> Table ch rh (transpose vals) | otherwise = id diff --git a/hledger-lib/Hledger/Reports/ReportOptions.hs b/hledger-lib/Hledger/Reports/ReportOptions.hs index 3d7fc6ae4..d1863ec04 100644 --- a/hledger-lib/Hledger/Reports/ReportOptions.hs +++ b/hledger-lib/Hledger/Reports/ReportOptions.hs @@ -39,8 +39,6 @@ module Hledger.Reports.ReportOptions ( reportPeriodOrJournalStart, reportPeriodLastDay, reportPeriodOrJournalLastDay, - valuationTypeIsCost, - valuationTypeIsDefaultValue, ) where @@ -429,18 +427,6 @@ valuationTypeFromRawOpts = lastMay . collectopts valuationfromrawopt "" -> Nothing c -> Just $ T.pack c -valuationTypeIsCost :: ReportOpts -> Bool -valuationTypeIsCost ropts = - case value_ ropts of - Just (AtCost _) -> True - _ -> False - -valuationTypeIsDefaultValue :: ReportOpts -> Bool -valuationTypeIsDefaultValue ropts = - case value_ ropts of - Just (AtDefault _) -> True - _ -> False - -- | Select the Transaction date accessor based on --date2. transactionDateFn :: ReportOpts -> (Transaction -> Day) transactionDateFn ReportOpts{..} = if date2_ then transactionDate2 else tdate diff --git a/hledger-ui/Hledger/UI/TransactionScreen.hs b/hledger-ui/Hledger/UI/TransactionScreen.hs index eba68f026..2f65c7e2c 100644 --- a/hledger-ui/Hledger/UI/TransactionScreen.hs +++ b/hledger-ui/Hledger/UI/TransactionScreen.hs @@ -81,10 +81,8 @@ tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec@ReportSpec{ render $ defaultLayout toplabel bottomlabel $ str $ showTransactionOneLineAmounts $ - (if valuationTypeIsCost ropts then transactionToCost (journalCommodityStyles j) else id) $ - (if valuationTypeIsDefaultValue ropts then (\t -> transactionApplyValuation prices styles periodlast (rsToday rspec) t (AtDefault Nothing)) else id) $ + maybe t (transactionApplyValuation prices styles periodlast (rsToday rspec) t) $ value_ ropts -- (if real_ ropts then filterTransactionPostings (Real True) else id) -- filter postings by --real - t where toplabel = str "Transaction "