;csv: avoid a potential display of internal placeholder (#1192)

With a multicommodity amount, the unknown account name will always be
"expenses:unknown".
This commit is contained in:
Simon Michael 2020-02-15 14:02:53 -08:00
parent 017d3355f8
commit 2d90074b2e

View File

@ -744,7 +744,7 @@ transactionFromCsvRecord sourcepos rules record = t
unknownIncomeAccount = "income:unknown" unknownIncomeAccount = "income:unknown"
-- A temporary placeholder for the unknown account name, which -- A temporary placeholder for the unknown account name, which
-- gets replaced by one of the above based on the amount's sign. -- 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_" unknownPlaceholderAccount = "_unknown_"
parsePosting' number accountFld amountFld amountInFld amountOutFld balanceFld commentFld = parsePosting' number accountFld amountFld amountInFld amountOutFld balanceFld commentFld =
@ -830,9 +830,11 @@ transactionFromCsvRecord sourcepos rules record = t
improveUnknownAccountName p = improveUnknownAccountName p =
if paccount p == unknownPlaceholderAccount if paccount p == unknownPlaceholderAccount
then case isNegativeMixedAmount (pamount p) of then case isNegativeMixedAmount (pamount p) of
-- amount is negative, call it an income
Just True -> p{paccount = unknownIncomeAccount} Just True -> p{paccount = unknownIncomeAccount}
Just False -> p{paccount = unknownExpenseAccount} -- amount is positive, or in multiple commodities so we
_ -> p -- can't tell, call it an expense
_ -> p{paccount = unknownExpenseAccount}
else p else p