lib, cli: -U/--uncleared no longer matches pending things (#564)

Also begin using "marked"/"unmarked" terminology where it's helpful.
This commit is contained in:
Simon Michael 2017-06-10 10:24:10 -07:00
parent c5d63f03ce
commit 8b073014e4
6 changed files with 11 additions and 17 deletions

View File

@ -144,7 +144,7 @@ m4_define({{_reportingoptions_}}, {{
: include only pending postings/txns
`-U --uncleared`
: include only uncleared (and pending) postings/txns
: include only unmarked postings/txns
`-R --real`
: include only non-virtual postings

View File

@ -79,7 +79,7 @@ data Query = Any -- ^ always match
| Acct Regexp -- ^ match postings whose account matches this regexp
| Date DateSpan -- ^ match if primary date in this date span
| Date2 DateSpan -- ^ match if secondary date in this date span
| Status ClearedStatus -- ^ match txns/postings with this cleared status (Status Uncleared matches all states except cleared)
| Status ClearedStatus -- ^ match txns/postings with this status
| Real Bool -- ^ match if "realness" (involves a real non-virtual account ?) has this value
| Amt OrdPlus Quantity -- ^ match if the amount's numeric quantity is less than/greater than/equal to/unsignedly equal to some value
| Sym Regexp -- ^ match if the entire commodity symbol is matched by this regexp
@ -673,7 +673,6 @@ matchesPosting (Acct r) p = matchesPosting p || matchesPosting (originalPosting
where matchesPosting p = regexMatchesCI r $ T.unpack $ paccount p -- XXX pack
matchesPosting (Date span) p = span `spanContainsDate` postingDate p
matchesPosting (Date2 span) p = span `spanContainsDate` postingDate2 p
matchesPosting (Status Uncleared) p = postingStatus p /= Cleared
matchesPosting (Status s) p = postingStatus p == s
matchesPosting (Real v) p = v == isReal p
matchesPosting q@(Depth _) Posting{paccount=a} = q `matchesAccount` a
@ -694,7 +693,7 @@ tests_matchesPosting = [
(Status Cleared) `matchesPosting` nullposting{pstatus=Cleared}
assertBool "negative match on cleared posting status" $
not $ (Not $ Status Cleared) `matchesPosting` nullposting{pstatus=Cleared}
assertBool "positive match on unclered posting status" $
assertBool "positive match on uncleared posting status" $
(Status Uncleared) `matchesPosting` nullposting{pstatus=Uncleared}
assertBool "negative match on unclered posting status" $
not $ (Not $ Status Uncleared) `matchesPosting` nullposting{pstatus=Uncleared}
@ -731,7 +730,6 @@ matchesTransaction (Desc r) t = regexMatchesCI r $ T.unpack $ tdescription t
matchesTransaction q@(Acct _) t = any (q `matchesPosting`) $ tpostings t
matchesTransaction (Date span) t = spanContainsDate span $ tdate t
matchesTransaction (Date2 span) t = spanContainsDate span $ transactionDate2 t
matchesTransaction (Status Uncleared) t = tstatus t /= Cleared
matchesTransaction (Status s) t = tstatus t == s
matchesTransaction (Real v) t = v == hasRealPostings t
matchesTransaction q@(Amt _ _) t = any (q `matchesPosting`) $ tpostings t

View File

@ -141,7 +141,7 @@ reportflags = [
,flagNone ["cleared","C"] (setboolopt "cleared") "include only cleared postings/txns"
,flagNone ["pending"] (setboolopt "pending") "include only pending postings/txns"
,flagNone ["uncleared","U"] (setboolopt "uncleared") "include only uncleared (and pending) postings/txns"
,flagNone ["uncleared","U"] (setboolopt "uncleared") "include only unmarked postings/txns"
,flagNone ["real","R"] (setboolopt "real") "include only non-virtual postings"
,flagReq ["depth"] (\s opts -> Right $ setopt "depth" s opts) "N" "hide accounts/postings deeper than N"
,flagNone ["empty","E"] (setboolopt "empty") "show items with zero amount, normally hidden"

View File

@ -178,6 +178,9 @@ or [balance assertions](manual.html#assertions-and-ordering).
With hledger you can also specify start and/or end dates with a query argument,
date:START-END, which probably doesn't combine perfectly with the options.
- in hledger version 1.3 onward, -U/--uncleared does not match pending things.
(#564)
### Future ?
There is a [ledger4](https://github.com/ledger/ledger4) repo on

View File

@ -0,0 +1 @@
../../examples/status.journal

View File

@ -53,10 +53,6 @@ hledger -fstatus.journal print --uncleared
(a) 1
(b) 1
2017/01/02 ! pending
(a) 1
! (b) 1
>>>=0
# 6. only one of these flags (the last) takes effect
@ -69,8 +65,8 @@ hledger -fstatus.journal register --uncleared --pending --cleared
# 7. these flags work with other commands
hledger -fstatus.journal balance -N --uncleared
>>>
2 a
2 b
1 a
1 b
>>>=0
## matching with status: query
@ -93,16 +89,12 @@ hledger -fstatus.journal print status:!
>>>=0
# 10. status: matches everything but *
# 10. status: matches unmarked only
hledger -fstatus.journal print status:
>>>
2017/01/01 uncleared
(a) 1
(b) 1
2017/01/02 ! pending
(a) 1
! (b) 1
>>>=0