tweak txn balancing error message

This commit is contained in:
Simon Michael 2010-03-09 18:34:20 +00:00
parent 5476a292ad
commit 723c96834c

View File

@ -110,7 +110,7 @@ isTransactionBalanced (Transaction {tpostings=ps}) =
-- return an error message instead.
balanceTransaction :: Transaction -> Either String Transaction
balanceTransaction t@Transaction{tpostings=ps}
| length missingamounts' > 1 = Left $ printerr "could not balance this transaction, too many missing amounts"
| length missingamounts' > 1 = Left $ printerr "could not balance this transaction (too many missing amounts)"
| not $ isTransactionBalanced t' = Left $ printerr nonzerobalanceerror
| otherwise = Right t'
where
@ -123,7 +123,7 @@ balanceTransaction t@Transaction{tpostings=ps}
balance p | isReal p && not (hasAmount p) = p{pamount = costOfMixedAmount (-otherstotal)}
| otherwise = p
where otherstotal = sum $ map pamount withamounts
printerr s = printf "%s:\n%s" s (showTransactionUnelided t)
printerr s = unlines [s, showTransactionUnelided t]
nonzerobalanceerror = "could not balance this transaction, amounts do not add up to zero"