lib: amultiplier -> aismultiplier

This commit is contained in:
Simon Michael 2019-01-04 18:54:52 +00:00
parent 3b0cb701ac
commit 5908414d77
5 changed files with 10 additions and 10 deletions

View File

@ -166,7 +166,7 @@ instance Num Amount where
-- | The empty simple amount. -- | The empty simple amount.
amount, nullamt :: Amount amount, nullamt :: Amount
amount = Amount{acommodity="", aquantity=0, aprice=NoPrice, astyle=amountstyle, amultiplier=False} amount = Amount{acommodity="", aquantity=0, aprice=NoPrice, astyle=amountstyle, aismultiplier=False}
nullamt = amount nullamt = amount
-- | A temporary value for parsed transactions which had no amount specified. -- | A temporary value for parsed transactions which had no amount specified.

View File

@ -47,7 +47,7 @@ import Hledger.Utils.Debug
-- 0000/01/01 -- 0000/01/01
-- ping $1.00 -- ping $1.00
-- <BLANKLINE> -- <BLANKLINE>
-- >>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "ping" ["pong" `post` amount{amultiplier=True, aquantity=3}]) nulltransaction{tpostings=["ping" `post` usd 2]} -- >>> putStr $ showTransaction $ transactionModifierToFunction (TransactionModifier "ping" ["pong" `post` amount{aismultiplier=True, aquantity=3}]) nulltransaction{tpostings=["ping" `post` usd 2]}
-- 0000/01/01 -- 0000/01/01
-- ping $2.00 -- ping $2.00
-- pong $6.00 -- pong $6.00
@ -111,7 +111,7 @@ tmPostingRuleToFunction pr =
postingRuleMultiplier :: TMPostingRule -> Maybe Quantity postingRuleMultiplier :: TMPostingRule -> Maybe Quantity
postingRuleMultiplier p = postingRuleMultiplier p =
case amounts $ pamount p of case amounts $ pamount p of
[a] | amultiplier a -> Just $ aquantity a [a] | aismultiplier a -> Just $ aquantity a
_ -> Nothing _ -> Nothing
renderPostingCommentDates :: Posting -> Posting renderPostingCommentDates :: Posting -> Posting

View File

