From 0bc86c95e447bd639acec54db902e126d3f272a8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 7 Dec 2023 14:39:52 -1000 Subject: [PATCH] lib: Hledger.Data.Amount: noPrice -> noCost --- hledger-lib/Hledger/Data/Amount.hs | 16 ++++++++-------- hledger-lib/Hledger/Data/Posting.hs | 8 ++++---- hledger-lib/Hledger/Reports/BudgetReport.hs | 2 +- hledger/Hledger/Cli/Commands/Balance.hs | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hledger-lib/Hledger/Data/Amount.hs b/hledger-lib/Hledger/Data/Amount.hs index 065a54f8b..b4e1f0f5d 100644 --- a/hledger-lib/Hledger/Data/Amount.hs +++ b/hledger-lib/Hledger/Data/Amount.hs @@ -80,7 +80,7 @@ module Hledger.Data.Amount ( -- ** rendering AmountDisplayOpts(..), noColour, - noPrice, + noCost, oneLine, csvDisplay, showAmountB, @@ -174,7 +174,7 @@ import Data.List (find, foldl', intercalate, intersperse, mapAccumL, partition) import Data.List.NonEmpty (NonEmpty(..), nonEmpty) import qualified Data.Map.Strict as M import qualified Data.Set as S -import Data.Maybe (fromMaybe, isNothing, isJust) +import Data.Maybe (fromMaybe, isNothing) import Data.Semigroup (Semigroup(..)) import qualified Data.Text as T import qualified Data.Text.Lazy.Builder as TB @@ -253,8 +253,8 @@ noColour = AmountDisplayOpts { } -- | Display Amount and MixedAmount with no prices. -noPrice :: AmountDisplayOpts -noPrice = def{displayCost=False} +noCost :: AmountDisplayOpts +noCost = def{displayCost=False} -- | Display Amount and MixedAmount on one line with no prices. oneLine :: AmountDisplayOpts @@ -682,9 +682,9 @@ cshowAmount = wbUnpack . showAmountB def{displayColour=True} -- | Get the string representation of an amount, without any \@ price. -- --- > showAmountWithoutPrice = wbUnpack . showAmountB noPrice +-- > showAmountWithoutPrice = wbUnpack . showAmountB noCost showAmountWithoutPrice :: Amount -> String -showAmountWithoutPrice = wbUnpack . showAmountB noPrice +showAmountWithoutPrice = wbUnpack . showAmountB noCost -- | Like showAmount, but show a zero amount's commodity if it has one. -- @@ -1057,9 +1057,9 @@ showMixedAmountWithZeroCommodity = wbUnpack . showMixedAmountB noColour{displayZ -- | Get the string representation of a mixed amount, without showing any transaction prices. -- With a True argument, adds ANSI codes to show negative amounts in red. -- --- > showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noPrice{displayColour=c} +-- > showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noCost{displayColour=c} showMixedAmountWithoutPrice :: Bool -> MixedAmount -> String -showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noPrice{displayColour=c} +showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noCost{displayColour=c} -- | Get the one-line string representation of a mixed amount, but without -- any \@ prices. diff --git a/hledger-lib/Hledger/Data/Posting.hs b/hledger-lib/Hledger/Data/Posting.hs index 0b544276c..51df12c00 100644 --- a/hledger-lib/Hledger/Data/Posting.hs +++ b/hledger-lib/Hledger/Data/Posting.hs @@ -539,11 +539,11 @@ postingApplyValuation priceoracle styles periodlast today v p = postingToCost :: ConversionOp -> Posting -> Maybe Posting postingToCost NoConversionOp p = Just p postingToCost ToCost p - -- If this is a conversion posting with a matched transaction price posting, ignore it - | "_conversion-matched" `elem` map fst (ptags p) && noCost = Nothing - | otherwise = Just $ postingTransformAmount mixedAmountCost p + -- If this is a conversion posting with a matched transaction price posting, ignore it + | "_conversion-matched" `elem` map fst (ptags p) && nocosts = Nothing + | otherwise = Just $ postingTransformAmount mixedAmountCost p where - noCost = (not . any (isJust . aprice) . amountsRaw) $ pamount p + nocosts = (not . any (isJust . aprice) . amountsRaw) $ pamount p -- | Generate inferred equity postings from a 'Posting' using transaction prices. -- Make sure not to generate equity postings when there are already matched diff --git a/hledger-lib/Hledger/Reports/BudgetReport.hs b/hledger-lib/Hledger/Reports/BudgetReport.hs index 031e5178d..5d9ef42ac 100644 --- a/hledger-lib/Hledger/Reports/BudgetReport.hs +++ b/hledger-lib/Hledger/Reports/BudgetReport.hs @@ -339,7 +339,7 @@ budgetReportAsTable LayoutWide width -> ( pure . showMixedAmountB oneLine{displayColour=color_, displayMaxWidth=width} , \a -> pure . percentage a) - _ -> ( showMixedAmountLinesB noPrice{displayCommodityOrder=Just cs, displayMinWidth=Nothing, displayColour=color_} + _ -> ( showMixedAmountLinesB noCost{displayCommodityOrder=Just cs, displayMinWidth=Nothing, displayColour=color_} , \a b -> fmap (percentage' a b) cs) showrow :: [BudgetCell] -> [(WideBuilder, BudgetDisplayRow)] diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index c03602641..61199dba2 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -524,7 +524,7 @@ renderComponent topaligned oneline opts (acctname, dep, total) (FormatField ljus | topaligned = TopRight | ljust = BottomLeft | otherwise = BottomRight - dopts = noPrice{displayColour=color_ opts, displayOneLine=oneline, displayMinWidth=mmin, displayMaxWidth=mmax} + dopts = noCost{displayColour=color_ opts, displayOneLine=oneline, displayMinWidth=mmin, displayMaxWidth=mmax} -- rendering multi-column balance reports