diff --git a/hledger-lib/Hledger/Read.hs b/hledger-lib/Hledger/Read.hs index 0c6cd8fba..48912f8ea 100644 --- a/hledger-lib/Hledger/Read.hs +++ b/hledger-lib/Hledger/Read.hs @@ -167,6 +167,7 @@ import Hledger.Utils import Prelude hiding (getContents, writeFile) import Hledger.Data.JournalChecks (journalStrictChecks) import Text.Printf (printf) +import Hledger.Data.Journal (journalNumberTransactions) --- ** doctest setup -- $setup @@ -353,7 +354,10 @@ readJournalFiles iopts@InputOpts{strict_, new_, new_save_} prefixedfiles = do readJournalFilesAndLatestDates :: InputOpts -> [PrefixedFilePath] -> ExceptT String IO (Journal, [LatestDatesForFile]) readJournalFilesAndLatestDates iopts pfs = do (js, lastdates) <- unzip <$> mapM (readJournalFileAndLatestDates iopts) pfs - return (maybe def sconcat $ nonEmpty js, catMaybes lastdates) + -- Also renumber the concatenated transactions. In 1.51 and before, tindex restarted from 1 in each file. + -- Now we ensure tindex is unique across all files. This helps aregister preserve txns' parse order, + -- and with luck won't cause problems for anyone. + return (journalNumberTransactions $ maybe def sconcat $ nonEmpty js, catMaybes lastdates) -- | An easy version of 'readJournal' which assumes default options, and fails in the IO monad. readJournal' :: Handle -> IO Journal diff --git a/hledger/test/aregister.test b/hledger/test/aregister.test index 88882e6cc..de2c57d82 100644 --- a/hledger/test/aregister.test +++ b/hledger/test/aregister.test @@ -46,6 +46,7 @@ Transactions in assets:checking and subaccounts (matching query): # matching postings) then by parse order. (#1642) # Also, make sure to use the posting date of matching transactions, if it # differs from the transaction date. +# Also, parse order respects the order of -f options on command line (not tested here). < ~ 2021-01-03 sixth, because forecast transactions come after normal transactions (a) 6