@ -203,7 +203,7 @@ instance NFData Commodity
data Amount = Amount { data Amount = Amount {
acommodity :: CommoditySymbol, acommodity :: CommoditySymbol,
aquantity :: Quantity, aquantity :: Quantity,
amultiplier :: Bool, -- ^ kludge: a flag marking this amount and posting as a multiplier aismultiplier :: Bool, -- ^ kludge: a flag marking this amount and posting as a multiplier
-- in a TMPostingRule. In a regular Posting, should always be false. -- in a TMPostingRule. In a regular Posting, should always be false.
astyle :: AmountStyle, astyle :: AmountStyle,
aprice :: Price -- ^ the (fixed, transaction-specific) price for this amount, if any aprice :: Price -- ^ the (fixed, transaction-specific) price for this amount, if any
@ -336,7 +336,7 @@ nulltransactionmodifier = TransactionModifier{
-- | A transaction modifier transformation, which adds an extra posting -- | A transaction modifier transformation, which adds an extra posting
-- to the matched posting's transaction. -- to the matched posting's transaction.
-- Can be like a regular posting, or the amount can have the amultiplier flag set, -- Can be like a regular posting, or the amount can have the aismultiplier flag set,
-- indicating that it's a multiplier for the matched posting's amount. -- indicating that it's a multiplier for the matched posting's amount.
type TMPostingRule = Posting type TMPostingRule = Posting

View File

@ -630,7 +630,7 @@ amountwithoutpricep = do
let numRegion = (offBeforeNum, offAfterNum) let numRegion = (offBeforeNum, offAfterNum)
(q,prec,mdec,mgrps) <- lift $ interpretNumber numRegion suggestedStyle ambiguousRawNum mExponent (q,prec,mdec,mgrps) <- lift $ interpretNumber numRegion suggestedStyle ambiguousRawNum mExponent
let s = amountstyle{ascommodityside=L, ascommodityspaced=commodityspaced, asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps} let s = amountstyle{ascommodityside=L, ascommodityspaced=commodityspaced, asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps}
return $ nullamt{acommodity=c, aquantity=sign (sign2 q), amultiplier=mult, astyle=s, aprice=NoPrice} return $ nullamt{acommodity=c, aquantity=sign (sign2 q), aismultiplier=mult, astyle=s, aprice=NoPrice}
rightornosymbolamountp :: Bool -> (Decimal -> Decimal) -> JournalParser m Amount rightornosymbolamountp :: Bool -> (Decimal -> Decimal) -> JournalParser m Amount
rightornosymbolamountp mult sign = label "amount" $ do rightornosymbolamountp mult sign = label "amount" $ do
@ -646,7 +646,7 @@ amountwithoutpricep = do
suggestedStyle <- getAmountStyle c suggestedStyle <- getAmountStyle c
(q,prec,mdec,mgrps) <- lift $ interpretNumber numRegion suggestedStyle ambiguousRawNum mExponent (q,prec,mdec,mgrps) <- lift $ interpretNumber numRegion suggestedStyle ambiguousRawNum mExponent
let s = amountstyle{ascommodityside=R, ascommodityspaced=commodityspaced, asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps} let s = amountstyle{ascommodityside=R, ascommodityspaced=commodityspaced, asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps}
return $ nullamt{acommodity=c, aquantity=sign q, amultiplier=mult, astyle=s, aprice=NoPrice} return $ nullamt{acommodity=c, aquantity=sign q, aismultiplier=mult, astyle=s, aprice=NoPrice}
-- no symbol amount -- no symbol amount
Nothing -> do Nothing -> do
suggestedStyle <- getDefaultAmountStyle suggestedStyle <- getDefaultAmountStyle
@ -657,7 +657,7 @@ amountwithoutpricep = do
let (c,s) = case (mult, defcs) of let (c,s) = case (mult, defcs) of
(False, Just (defc,defs)) -> (defc, defs{asprecision=max (asprecision defs) prec}) (False, Just (defc,defs)) -> (defc, defs{asprecision=max (asprecision defs) prec})
_ -> ("", amountstyle{asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps}) _ -> ("", amountstyle{asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps})
return $ nullamt{acommodity=c, aquantity=sign q, amultiplier=mult, astyle=s, aprice=NoPrice} return $ nullamt{acommodity=c, aquantity=sign q, aismultiplier=mult, astyle=s, aprice=NoPrice}
-- For reducing code duplication. Doesn't parse anything. Has the type -- For reducing code duplication. Doesn't parse anything. Has the type
-- of a parser only in order to throw parse errors (for convenience). -- of a parser only in order to throw parse errors (for convenience).

View File

@ -314,7 +314,7 @@ tests_MultiBalanceReports = tests "MultiBalanceReports" [
(map showw aitems) `is` (map showw eitems) (map showw aitems) `is` (map showw eitems)
((\(_, b, _) -> showMixedAmountDebug b) atotal) `is` (showMixedAmountDebug etotal) -- we only check the sum of the totals ((\(_, b, _) -> showMixedAmountDebug b) atotal) `is` (showMixedAmountDebug etotal) -- we only check the sum of the totals
usd0 = usd 0 usd0 = usd 0
amount0 = Amount {acommodity="$", aquantity=0, aprice=NoPrice, astyle=AmountStyle {ascommodityside = L, ascommodityspaced = False, asprecision = 2, asdecimalpoint = Just '.', asdigitgroups = Nothing}, amultiplier=False} amount0 = Amount {acommodity="$", aquantity=0, aprice=NoPrice, astyle=AmountStyle {ascommodityside = L, ascommodityspaced = False, asprecision = 2, asdecimalpoint = Just '.', asdigitgroups = Nothing}, aismultiplier=False}
in in
tests "multiBalanceReport" [ tests "multiBalanceReport" [
test "null journal" $ test "null journal" $