mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
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.
|
||||
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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user