mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-20 02:37:12 +03:00
tweak error message
This commit is contained in:
parent
caef315906
commit
2b672c5837
@ -91,8 +91,8 @@ isLedgerTransactionBalanced (LedgerTransaction {ltpostings=ps}) =
|
||||
-- return an error message instead.
|
||||
balanceLedgerTransaction :: LedgerTransaction -> Either String LedgerTransaction
|
||||
balanceLedgerTransaction t@LedgerTransaction{ltpostings=ps}
|
||||
| length missingamounts > 1 = Left $ showerr "could not balance this entry, too many missing amounts"
|
||||
| not $ isLedgerTransactionBalanced t' = Left $ showerr "could not balance this entry, amounts do not balance"
|
||||
| length missingamounts > 1 = Left $ printerr "could not balance this entry, too many missing amounts"
|
||||
| not $ isLedgerTransactionBalanced t' = Left $ printerr "could not balance this entry, amounts do not add up to zero"
|
||||
| otherwise = Right t'
|
||||
where
|
||||
(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)}
|
||||
| otherwise = p
|
||||
where otherstotal = sum $ map pamount withamounts
|
||||
showerr s = printf "%s:\n%s" s (showLedgerTransactionUnelided t)
|
||||
printerr s = printf "%s:\n%s" s (showLedgerTransactionUnelided t)
|
||||
|
Loading…
Reference in New Issue
Block a user