fix: csv: report correct CSV line number in errors

Some errors in CSV conversion, such as a failing balance assertion,
were always being reported as line 2.
Reported by Lawrence Wu.
This commit is contained in:
Simon Michael 2021-09-01 06:58:01 -10:00
parent 8274da81fc
commit 5485990cac

View File

@ -740,7 +740,7 @@ readJournalFromCsv mrulesfile csvfile csvdata =
-- mfieldnames = lastMay headerlines
let
-- convert CSV records to transactions
-- convert CSV records to transactions, saving the CSV line numbers for error positions
txns = dbg7 "csv txns" $ snd $ mapAccumL
(\pos r ->
let
@ -748,7 +748,7 @@ readJournalFromCsv mrulesfile csvfile csvdata =
line' = (mkPos . (+1) . unPos) line
pos' = SourcePos name line' col
in
(pos, transactionFromCsvRecord pos' rules r)
(pos', transactionFromCsvRecord pos rules r)
)
(initialPos parsecfilename) records