journal: don't parse + before an amount as part of the commodity (fixes #181)
This commit is contained in:
parent
3fb5e25fd4
commit
8341b4a8d3
@ -649,10 +649,16 @@ amountp' s = either (error' . show) id $ parseWithCtx nullctx amountp s
|
|||||||
mamountp' :: String -> MixedAmount
|
mamountp' :: String -> MixedAmount
|
||||||
mamountp' = mixed . amountp'
|
mamountp' = mixed . amountp'
|
||||||
|
|
||||||
|
signp :: GenParser Char JournalContext String
|
||||||
|
signp = do
|
||||||
|
sign <- optionMaybe $ oneOf "+-"
|
||||||
|
return $ case sign of Just '-' -> "-"
|
||||||
|
_ -> ""
|
||||||
|
|
||||||
leftsymbolamount :: GenParser Char JournalContext Amount
|
leftsymbolamount :: GenParser Char JournalContext Amount
|
||||||
leftsymbolamount = do
|
leftsymbolamount = do
|
||||||
sign <- optionMaybe $ string "-"
|
sign <- signp
|
||||||
let applysign = if isJust sign then negate else id
|
let applysign = if sign=="-" then negate else id
|
||||||
c <- commoditysymbol
|
c <- commoditysymbol
|
||||||
sp <- many spacenonewline
|
sp <- many spacenonewline
|
||||||
(q,prec,dec,sep,seppos) <- numberp
|
(q,prec,dec,sep,seppos) <- numberp
|
||||||
@ -748,7 +754,7 @@ fixedlotprice =
|
|||||||
-- assumed to repeat).
|
-- assumed to repeat).
|
||||||
numberp :: GenParser Char JournalContext (Quantity, Int, Char, Char, [Int])
|
numberp :: GenParser Char JournalContext (Quantity, Int, Char, Char, [Int])
|
||||||
numberp = do
|
numberp = do
|
||||||
sign <- optionMaybe $ string "-"
|
sign <- signp
|
||||||
parts <- many1 $ choice' [many1 digit, many1 $ char ',', many1 $ char '.']
|
parts <- many1 $ choice' [many1 digit, many1 $ char ',', many1 $ char '.']
|
||||||
let numeric = isNumber . headDef '_'
|
let numeric = isNumber . headDef '_'
|
||||||
(numparts, puncparts) = partition numeric parts
|
(numparts, puncparts) = partition numeric parts
|
||||||
@ -775,8 +781,7 @@ numberp = do
|
|||||||
precision = length frac
|
precision = length frac
|
||||||
int' = if null int then "0" else int
|
int' = if null int then "0" else int
|
||||||
frac' = if null frac then "0" else frac
|
frac' = if null frac then "0" else frac
|
||||||
sign' = fromMaybe "" sign
|
quantity = read $ sign++int'++"."++frac' -- this read should never fail
|
||||||
quantity = read $ sign'++int'++"."++frac' -- this read should never fail
|
|
||||||
(decimalpoint, separator) = case (decimalpoint', separator') of (Just d, Just s) -> (d,s)
|
(decimalpoint, separator) = case (decimalpoint', separator') of (Just d, Just s) -> (d,s)
|
||||||
(Just '.',Nothing) -> ('.',',')
|
(Just '.',Nothing) -> ('.',',')
|
||||||
(Just ',',Nothing) -> (',','.')
|
(Just ',',Nothing) -> (',','.')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user