lib: clean up status functional tests, document ClearedStatus (#564)
This commit is contained in:
		
							parent
							
								
									a14317db3c
								
							
						
					
					
						commit
						c5d63f03ce
					
				
							
								
								
									
										11
									
								
								examples/status.journal
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								examples/status.journal
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| 1/1 uncleared | ||||
|   (a)  1 | ||||
|   (b)  1 | ||||
| 
 | ||||
| 1/2 ! pending | ||||
|   (a)  1 | ||||
|   ! (b)  1 | ||||
| 
 | ||||
| 1/3 * cleared | ||||
|   (a)  1 | ||||
|   * (b)  1 | ||||
| @ -180,6 +180,12 @@ type TagName = Text | ||||
| type TagValue = Text | ||||
| type Tag = (TagName, TagValue)  -- ^ A tag name and (possibly empty) value. | ||||
| 
 | ||||
| -- | The status of a transaction or posting, recorded with a status mark | ||||
| -- (nothing, !, or *). What these mean is ultimately user defined. | ||||
| -- Calling the unmarked state "Uncleared" creates some ambiguity  | ||||
| -- but is traditional in Ledger/hledger so we keep it (#564). | ||||
| -- Calling the type "Cleared..." might also be confusing, just Status | ||||
| -- would be better but that's currently used as a Query constructor. | ||||
| data ClearedStatus = Uncleared | Pending | Cleared | ||||
|   deriving (Eq,Ord,Typeable,Data,Generic) | ||||
| 
 | ||||
|  | ||||
| @ -1,80 +1,108 @@ | ||||
| # 1. the status field can contain nothing, | ||||
| hledger -f- print | ||||
| <<< | ||||
| 2015/1/1 x | ||||
|   (a)  1 | ||||
| ## parsing | ||||
| 
 | ||||
| # 1. transactions and postings have status marks which are nothing, ! or * | ||||
| hledger -fstatus.journal print | ||||
| >>> | ||||
| 2015/01/01 x | ||||
| 2017/01/01 uncleared | ||||
|     (a)               1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 2. or ! | ||||
| hledger -f- print | ||||
| <<< | ||||
| 2015/1/1 ! x | ||||
|   (a)  1 | ||||
| >>> | ||||
| 2015/01/01 ! x | ||||
|     (a)               1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 3. or * | ||||
| hledger -f- print | ||||
| <<< | ||||
| 2015/1/1 * x | ||||
|   (a)  1 | ||||
| >>> | ||||
| 2015/01/01 * x | ||||
|     (a)               1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 4. --cleared matches * only | ||||
| hledger -f- print --cleared | ||||
| <<< | ||||
| 2015/1/1 x | ||||
|   (a)  1 | ||||
| 2015/1/1 ! x | ||||
|   (b)  1 | ||||
| 2015/1/1 * x | ||||
|   (c)  1 | ||||
| >>> | ||||
| 2015/01/01 * x | ||||
|     (c)               1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 5. --pending matches ! only | ||||
| hledger -f- print --pending | ||||
| <<< | ||||
| 2015/1/1 x | ||||
|   (a)  1 | ||||
| 2015/1/1 ! x | ||||
|   (b)  1 | ||||
| 2015/1/1 * x | ||||
|   (c)  1 | ||||
| >>> | ||||
| 2015/01/01 ! x | ||||
|     (b)               1 | ||||
| 
 | ||||
| 2017/01/02 ! pending | ||||
|     (a)               1 | ||||
|     ! (b)             1 | ||||
| 
 | ||||
| 2017/01/03 * cleared | ||||
|     (a)               1 | ||||
|     * (b)             1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 6. --uncleared matches all except * | ||||
| hledger -f- print --uncleared | ||||
| # 2. other characters will be considered part of the description | ||||
| hledger -f- print desc:% | ||||
| <<< | ||||
| 2015/1/1 x | ||||
|   (a)  1 | ||||
| 2015/1/1 ! x | ||||
|   (b)  1 | ||||
| 2015/1/1 * x | ||||
|   (c)  1 | ||||
| 2017/01/01 %  | ||||
| >>> | ||||
| 2015/01/01 x | ||||
|     (a)               1 | ||||
| 
 | ||||
| 2015/01/01 ! x | ||||
|     (b)               1 | ||||
| 2017/01/01 % | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| ## matching with flags | ||||
| 
 | ||||
| # 3. --cleared matches * only | ||||
| hledger -fstatus.journal print --cleared | ||||
| >>> | ||||
| 2017/01/03 * cleared | ||||
|     (a)               1 | ||||
|     * (b)             1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 4. --pending matches ! only | ||||
| hledger -fstatus.journal print --pending | ||||
| >>> | ||||
| 2017/01/02 ! pending | ||||
|     (a)               1 | ||||
|     ! (b)             1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 5. --uncleared matches everything but * | ||||
| hledger -fstatus.journal print --uncleared | ||||
| >>> | ||||
| 2017/01/01 uncleared | ||||
|     (a)               1 | ||||
|     (b)               1 | ||||
| 
 | ||||
| 2017/01/02 ! pending | ||||
|     (a)               1 | ||||
|     ! (b)             1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 6. only one of these flags (the last) takes effect | ||||
| hledger -fstatus.journal register --uncleared --pending --cleared | ||||
| >>> | ||||
| 2017/01/03 cleared              (a)                              1             1 | ||||
|                                 (b)                              1             2 | ||||
| >>>= 0 | ||||
| 
 | ||||
| # 7. these flags work with other commands | ||||
| hledger -fstatus.journal balance -N --uncleared | ||||
| >>> | ||||
|                    2  a | ||||
|                    2  b | ||||
| >>>=0 | ||||
| 
 | ||||
| ## matching with status: query | ||||
| 
 | ||||
| # 8. status:* matches * only | ||||
| hledger -fstatus.journal print status:* | ||||
| >>> | ||||
| 2017/01/03 * cleared | ||||
|     (a)               1 | ||||
|     * (b)             1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 9. status:! matches ! only | ||||
| hledger -fstatus.journal print status:! | ||||
| >>> | ||||
| 2017/01/02 ! pending | ||||
|     (a)               1 | ||||
|     ! (b)             1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 10. status: matches everything but * | ||||
| hledger -fstatus.journal print status: | ||||
| >>> | ||||
| 2017/01/01 uncleared | ||||
|     (a)               1 | ||||
|     (b)               1 | ||||
| 
 | ||||
| 2017/01/02 ! pending | ||||
|     (a)               1 | ||||
|     ! (b)             1 | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
|  | ||||
| @ -1,76 +0,0 @@ | ||||
| # filtering by transaction status | ||||
| 
 | ||||
| # 1. with --cleared, print shows cleared transactions only | ||||
| hledger -f- print --cleared | ||||
| <<< | ||||
| 2010/1/1 x | ||||
|   a  1 | ||||
|   b | ||||
| 
 | ||||
| 2010/1/2 * x | ||||
|   a  1 | ||||
|   b | ||||
| 
 | ||||
| 2010/1/3 * | ||||
|   a  1 | ||||
|   b | ||||
| >>> | ||||
| 2010/01/02 * x | ||||
|     a               1 | ||||
|     b | ||||
| 
 | ||||
| 2010/01/03 * | ||||
|     a               1 | ||||
|     b | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 2. with --uncleared, shows uncleared transactions only | ||||
| hledger -f- print --uncleared | ||||
| <<< | ||||
| 2010/1/1 x | ||||
|   a  1 | ||||
|   b | ||||
| 
 | ||||
| 2010/1/2 * x | ||||
|   a  1 | ||||
|   b | ||||
| 
 | ||||
| 2010/1/3 * | ||||
|   a  1 | ||||
|   b | ||||
| >>> | ||||
| 2010/01/01 x | ||||
|     a               1 | ||||
|     b | ||||
| 
 | ||||
| >>>=0 | ||||
| 
 | ||||
| # 3. can also have per-posting cleared status | ||||
| hledger -f- register --cleared | ||||
| <<< | ||||
| 2012/1/1 | ||||
|   a  1 | ||||
|   *b  2 | ||||
|   * c  4 | ||||
|   d | ||||
| >>> | ||||
| 2012/01/01                      b                                2             2 | ||||
|                                 c                                4             6 | ||||
| >>>= 0 | ||||
| 
 | ||||
| 
 | ||||
| # 4. also works with balance as shown, same as ledger. Hmm. | ||||
| hledger -f- balance --uncleared | ||||
| <<< | ||||
| 2012/1/1 | ||||
|   a  1 | ||||
|   *b  2 | ||||
|   d | ||||
| 
 | ||||
| >>> | ||||
|                    1  a | ||||
|                   -3  d | ||||
| -------------------- | ||||
|                   -2 | ||||
| >>>=0 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user