From 2d90074b2e35c55209fbe00e2c1e9ba3b755c40b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 15 Feb 2020 14:02:53 -0800 Subject: [PATCH] ;csv: avoid a potential display of internal placeholder (#1192) With a multicommodity amount, the unknown account name will always be "expenses:unknown". --- hledger-lib/Hledger/Read/CsvReader.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hledger-lib/Hledger/Read/CsvReader.hs b/hledger-lib/Hledger/Read/CsvReader.hs index 899182691..a957c3a70 100644 --- a/hledger-lib/Hledger/Read/CsvReader.hs +++ b/hledger-lib/Hledger/Read/CsvReader.hs @@ -744,7 +744,7 @@ transactionFromCsvRecord sourcepos rules record = t unknownIncomeAccount = "income:unknown" -- A temporary placeholder for the unknown account name, which -- gets replaced by one of the above based on the amount's sign. - -- This is a value hopefully never chosen by users (cf #1192). XXX + -- This is a value hopefully never chosen by users (cf #1192). unknownPlaceholderAccount = "_unknown_" parsePosting' number accountFld amountFld amountInFld amountOutFld balanceFld commentFld = @@ -830,9 +830,11 @@ transactionFromCsvRecord sourcepos rules record = t improveUnknownAccountName p = if paccount p == unknownPlaceholderAccount then case isNegativeMixedAmount (pamount p) of + -- amount is negative, call it an income Just True -> p{paccount = unknownIncomeAccount} - Just False -> p{paccount = unknownExpenseAccount} - _ -> p + -- amount is positive, or in multiple commodities so we + -- can't tell, call it an expense + _ -> p{paccount = unknownExpenseAccount} else p