tweak txn balancing error message
This commit is contained in:
parent
5476a292ad
commit
723c96834c
@ -110,7 +110,7 @@ isTransactionBalanced (Transaction {tpostings=ps}) =
|
|||||||
-- return an error message instead.
|
-- return an error message instead.
|
||||||
balanceTransaction :: Transaction -> Either String Transaction
|
balanceTransaction :: Transaction -> Either String Transaction
|
||||||
balanceTransaction t@Transaction{tpostings=ps}
|
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
|
| not $ isTransactionBalanced t' = Left $ printerr nonzerobalanceerror
|
||||||
| otherwise = Right t'
|
| otherwise = Right t'
|
||||||
where
|
where
|
||||||
@ -123,7 +123,7 @@ balanceTransaction t@Transaction{tpostings=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
|
||||||
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"
|
nonzerobalanceerror = "could not balance this transaction, amounts do not add up to zero"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user