cln: Remove unnecessary normaliseMixedAmount(SquashPricesForDisplay)? functions.
This commit is contained in:
parent
c0fd79a40e
commit
378df77001
@ -30,9 +30,9 @@ commodities; this is the type most often used:
|
|||||||
16h + $13.55 + AAPL 500 + 6 oranges
|
16h + $13.55 + AAPL 500 + 6 oranges
|
||||||
@
|
@
|
||||||
|
|
||||||
When a mixed amount has been \"normalised\", it has no more than one amount
|
A mixed amount is always \"normalised\", it has no more than one amount
|
||||||
in each commodity and no zero amounts; or it has just a single zero amount
|
in each commodity and price. When calling 'amounts' it will have no zero
|
||||||
and no others.
|
amounts, or just a single zero amount and no other amounts.
|
||||||
|
|
||||||
Limited arithmetic with simple and mixed amounts is supported, best used
|
Limited arithmetic with simple and mixed amounts is supported, best used
|
||||||
with similar amounts since it mostly ignores assigned prices and commodity
|
with similar amounts since it mostly ignores assigned prices and commodity
|
||||||
@ -106,8 +106,6 @@ module Hledger.Data.Amount (
|
|||||||
filterMixedAmount,
|
filterMixedAmount,
|
||||||
filterMixedAmountByCommodity,
|
filterMixedAmountByCommodity,
|
||||||
mapMixedAmount,
|
mapMixedAmount,
|
||||||
normaliseMixedAmountSquashPricesForDisplay,
|
|
||||||
normaliseMixedAmount,
|
|
||||||
unifyMixedAmount,
|
unifyMixedAmount,
|
||||||
mixedAmountStripPrices,
|
mixedAmountStripPrices,
|
||||||
-- ** arithmetic
|
-- ** arithmetic
|
||||||
@ -642,7 +640,7 @@ averageMixedAmounts as = fromIntegral (length as) `divideMixedAmount` maSum as
|
|||||||
-- Ie when normalised, are all individual commodity amounts negative ?
|
-- Ie when normalised, are all individual commodity amounts negative ?
|
||||||
isNegativeMixedAmount :: MixedAmount -> Maybe Bool
|
isNegativeMixedAmount :: MixedAmount -> Maybe Bool
|
||||||
isNegativeMixedAmount m =
|
isNegativeMixedAmount m =
|
||||||
case amounts $ normaliseMixedAmountSquashPricesForDisplay m of
|
case amounts $ mixedAmountStripPrices m of
|
||||||
[] -> Just False
|
[] -> Just False
|
||||||
[a] -> Just $ isNegativeAmount a
|
[a] -> Just $ isNegativeAmount a
|
||||||
as | all isNegativeAmount as -> Just True
|
as | all isNegativeAmount as -> Just True
|
||||||
@ -708,13 +706,6 @@ maCommodities :: MixedAmount -> S.Set CommoditySymbol
|
|||||||
maCommodities = S.fromList . fmap acommodity . amounts'
|
maCommodities = S.fromList . fmap acommodity . amounts'
|
||||||
where amounts' ma@(Mixed m) = if M.null m then [] else amounts ma
|
where amounts' ma@(Mixed m) = if M.null m then [] else amounts ma
|
||||||
|
|
||||||
normaliseMixedAmount :: MixedAmount -> MixedAmount
|
|
||||||
normaliseMixedAmount = id -- XXX Remove
|
|
||||||
|
|
||||||
-- | Strip prices from a MixedAmount.
|
|
||||||
normaliseMixedAmountSquashPricesForDisplay :: MixedAmount -> MixedAmount
|
|
||||||
normaliseMixedAmountSquashPricesForDisplay = mixedAmountStripPrices -- XXX Remove
|
|
||||||
|
|
||||||
-- | Unify a MixedAmount to a single commodity value if possible.
|
-- | Unify a MixedAmount to a single commodity value if possible.
|
||||||
-- This consolidates amounts of the same commodity and discards zero
|
-- This consolidates amounts of the same commodity and discards zero
|
||||||
-- amounts; but this one insists on simplifying to a single commodity,
|
-- amounts; but this one insists on simplifying to a single commodity,
|
||||||
|
|||||||
@ -159,7 +159,7 @@ close CliOpts{rawopts_=rawopts, reportspec_=rspec} j = do
|
|||||||
: [posting{paccount=openingacct, pamount=mixedAmount . precise $ negate b} | interleaved]
|
: [posting{paccount=openingacct, pamount=mixedAmount . precise $ negate b} | interleaved]
|
||||||
|
|
||||||
| (a,mb) <- acctbals
|
| (a,mb) <- acctbals
|
||||||
, let bs = amounts $ normaliseMixedAmount mb
|
, let bs = amounts mb
|
||||||
-- mark the last balance in each commodity with the unpriced sum in that commodity (for a balance assertion)
|
-- mark the last balance in each commodity with the unpriced sum in that commodity (for a balance assertion)
|
||||||
, let bs' = concat [reverse $ zip (reverse bs) (Just commoditysum : repeat Nothing)
|
, let bs' = concat [reverse $ zip (reverse bs) (Just commoditysum : repeat Nothing)
|
||||||
| bs <- groupBy ((==) `on` acommodity) bs
|
| bs <- groupBy ((==) `on` acommodity) bs
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user