tweak error message

This commit is contained in:
Simon Michael 2009-04-08 03:10:15 +00:00
parent caef315906
commit 2b672c5837

View File

@ -91,8 +91,8 @@ isLedgerTransactionBalanced (LedgerTransaction {ltpostings=ps}) =
-- return an error message instead. -- return an error message instead.
balanceLedgerTransaction :: LedgerTransaction -> Either String LedgerTransaction balanceLedgerTransaction :: LedgerTransaction -> Either String LedgerTransaction
balanceLedgerTransaction t@LedgerTransaction{ltpostings=ps} balanceLedgerTransaction t@LedgerTransaction{ltpostings=ps}
| length missingamounts > 1 = Left $ showerr "could not balance this entry, too many missing amounts" | length missingamounts > 1 = Left $ printerr "could not balance this entry, too many missing amounts"
| not $ isLedgerTransactionBalanced t' = Left $ showerr "could not balance this entry, amounts do not balance" | not $ isLedgerTransactionBalanced t' = Left $ printerr "could not balance this entry, amounts do not add up to zero"
| otherwise = Right t' | otherwise = Right t'
where where
(withamounts, missingamounts) = partition hasAmount $ filter isReal ps (withamounts, missingamounts) = partition hasAmount $ filter isReal ps
@ -103,4 +103,4 @@ balanceLedgerTransaction t@LedgerTransaction{ltpostings=ps}
balance p | isReal p && not (hasAmount p) = p{pamount = costOfMixedAmount (-otherstotal)} balance p | isReal p && not (hasAmount p) = p{pamount = costOfMixedAmount (-otherstotal)}
| otherwise = p | otherwise = p
where otherstotal = sum $ map pamount withamounts where otherstotal = sum $ map pamount withamounts
showerr s = printf "%s:\n%s" s (showLedgerTransactionUnelided t) printerr s = printf "%s:\n%s" s (showLedgerTransactionUnelided t)