clarify entry balance checking and show the full entry when unbalanced
This commit is contained in:
parent
9f341b0279
commit
3138046744
@ -42,11 +42,12 @@ isEntryBalanced :: Entry -> Bool
|
||||
isEntryBalanced = isZeroAmount . sumLedgerTransactions . etransactions
|
||||
|
||||
autofillEntry :: Entry -> Entry
|
||||
autofillEntry e@(Entry _ _ _ _ _ ts _) =
|
||||
let e' = e{etransactions=autofillTransactions ts} in
|
||||
case (isEntryBalanced e') of
|
||||
True -> e'
|
||||
False -> (error $ "transactions don't balance in " ++ show e)
|
||||
autofillEntry e@(Entry {etransactions=ts}) = e{etransactions=autofillTransactions ts}
|
||||
|
||||
assertBalancedEntry :: Entry -> Entry
|
||||
assertBalancedEntry e
|
||||
| isEntryBalanced e = e
|
||||
| otherwise = error $ "transactions don't balance in:\n" ++ show e
|
||||
|
||||
{-|
|
||||
Helper for the print command which shows cleaned up ledger file
|
||||
|
||||
@ -231,7 +231,7 @@ ledgerentry = do
|
||||
comment <- ledgercomment
|
||||
restofline
|
||||
transactions <- ledgertransactions
|
||||
return $ autofillEntry $ Entry date status code description comment transactions (unlines preceding)
|
||||
return $ assertBalancedEntry $ autofillEntry $ Entry date status code description comment transactions (unlines preceding)
|
||||
|
||||
ledgerdate :: Parser String
|
||||
ledgerdate = do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user