lib: Remove unused (amount|mixedAmount|posting|transaction)ApplyCostValuation functions.

This commit is contained in:
Stephen Morgan 2021-05-07 21:56:48 +10:00
parent 53611be6e9
commit dc16451de0
4 changed files with 14 additions and 43 deletions

View File

@ -64,7 +64,6 @@ module Hledger.Data.Posting (
-- * misc. -- * misc.
showComment, showComment,
postingTransformAmount, postingTransformAmount,
postingApplyCostValuation,
postingApplyValuation, postingApplyValuation,
postingToCost, postingToCost,
tests_Posting tests_Posting
@ -332,14 +331,6 @@ aliasReplace (BasicAlias old new) a
aliasReplace (RegexAlias re repl) a = aliasReplace (RegexAlias re repl) a =
fmap T.pack . regexReplace re repl $ T.unpack a -- XXX fmap T.pack . regexReplace re repl $ T.unpack a -- XXX
-- | Apply a specified costing and valuation to this posting's amount,
-- using the provided price oracle, commodity styles, and reference dates.
-- Costing is done first if requested, and after that any valuation.
-- See amountApplyValuation and amountCost.
postingApplyCostValuation :: PriceOracle -> M.Map CommoditySymbol AmountStyle -> Day -> Day -> Costing -> Maybe ValuationType -> Posting -> Posting
postingApplyCostValuation priceoracle styles periodlast today cost v p =
postingTransformAmount (mixedAmountApplyCostValuation priceoracle styles periodlast today (postingDate p) cost v) p
-- | Apply a specified valuation to this posting's amount, using the -- | Apply a specified valuation to this posting's amount, using the
-- provided price oracle, commodity styles, and reference dates. -- provided price oracle, commodity styles, and reference dates.
-- See amountApplyValuation. -- See amountApplyValuation.

View File

@ -33,7 +33,6 @@ module Hledger.Data.Transaction (
balanceTransaction, balanceTransaction,
balanceTransactionHelper, balanceTransactionHelper,
transactionTransformPostings, transactionTransformPostings,
transactionApplyCostValuation,
transactionApplyValuation, transactionApplyValuation,
transactionToCost, transactionToCost,
transactionApplyAliases, transactionApplyAliases,
@ -615,13 +614,6 @@ postingSetTransaction t p = p{ptransaction=Just t}
transactionTransformPostings :: (Posting -> Posting) -> Transaction -> Transaction transactionTransformPostings :: (Posting -> Posting) -> Transaction -> Transaction
transactionTransformPostings f t@Transaction{tpostings=ps} = t{tpostings=map f ps} transactionTransformPostings f t@Transaction{tpostings=ps} = t{tpostings=map f ps}
-- | Apply a specified costing and valuation to this transaction's amounts,
-- using the provided price oracle, commodity styles, and reference dates.
-- See amountApplyValuation and amountCost.
transactionApplyCostValuation :: PriceOracle -> M.Map CommoditySymbol AmountStyle -> Day -> Day -> Costing -> Maybe ValuationType -> Transaction -> Transaction
transactionApplyCostValuation priceoracle styles periodlast today cost v =
transactionTransformPostings (postingApplyCostValuation priceoracle styles periodlast today cost v)
-- | Apply a specified valuation to this transaction's amounts, using -- | Apply a specified valuation to this transaction's amounts, using
-- the provided price oracle, commodity styles, and reference dates. -- the provided price oracle, commodity styles, and reference dates.
-- See amountApplyValuation. -- See amountApplyValuation.
@ -631,7 +623,7 @@ transactionApplyValuation priceoracle styles periodlast today v =
-- | Convert this transaction's amounts to cost, and apply the appropriate amount styles. -- | Convert this transaction's amounts to cost, and apply the appropriate amount styles.
transactionToCost :: M.Map CommoditySymbol AmountStyle -> Transaction -> Transaction transactionToCost :: M.Map CommoditySymbol AmountStyle -> Transaction -> Transaction
transactionToCost styles t@Transaction{tpostings=ps} = t{tpostings=map (postingToCost styles) ps} transactionToCost styles = transactionTransformPostings (postingToCost styles)
-- | Apply some account aliases to all posting account names in the transaction, as described by accountNameApplyAliases. -- | Apply some account aliases to all posting account names in the transaction, as described by accountNameApplyAliases.
-- This can fail due to a bad replacement pattern in a regular expression alias. -- This can fail due to a bad replacement pattern in a regular expression alias.

View File

@ -17,10 +17,7 @@ module Hledger.Data.Valuation (
,ValuationType(..) ,ValuationType(..)
,PriceOracle ,PriceOracle
,journalPriceOracle ,journalPriceOracle
,amountApplyCostValuation ,mixedAmountToCost
,amountApplyValuation
,amountValueAtDate
,mixedAmountApplyCostValuation
,mixedAmountApplyValuation ,mixedAmountApplyValuation
,mixedAmountValueAtDate ,mixedAmountValueAtDate
,marketPriceReverse ,marketPriceReverse
@ -100,13 +97,9 @@ priceDirectiveToMarketPrice PriceDirective{..} =
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- Converting things to value -- Converting things to value
-- | Apply a specified costing and valuation to this mixed amount, -- | Convert all component amounts to cost/selling price if requested, and style them.
-- using the provided price oracle, commodity styles, and reference dates. mixedAmountToCost :: Costing -> M.Map CommoditySymbol AmountStyle -> MixedAmount -> MixedAmount
-- Costing is done first if requested, and after that any valuation. mixedAmountToCost cost styles = mapMixedAmount (amountToCost cost styles)
-- See amountApplyValuation and amountCost.
mixedAmountApplyCostValuation :: PriceOracle -> M.Map CommoditySymbol AmountStyle -> Day -> Day -> Day -> Costing -> Maybe ValuationType -> MixedAmount -> MixedAmount
mixedAmountApplyCostValuation priceoracle styles periodlast today postingdate cost v =
mapMixedAmount (amountApplyCostValuation priceoracle styles periodlast today postingdate cost v)
-- | Apply a specified valuation to this mixed amount, using the -- | Apply a specified valuation to this mixed amount, using the
-- provided price oracle, commodity styles, and reference dates. -- provided price oracle, commodity styles, and reference dates.
@ -115,18 +108,10 @@ mixedAmountApplyValuation :: PriceOracle -> M.Map CommoditySymbol AmountStyle ->
mixedAmountApplyValuation priceoracle styles periodlast today postingdate v = mixedAmountApplyValuation priceoracle styles periodlast today postingdate v =
mapMixedAmount (amountApplyValuation priceoracle styles periodlast today postingdate v) mapMixedAmount (amountApplyValuation priceoracle styles periodlast today postingdate v)
-- | Apply a specified costing and valuation to this Amount, -- | Convert an Amount to its cost if requested, and style it appropriately.
-- using the provided price oracle, commodity styles, and reference dates. amountToCost :: Costing -> M.Map CommoditySymbol AmountStyle -> Amount -> Amount
-- Costing is done first if requested, and after that any valuation. amountToCost NoCost _ = id
-- See amountApplyValuation and amountCost. amountToCost Cost styles = styleAmount styles . amountCost
amountApplyCostValuation :: PriceOracle -> M.Map CommoditySymbol AmountStyle -> Day -> Day -> Day -> Costing -> Maybe ValuationType -> Amount -> Amount
amountApplyCostValuation priceoracle styles periodlast today postingdate cost v =
valuation . costing
where
valuation = maybe id (amountApplyValuation priceoracle styles periodlast today postingdate) v
costing = case cost of
Cost -> styleAmount styles . amountCost
NoCost -> id
-- | Apply a specified valuation to this amount, using the provided -- | Apply a specified valuation to this amount, using the provided
-- price oracle, reference dates, and whether this is for a -- price oracle, reference dates, and whether this is for a

View File

@ -63,7 +63,10 @@ roi CliOpts{rawopts_=rawopts, reportspec_=rspec@ReportSpec{rsOpts=ReportOpts{..}
priceOracle = journalPriceOracle infer_value_ j priceOracle = journalPriceOracle infer_value_ j
styles = journalCommodityStyles j styles = journalCommodityStyles j
today = rsToday rspec today = rsToday rspec
mixedAmountValue periodlast date = mixedAmountApplyCostValuation priceOracle styles periodlast today date cost_ value_ mixedAmountValue periodlast date =
maybe id (mixedAmountApplyValuation priceOracle styles periodlast today date) value_
. mixedAmountToCost cost_ styles
let let
ropts = rsOpts rspec ropts = rsOpts rspec
showCashFlow = boolopt "cashflow" rawopts showCashFlow = boolopt "cashflow" rawopts