From 4ec0cc474f92393c0a608c1c867aeb79acdedd60 Mon Sep 17 00:00:00 2001 From: Omari Norman Date: Sun, 26 Dec 2010 22:39:28 +0000 Subject: [PATCH] Fix postingCleared for individually-cleared postings The previous code simply looked directly to the parent transaction's status to determine whether the posting was cleared. This gave erroneous information for postings that were individually cleared even though the parent transaction was not cleared. --- hledger-lib/Hledger/Data/Posting.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hledger-lib/Hledger/Data/Posting.hs b/hledger-lib/Hledger/Data/Posting.hs index 0044d9cb4..a16d9df61 100644 --- a/hledger-lib/Hledger/Data/Posting.hs +++ b/hledger-lib/Hledger/Data/Posting.hs @@ -74,8 +74,14 @@ sumPostings = sumMixedAmountsPreservingHighestPrecision . map pamount postingDate :: Posting -> Day postingDate p = maybe nulldate tdate $ ptransaction p +-- |Is this posting cleared? If this posting was individually marked +-- as cleared, returns True. Otherwise, return the parent +-- transaction's cleared status or, if there is no parent +-- transaction, return False. postingCleared :: Posting -> Bool -postingCleared p = maybe False tstatus $ ptransaction p +postingCleared p = if pstatus p + then True + else maybe False tstatus $ ptransaction p -- | Does this posting fall within the given date span ? isPostingInDateSpan :: DateSpan -> Posting -> Bool