mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-29 05:11:33 +03:00
lib: Remove unused (amount|mixedAmount|posting|transaction)ApplyCostValuation functions.
This commit is contained in:
parent
53611be6e9
commit
dc16451de0
@ -64,7 +64,6 @@ module Hledger.Data.Posting (
|
||||
-- * misc.
|
||||
showComment,
|
||||
postingTransformAmount,
|
||||
postingApplyCostValuation,
|
||||
postingApplyValuation,
|
||||
postingToCost,
|
||||
tests_Posting
|
||||
@ -332,14 +331,6 @@ aliasReplace (BasicAlias old new) a
|
||||
aliasReplace (RegexAlias re repl) a =
|
||||
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
|
||||
-- provided price oracle, commodity styles, and reference dates.
|
||||
-- See amountApplyValuation.
|
||||
|
@ -33,7 +33,6 @@ module Hledger.Data.Transaction (
|
||||
balanceTransaction,
|
||||
balanceTransactionHelper,
|
||||
transactionTransformPostings,
|
||||
transactionApplyCostValuation,
|
||||
transactionApplyValuation,
|
||||
transactionToCost,
|
||||
transactionApplyAliases,
|
||||
@ -615,13 +614,6 @@ postingSetTransaction t p = p{ptransaction=Just t}
|
||||
transactionTransformPostings :: (Posting -> Posting) -> Transaction -> Transaction
|
||||
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
|
||||
-- the provided price oracle, commodity styles, and reference dates.
|
||||
-- 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.
|
||||
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.
|
||||
-- This can fail due to a bad replacement pattern in a regular expression alias.
|
||||
|
@ -17,10 +17,7 @@ module Hledger.Data.Valuation (
|
||||
,ValuationType(..)
|
||||
,PriceOracle
|
||||
,journalPriceOracle
|
||||
,amountApplyCostValuation
|
||||
,amountApplyValuation
|
||||
,amountValueAtDate
|
||||
,mixedAmountApplyCostValuation
|
||||
,mixedAmountToCost
|
||||
,mixedAmountApplyValuation
|
||||
,mixedAmountValueAtDate
|
||||
,marketPriceReverse
|
||||
@ -100,13 +97,9 @@ priceDirectiveToMarketPrice PriceDirective{..} =
|
||||
------------------------------------------------------------------------------
|
||||
-- Converting things to value
|
||||
|
||||
-- | Apply a specified costing and valuation to this mixed 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.
|
||||
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)
|
||||
-- | Convert all component amounts to cost/selling price if requested, and style them.
|
||||
mixedAmountToCost :: Costing -> M.Map CommoditySymbol AmountStyle -> MixedAmount -> MixedAmount
|
||||
mixedAmountToCost cost styles = mapMixedAmount (amountToCost cost styles)
|
||||
|
||||
-- | Apply a specified valuation to this mixed amount, using the
|
||||
-- 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 =
|
||||
mapMixedAmount (amountApplyValuation priceoracle styles periodlast today postingdate v)
|
||||
|
||||
-- | Apply a specified costing and valuation to this 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.
|
||||
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
|
||||
-- | Convert an Amount to its cost if requested, and style it appropriately.
|
||||
amountToCost :: Costing -> M.Map CommoditySymbol AmountStyle -> Amount -> Amount
|
||||
amountToCost NoCost _ = id
|
||||
amountToCost Cost styles = styleAmount styles . amountCost
|
||||
|
||||
-- | Apply a specified valuation to this amount, using the provided
|
||||
-- price oracle, reference dates, and whether this is for a
|
||||
@ -151,7 +136,7 @@ amountApplyCostValuation priceoracle styles periodlast today postingdate cost v
|
||||
--
|
||||
-- - the provided "today" date - (--value=now, or -V/X with no report
|
||||
-- end date).
|
||||
--
|
||||
--
|
||||
-- This is all a bit complicated. See the reference doc at
|
||||
-- https://hledger.org/hledger.html#effect-of-valuation-on-reports
|
||||
-- (hledger_options.m4.md "Effect of valuation on reports"), and #1083.
|
||||
|
@ -63,7 +63,10 @@ roi CliOpts{rawopts_=rawopts, reportspec_=rspec@ReportSpec{rsOpts=ReportOpts{..}
|
||||
priceOracle = journalPriceOracle infer_value_ j
|
||||
styles = journalCommodityStyles j
|
||||
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
|
||||
ropts = rsOpts rspec
|
||||
showCashFlow = boolopt "cashflow" rawopts
|
||||
|
Loading…
Reference in New Issue
Block a user