From 4ceda8f985bc7fbd222aca7be8ea55fa95604ae8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 14 Aug 2016 14:50:03 -0700 Subject: [PATCH] timeclock: fix order of transaction indexes #394 Timeclock transaction ids now count up rather than down. Also, remove old code for appending timeclock transactions to journal transactions, a holdover from the days when both were allowed in one file. --- hledger-lib/Hledger/Read/TimeclockReader.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Read/TimeclockReader.hs b/hledger-lib/Hledger/Read/TimeclockReader.hs index 7e101d268..9ec7701f7 100644 --- a/hledger-lib/Hledger/Read/TimeclockReader.hs +++ b/hledger-lib/Hledger/Read/TimeclockReader.hs @@ -90,12 +90,15 @@ parse _ = parseAndFinaliseJournal timeclockfilep timeclockfilep :: ErroringJournalParser ParsedJournal timeclockfilep = do many timeclockitemp eof - j@Journal{jtxns=ts, jparsetimeclockentries=es} <- get + j@Journal{jparsetimeclockentries=es} <- get -- Convert timeclock entries in this journal to transactions, closing any unfinished sessions. -- Doing this here rather than in journalFinalise means timeclock sessions can't span file boundaries, -- but it simplifies code above. now <- liftIO getCurrentLocalTime - let j' = j{jtxns = ts ++ timeclockEntriesToTransactions now (reverse es), jparsetimeclockentries = []} + -- entries have been parsed in reverse order. timeclockEntriesToTransactions + -- expects them to be in normal order, then we must reverse again since + -- journalFinalise expects them in reverse order + let j' = j{jtxns = reverse $ timeclockEntriesToTransactions now $ reverse es, jparsetimeclockentries = []} return j' where -- As all ledger line types can be distinguished by the first