journal: get decimal hint from default commodity

If appropriate commodity directive is missing fallback to default
commodity directive to get number representation style.
This commit is contained in:
Mykola Orliuk 2017-11-04 23:59:15 +01:00 committed by Simon Michael
parent b7dbe044b0
commit 7cbdeb40a4
2 changed files with 6 additions and 2 deletions

View File

@ -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})

View File

@ -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