test and fix display of zero-balance leaves (fixes #170)
This commit is contained in:
		
							parent
							
								
									cf254b0da3
								
							
						
					
					
						commit
						4dc61e76bf
					
				@ -125,10 +125,11 @@ pruneAccounts :: (Account -> Bool) -> Account -> Maybe Account
 | 
				
			|||||||
pruneAccounts p = headMay . prune
 | 
					pruneAccounts p = headMay . prune
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
    prune a
 | 
					    prune a
 | 
				
			||||||
      | null prunedsubs = if p a then [] else [a]
 | 
					      | null prunedsubs = if p a then [] else [a']
 | 
				
			||||||
      | otherwise       = [a{asubs=prunedsubs}]
 | 
					      | otherwise       = [a']
 | 
				
			||||||
      where
 | 
					      where
 | 
				
			||||||
        prunedsubs = concatMap prune $ asubs a
 | 
					        prunedsubs = concatMap prune $ asubs a
 | 
				
			||||||
 | 
					        a' = a{asubs=prunedsubs}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Flatten an account tree into a list, which is sometimes
 | 
					-- | Flatten an account tree into a list, which is sometimes
 | 
				
			||||||
-- convenient. Note since accounts link to their parents/subs, the
 | 
					-- convenient. Note since accounts link to their parents/subs, the
 | 
				
			||||||
 | 
				
			|||||||
@ -46,3 +46,15 @@ hledgerdev -f - balance --no-total
 | 
				
			|||||||
>>>2
 | 
					>>>2
 | 
				
			||||||
>>>=0
 | 
					>>>=0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# 5. Zero-balance leaves should also be hidden by default.
 | 
				
			||||||
 | 
					hledgerdev -f - balance --no-total
 | 
				
			||||||
 | 
					<<<
 | 
				
			||||||
 | 
					1/1
 | 
				
			||||||
 | 
					 (a)          1
 | 
				
			||||||
 | 
					 (a:aa)       1
 | 
				
			||||||
 | 
					 (a:aa)      -1
 | 
				
			||||||
 | 
					 (a:aa:aaa)   1
 | 
				
			||||||
 | 
					 (a:aa:aaa)  -1
 | 
				
			||||||
 | 
					>>>
 | 
				
			||||||
 | 
					                   1  a
 | 
				
			||||||
 | 
					>>>=0
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user