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
|
isEntryBalanced = isZeroAmount . sumLedgerTransactions . etransactions
|
||||||
|
|
||||||
autofillEntry :: Entry -> Entry
|
autofillEntry :: Entry -> Entry
|
||||||
autofillEntry e@(Entry _ _ _ _ _ ts _) =
|
autofillEntry e@(Entry {etransactions=ts}) = e{etransactions=autofillTransactions ts}
|
||||||
let e' = e{etransactions=autofillTransactions ts} in
|
|
||||||
case (isEntryBalanced e') of
|
assertBalancedEntry :: Entry -> Entry
|
||||||
True -> e'
|
assertBalancedEntry e
|
||||||
False -> (error $ "transactions don't balance in " ++ show 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
|
Helper for the print command which shows cleaned up ledger file
|
||||||
|
|||||||
@ -231,7 +231,7 @@ ledgerentry = do
|
|||||||
comment <- ledgercomment
|
comment <- ledgercomment
|
||||||
restofline
|
restofline
|
||||||
transactions <- ledgertransactions
|
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 :: Parser String
|
||||||
ledgerdate = do
|
ledgerdate = do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user