parsing: amt queries use the = operator by default

This commit is contained in:
Simon Michael 2013-09-09 11:57:25 -07:00
parent ec9323688f
commit 73230838c5
3 changed files with 6 additions and 3 deletions

View File

@ -961,7 +961,7 @@ A query term can be any of the following:
- `status:1` or `status:0` - match cleared/uncleared transactions
- `real:1` or `real:0` - match real/virtual-ness
- `empty:1` or `empty:0` - match if amount is/is not zero
- `amt:<N`, `amt:=N`, `amt:>N` - match postings with a single-commodity amount less than, greater than or equal to N. (Multi-commodity amounts are always matched.)
- `amt:N` or `amt:=N`, `amt:<N`, `amt:>N` - match postings with a single-commodity amount equal to, less than, or greater than N. (Multi-commodity amounts are always matched.)
- `not:` before any of the above negates the match
<!--

View File

@ -6,6 +6,7 @@ title: hledger news
## unreleased
- parsing: amt queries use the = operator by default, eg amt:50 finds amounts equal to 50
- don't break when there are non-ascii characters in CSV files
- csv: add the `include` directive, useful for factoring out common rules used with multiple CSV files
- balancesheet: don't bother showing equity, it won't be useful for most of us

View File

@ -251,14 +251,16 @@ parseAmountTest s =
'<':s' -> (LT, readDef err s')
'=':s' -> (EQ, readDef err s')
'>':s' -> (GT, readDef err s')
_ -> err
where err = error' $ "could not parse as operator followed by numeric quantity: "++s
s' -> (EQ, readDef err s')
where
err = error' $ "could not parse as '=', '<', or '>' (optional) followed by a numeric quantity: " ++ s
tests_parseAmountTest = [
"parseAmountTest" ~: do
let s `gives` r = parseAmountTest s `is` r
"<0" `gives` (LT,0)
"=0.23" `gives` (EQ,0.23)
"0.23" `gives` (EQ,0.23)
">10000.10" `gives` (GT,10000.1)
]