preserve transaction order regardless of where the blank one is
This commit is contained in:
		
							parent
							
								
									11c96dd042
								
							
						
					
					
						commit
						573fac2755
					
				| @ -21,13 +21,14 @@ elideRight width s = | |||||||
| 
 | 
 | ||||||
| autofillTransactions :: [LedgerTransaction] -> [LedgerTransaction] | autofillTransactions :: [LedgerTransaction] -> [LedgerTransaction] | ||||||
| autofillTransactions ts = | autofillTransactions ts = | ||||||
|     let (ns, as) = partition isNormal ts |     case (length blanks) of | ||||||
|             where isNormal t = (symbol $ currency $ tamount t) /= "AUTO" in |       0 -> ts | ||||||
|     case (length as) of |       1 -> map balance ts | ||||||
|       0 -> ns |  | ||||||
|       1 -> ns ++ [balanceTransaction $ head as] |  | ||||||
|           where balanceTransaction t = t{tamount = -(sumLedgerTransactions ns)} |  | ||||||
|       otherwise -> error "too many blank transactions in this entry" |       otherwise -> error "too many blank transactions in this entry" | ||||||
|  |     where  | ||||||
|  |       (normals, blanks) = partition isnormal ts | ||||||
|  |       balance t = if isnormal t then t else t{tamount = -(sumLedgerTransactions normals)} | ||||||
|  |       isnormal t = (symbol $ currency $ tamount t) /= "AUTO" | ||||||
| 
 | 
 | ||||||
| sumLedgerTransactions :: [LedgerTransaction] -> Amount | sumLedgerTransactions :: [LedgerTransaction] -> Amount | ||||||
| sumLedgerTransactions = sum . map tamount | sumLedgerTransactions = sum . map tamount | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user