diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 14acb5023..61be79282 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -560,10 +560,11 @@ amountwithoutpricep = do suggestedStyle <- getDefaultAmountStyle (q,prec,mdec,mgrps) <- lift $ interpretNumber numRegion suggestedStyle ambiguousRawNum mExponent -- if a default commodity has been set, apply it and its style to this amount + -- (unless it's a multiplier in an automated posting) defcs <- getDefaultCommodityAndStyle - let (c,s) = case defcs of - Just (defc,defs) -> (defc, defs{asprecision=max (asprecision defs) prec}) - Nothing -> ("", amountstyle{asprecision=prec, asdecimalpoint=mdec, asdigitgroups=mgrps}) + 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 -- For reducing code duplication. Doesn't parse anything. Has the type diff --git a/tests/journal/default-commodity.test b/tests/journal/default-commodity.test index 9c400f149..754f2bbee 100644 --- a/tests/journal/default-commodity.test +++ b/tests/journal/default-commodity.test @@ -72,29 +72,22 @@ D $1,000.0 >>>=0 -# 6. A default commodity should not disrupt automated posting amounts. -#hledger -f- print --auto -#<<< -#commodity 1,000.00 EUR -# -#D 1,000.00 EUR -# -#alias /Assets:Depot:([^:]+):(.*)/ = Assets:Depot:\1 -# -#= ^Assets:Depot -# [Assets:Depot] *-1 -# [Assets:Savings] *1 -# -#2018/01/01 * Buying Shares -# Assets:Depot:LyxorACWI:20180101 0.43346 LyxorACWI @@ 100.00 EUR -# Assets:Checking -# -#>>> -#2018/01/01 * Buying Shares -# Assets:Depot:LyxorACWI 0.43346 LyxorACWI @@ 100.00 EUR -# [Assets:Depot] -0.43346 LyxorACWI @@ 100.00 EUR -# [Assets:Savings] 0.43346 LyxorACWI @@ 100.00 EUR -# Assets:Checking -# -#>>>= +# 6. A default commodity should not affect parsing of +# automated posting multiplier amounts. +hledger -f- print --auto +<<< +D $1000. + += a + (b) *2 + +2018/1/1 + (a) €1 + +>>> +2018/01/01 + (a) €1 + (b) €2 + +>>>=