From 6073b56b9e97c9897ed9225aa16f405fd0e53994 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 30 May 2013 15:16:54 -0700 Subject: [PATCH] parsing: order postings first by date, then by parse order when checking balance assertions --- hledger-lib/Hledger/Data/Journal.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 316f42c48..d02a34123 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -377,7 +377,10 @@ checkBalanceAssertionsForAccount ps | null errs = Right () | otherwise = Left $ head errs where - errs = fst $ foldl' checkBalanceAssertion ([],nullmixedamt) $ splitAssertions ps + errs = fst $ + foldl' checkBalanceAssertion ([],nullmixedamt) $ + splitAssertions $ + sortBy (comparing postingDate) ps -- Given a starting balance, accumulated errors, and a non-null sequence of -- postings to a single account with a balance assertion in the last: