dev: amountStripPrices -> amountStripCost
This commit is contained in:
parent
0353840d90
commit
e201775e93
@ -156,7 +156,7 @@ main = do
|
||||
force = boolopt "force" rawopts
|
||||
|
||||
-- parse the AMT arg as a cost-less Amount (any provided cost is ignored)
|
||||
eamt = styleAmount (journalCommodityStyles j) . amountStripPrices <$> parseamount amtarg
|
||||
eamt = styleAmount (journalCommodityStyles j) . amountStripCost <$> parseamount amtarg
|
||||
amt = case eamt of
|
||||
Left err ->
|
||||
error' $ "could not parse " ++ show amtarg ++ " as a hledger amount\n" ++ customErrorBundlePretty err ++ "\n" ++shortusage
|
||||
@ -220,7 +220,7 @@ main = do
|
||||
++ showMixedAmountOneLine balincomm ++ ")"
|
||||
-- subtract this from the amount remaining to move (ignoring cost)
|
||||
stilltomovenext = dbgamt "remaining amt to move" $
|
||||
stilltomove - amountStripPrices balincommsinglecost
|
||||
stilltomove - amountStripCost balincommsinglecost
|
||||
|
||||
-- since balance assertion amounts are required to be exact, the
|
||||
-- amounts in opening/closing transactions should be too (#941, #1137)
|
||||
|
||||
@ -103,7 +103,7 @@ module Hledger.Data.Amount (
|
||||
withInternalPrecision,
|
||||
setAmountDecimalPoint,
|
||||
withDecimalPoint,
|
||||
amountStripPrices,
|
||||
amountStripCost,
|
||||
|
||||
-- * MixedAmount
|
||||
nullmixedamt,
|
||||
@ -335,6 +335,10 @@ amountCost a@Amount{aquantity=q, aprice=mp} =
|
||||
Just (UnitPrice p@Amount{aquantity=pq}) -> p{aquantity=pq * q}
|
||||
Just (TotalPrice p@Amount{aquantity=pq}) -> p{aquantity=pq}
|
||||
|
||||
-- | Strip all prices from an Amount
|
||||
amountStripCost :: Amount -> Amount
|
||||
amountStripCost a = a{aprice=Nothing}
|
||||
|
||||
-- | Apply a function to an amount's quantity (and its total price, if it has one).
|
||||
transformAmount :: (Quantity -> Quantity) -> Amount -> Amount
|
||||
transformAmount f a@Amount{aquantity=q,aprice=p} = a{aquantity=f q, aprice=f' <$> p}
|
||||
@ -613,10 +617,6 @@ withDecimalPoint = flip setAmountDecimalPoint
|
||||
|
||||
-- Amount rendering
|
||||
|
||||
-- | Strip all prices from an Amount
|
||||
amountStripPrices :: Amount -> Amount
|
||||
amountStripPrices a = a{aprice=Nothing}
|
||||
|
||||
showAmountCostB :: Amount -> WideBuilder
|
||||
showAmountCostB amt = case aprice amt of
|
||||
Nothing -> mempty
|
||||
|
||||
@ -647,8 +647,8 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedcomm
|
||||
else return actualbal
|
||||
let
|
||||
assertedcomm = acommodity assertedcommbal
|
||||
assertedcommbalcostless = amountStripPrices assertedcommbal
|
||||
actualcommbalcostless = amountStripPrices . headDef nullamt . amountsRaw . filterMixedAmountByCommodity assertedcomm $ actualbal'
|
||||
assertedcommbalcostless = amountStripCost assertedcommbal
|
||||
actualcommbalcostless = amountStripCost . headDef nullamt . amountsRaw . filterMixedAmountByCommodity assertedcomm $ actualbal'
|
||||
|
||||
-- test the assertion. Costs are ignored currently.
|
||||
pass =
|
||||
|
||||
@ -559,7 +559,7 @@ postingAddInferredEquityPostings verbosetags equityAcct p
|
||||
conversionPostings amt = case aprice amt of
|
||||
Nothing -> []
|
||||
Just _ -> [ cp{ paccount = accountPrefix <> amtCommodity
|
||||
, pamount = mixedAmount . negate $ amountStripPrices amt
|
||||
, pamount = mixedAmount . negate $ amountStripCost amt
|
||||
}
|
||||
, cp{ paccount = accountPrefix <> costCommodity
|
||||
, pamount = mixedAmount cost
|
||||
|
||||
@ -210,7 +210,7 @@ postingToCSV p =
|
||||
map (\(a@(Amount {aquantity=q,acommodity=c})) ->
|
||||
-- commodity goes into separate column, so we suppress it, along with digit group
|
||||
-- separators and prices
|
||||
let a_ = amountStripPrices a{acommodity=""} in
|
||||
let a_ = amountStripCost a{acommodity=""} in
|
||||
let showamt = wbToText . showAmountB csvDisplay in
|
||||
let amt = showamt a_ in
|
||||
let credit = if q < 0 then showamt $ negate a_ else "" in
|
||||
|
||||
Loading…
Reference in New Issue
Block a user