lib: Hledger.Data.Amount: noPrice -> noCost
This commit is contained in:
parent
862b7e5712
commit
0bc86c95e4
@ -80,7 +80,7 @@ module Hledger.Data.Amount (
|
|||||||
-- ** rendering
|
-- ** rendering
|
||||||
AmountDisplayOpts(..),
|
AmountDisplayOpts(..),
|
||||||
noColour,
|
noColour,
|
||||||
noPrice,
|
noCost,
|
||||||
oneLine,
|
oneLine,
|
||||||
csvDisplay,
|
csvDisplay,
|
||||||
showAmountB,
|
showAmountB,
|
||||||
@ -174,7 +174,7 @@ import Data.List (find, foldl', intercalate, intersperse, mapAccumL, partition)
|
|||||||
import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
|
import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import Data.Maybe (fromMaybe, isNothing, isJust)
|
import Data.Maybe (fromMaybe, isNothing)
|
||||||
import Data.Semigroup (Semigroup(..))
|
import Data.Semigroup (Semigroup(..))
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Lazy.Builder as TB
|
import qualified Data.Text.Lazy.Builder as TB
|
||||||
@ -253,8 +253,8 @@ noColour = AmountDisplayOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- | Display Amount and MixedAmount with no prices.
|
-- | Display Amount and MixedAmount with no prices.
|
||||||
noPrice :: AmountDisplayOpts
|
noCost :: AmountDisplayOpts
|
||||||
noPrice = def{displayCost=False}
|
noCost = def{displayCost=False}
|
||||||
|
|
||||||
-- | Display Amount and MixedAmount on one line with no prices.
|
-- | Display Amount and MixedAmount on one line with no prices.
|
||||||
oneLine :: AmountDisplayOpts
|
oneLine :: AmountDisplayOpts
|
||||||
@ -682,9 +682,9 @@ cshowAmount = wbUnpack . showAmountB def{displayColour=True}
|
|||||||
|
|
||||||
-- | Get the string representation of an amount, without any \@ price.
|
-- | Get the string representation of an amount, without any \@ price.
|
||||||
--
|
--
|
||||||
-- > showAmountWithoutPrice = wbUnpack . showAmountB noPrice
|
-- > showAmountWithoutPrice = wbUnpack . showAmountB noCost
|
||||||
showAmountWithoutPrice :: Amount -> String
|
showAmountWithoutPrice :: Amount -> String
|
||||||
showAmountWithoutPrice = wbUnpack . showAmountB noPrice
|
showAmountWithoutPrice = wbUnpack . showAmountB noCost
|
||||||
|
|
||||||
-- | Like showAmount, but show a zero amount's commodity if it has one.
|
-- | 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.
|
-- | 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.
|
-- 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 :: 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
|
-- | Get the one-line string representation of a mixed amount, but without
|
||||||
-- any \@ prices.
|
-- any \@ prices.
|
||||||
|
|||||||
@ -539,11 +539,11 @@ postingApplyValuation priceoracle styles periodlast today v p =
|
|||||||
postingToCost :: ConversionOp -> Posting -> Maybe Posting
|
postingToCost :: ConversionOp -> Posting -> Maybe Posting
|
||||||
postingToCost NoConversionOp p = Just p
|
postingToCost NoConversionOp p = Just p
|
||||||
postingToCost ToCost p
|
postingToCost ToCost p
|
||||||
-- If this is a conversion posting with a matched transaction price posting, ignore it
|
-- If this is a conversion posting with a matched transaction price posting, ignore it
|
||||||
| "_conversion-matched" `elem` map fst (ptags p) && noCost = Nothing
|
| "_conversion-matched" `elem` map fst (ptags p) && nocosts = Nothing
|
||||||
| otherwise = Just $ postingTransformAmount mixedAmountCost p
|
| otherwise = Just $ postingTransformAmount mixedAmountCost p
|
||||||
where
|
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.
|
-- | Generate inferred equity postings from a 'Posting' using transaction prices.
|
||||||
-- Make sure not to generate equity postings when there are already matched
|
-- Make sure not to generate equity postings when there are already matched
|
||||||
|
|||||||
@ -339,7 +339,7 @@ budgetReportAsTable
|
|||||||
LayoutWide width ->
|
LayoutWide width ->
|
||||||
( pure . showMixedAmountB oneLine{displayColour=color_, displayMaxWidth=width}
|
( pure . showMixedAmountB oneLine{displayColour=color_, displayMaxWidth=width}
|
||||||
, \a -> pure . percentage a)
|
, \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)
|
, \a b -> fmap (percentage' a b) cs)
|
||||||
|
|
||||||
showrow :: [BudgetCell] -> [(WideBuilder, BudgetDisplayRow)]
|
showrow :: [BudgetCell] -> [(WideBuilder, BudgetDisplayRow)]
|
||||||
|
|||||||
@ -524,7 +524,7 @@ renderComponent topaligned oneline opts (acctname, dep, total) (FormatField ljus
|
|||||||
| topaligned = TopRight
|
| topaligned = TopRight
|
||||||
| ljust = BottomLeft
|
| ljust = BottomLeft
|
||||||
| otherwise = BottomRight
|
| 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
|
-- rendering multi-column balance reports
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user