diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index be2899255..5ce37c94c 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -203,10 +203,10 @@ instance NFData Commodity data Amount = Amount { acommodity :: CommoditySymbol, aquantity :: Quantity, - aprice :: Price, -- ^ the (fixed) price for this amount, if any - astyle :: AmountStyle, - amultiplier :: Bool -- ^ kludge: a flag marking this amount and posting as a multiplier + amultiplier :: Bool, -- ^ kludge: a flag marking this amount and posting as a multiplier -- in a TMPostingRule. In a regular Posting, should always be false. + astyle :: AmountStyle, + aprice :: Price -- ^ the (fixed, transaction-specific) price for this amount, if any } deriving (Eq,Ord,Typeable,Data,Generic,Show) instance NFData Amount diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 20f026fe3..660094f50 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -630,7 +630,7 @@ amountwithoutpricep = do let numRegion = (offBeforeNum, offAfterNum) (q,prec,mdec,mgrps) <- lift $ interpretNumber numRegion suggestedStyle ambiguousRawNum mExponent let s = amountstyle{ascommodityside=L, ascommodityspaced=commodityspaced, asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps} - return $ Amount c (sign (sign2 q)) NoPrice s mult + return $ nullamt{acommodity=c, aquantity=sign (sign2 q), amultiplier=mult, astyle=s, aprice=NoPrice} rightornosymbolamountp :: Bool -> (Decimal -> Decimal) -> JournalParser m Amount rightornosymbolamountp mult sign = label "amount" $ do @@ -646,7 +646,7 @@ amountwithoutpricep = do suggestedStyle <- getAmountStyle c (q,prec,mdec,mgrps) <- lift $ interpretNumber numRegion suggestedStyle ambiguousRawNum mExponent let s = amountstyle{ascommodityside=R, ascommodityspaced=commodityspaced, asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps} - return $ Amount c (sign q) NoPrice s mult + return $ nullamt{acommodity=c, aquantity=sign q, amultiplier=mult, astyle=s, aprice=NoPrice} -- no symbol amount Nothing -> do suggestedStyle <- getDefaultAmountStyle @@ -657,7 +657,7 @@ amountwithoutpricep = do let (c,s) = case (mult, defcs) of (False, Just (defc,defs)) -> (defc, defs{asprecision=max (asprecision defs) prec}) _ -> ("", amountstyle{asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps}) - return $ Amount c (sign q) NoPrice s mult + return $ nullamt{acommodity=c, aquantity=sign q, amultiplier=mult, astyle=s, aprice=NoPrice} -- For reducing code duplication. Doesn't parse anything. Has the type -- of a parser only in order to throw parse errors (for convenience).