diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 1a540ca0b..01f0b0c75 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -150,7 +150,11 @@ getDefaultDecimalHint :: JournalParser m (Maybe Char) getDefaultDecimalHint = maybe Nothing (asdecimalpoint . snd) <$> getDefaultCommodityAndStyle getDecimalHint :: CommoditySymbol -> JournalParser m (Maybe Char) -getDecimalHint commodity = maybe Nothing asdecimalpoint . maybe Nothing cformat . M.lookup commodity . jcommodities <$> get +getDecimalHint commodity = do + specificStyle <- maybe Nothing cformat . M.lookup commodity . jcommodities <$> get + defaultStyle <- fmap snd <$> getDefaultCommodityAndStyle + let effectiveStyle = listToMaybe $ catMaybes [specificStyle, defaultStyle] + return $ maybe Nothing asdecimalpoint effectiveStyle pushAccount :: AccountName -> JournalParser m () pushAccount acct = modify' (\j -> j{jaccounts = acct : jaccounts j}) diff --git a/tests/journal/numbers.test b/tests/journal/numbers.test index 4b49886c2..005e25d68 100644 --- a/tests/journal/numbers.test +++ b/tests/journal/numbers.test @@ -50,7 +50,7 @@ D 1,000.00 EUR 2017/1/1 a 1,000 - b -1,000.00 + b -1,000 EUR >>> 1,000.00 EUR a -1,000.00 EUR b