From bb67c09aeae287bbbb949976fd7227664824deba Mon Sep 17 00:00:00 2001 From: thedon Date: Sun, 18 Aug 2024 22:50:10 +0000 Subject: [PATCH] [FIX] account_statement_import_sheet_parser: prevent failing when bank-balance import Problem: When the import expects to see the Amount field when the amounts are split into Credit/Debit. Attempting to import throws the error "Bad file/mapping: 'Amount' is not in list". this fix sets the relevant fields to False depending on the type of import selected by the user. --- .../models/account_statement_import_sheet_parser.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py b/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py index e57cdad503..c4f2b35721 100644 --- a/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py +++ b/account_statement_import_sheet_file/models/account_statement_import_sheet_parser.py @@ -189,6 +189,18 @@ def _parse_lines(self, mapping, data_file, currency_code): [next(csv_or_xlsx) for _i in range(header_line)] header = [value.strip() for value in next(csv_or_xlsx)] + if mapping.amount_type == "simple_value": + mapping.debit_credit_column = False + mapping.amount_debit_column = False + mapping.amount_debit_column = False + elif mapping.amount_type == "absolute_value": + mapping.amount_column = False + mapping.amount_debit_column = False + mapping.amount_debit_column = False + elif mapping.amount_type == "distinct_credit_debit": + mapping.amount_column = False + mapping.debit_credit_column = False + # NOTE no seria necesario debit_column y credit_column ya que tenemos los # respectivos campos related for column_name in self._get_column_names():