balance: support -s with account patterns
This commit is contained in:
		
							parent
							
								
									dd202d3113
								
							
						
					
					
						commit
						a881f713c1
					
				| @ -19,6 +19,9 @@ data Account = Account { | ||||
|       abalance :: Amount | ||||
| } | ||||
| 
 | ||||
| instance Show Account where | ||||
|     show (Account a ts b) = printf "Account %s with %d transactions" a $ length ts | ||||
| 
 | ||||
| nullacct = Account "" [] nullamt | ||||
| 
 | ||||
| mkAccount :: Ledger -> AccountName -> Account | ||||
| @ -108,7 +111,7 @@ ledgerAccountTreeMatching l showsubs [] = | ||||
|     ledgerAccountTreeMatching l showsubs [".*"] | ||||
| ledgerAccountTreeMatching l showsubs acctpats =  | ||||
|     addDataToAccountNameTree l $  | ||||
|     filterAccountNameTree acctpats $  | ||||
|     filterAccountNameTree acctpats showsubs $  | ||||
|     ledgerAccountNameTree l | ||||
| 
 | ||||
| showLedgerAccounts :: Ledger -> Bool -> [String] -> String | ||||
|  | ||||
| @ -82,10 +82,11 @@ showAccountNameTree t = | ||||
|         where | ||||
|           topacct = indentAccountName 0 $ root t | ||||
| 
 | ||||
| filterAccountNameTree :: [String] -> Tree AccountName -> Tree AccountName | ||||
| filterAccountNameTree pats = | ||||
|     treefilter matchany | ||||
| filterAccountNameTree :: [String] -> Bool -> Tree AccountName -> Tree AccountName | ||||
| filterAccountNameTree pats keepsubs = | ||||
|     treefilter $ \a -> matchpats a || (keepsubs && issubofmatch a) | ||||
|     where | ||||
|       matchany a = any (match a) pats | ||||
|       matchpats a = any (match a) pats | ||||
|       match a pat = matchAccountName pat $ accountLeafName a | ||||
|       issubofmatch a = any matchpats $ parentAccountNames a | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user