mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 21:02:04 +03:00
imp: journal: ignore commodity subdirectives other than format
This commit is contained in:
parent
a454b47ad9
commit
bf6a2a7ccf
@ -79,7 +79,7 @@ import Control.Monad.Except (ExceptT(..), runExceptT)
|
||||
import Control.Monad.State.Strict (evalStateT,get,modify',put)
|
||||
import Control.Monad.Trans.Class (lift)
|
||||
import Data.Char (toLower)
|
||||
import Data.Either (isRight)
|
||||
import Data.Either (isRight, lefts)
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Text (Text)
|
||||
import Data.String
|
||||
@ -489,7 +489,9 @@ commoditydirectivemultilinep = do
|
||||
lift skipNonNewlineSpaces1
|
||||
sym <- lift commoditysymbolp
|
||||
_ <- lift followingcommentp
|
||||
mfmt <- lastMay <$> many (indented $ formatdirectivep sym)
|
||||
-- read all subdirectives, saving format subdirectives as Lefts
|
||||
subdirectives <- many $ indented (eitherP (formatdirectivep sym) (lift restofline))
|
||||
let mfmt = lastMay $ lefts subdirectives
|
||||
let comm = Commodity{csymbol=sym, cformat=mfmt}
|
||||
modify' (\j -> j{jcommodities=M.insert sym comm $ jcommodities j})
|
||||
where
|
||||
|
@ -2186,6 +2186,8 @@ commodity INR
|
||||
format INR 1,00,00,000.00
|
||||
```
|
||||
|
||||
Any indented subdirectives other than `format` are currently ignored.
|
||||
|
||||
Remember that if the commodity symbol contains spaces, numbers, or
|
||||
punctuation, it must be enclosed in double quotes (cf [Commodity](#commodity)).
|
||||
|
||||
|
@ -64,10 +64,13 @@ $ hledger -f - commodities
|
||||
>2 /unexpected 'f'/
|
||||
>=1
|
||||
|
||||
# 10 it rejects unrecognised subdirectives (should be permissive like account, TODO)
|
||||
# 10 it ignores unrecognised subdirectives
|
||||
<
|
||||
commodity A
|
||||
note a a
|
||||
commodity USD
|
||||
note American Dollars
|
||||
format USD 1,000.00
|
||||
nomarket
|
||||
alias DOLLARS
|
||||
default
|
||||
$ hledger -f - commodities
|
||||
>2 /expecting "format"/
|
||||
>=1
|
||||
USD
|
||||
|
Loading…
Reference in New Issue
Block a user