From d87da25417d5780e7f18fe2507950d69fbb011de Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Mon, 18 May 2026 13:03:13 +0000 Subject: [PATCH] fix(bank-statement-importer): drop premature File Format validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The validate() hook threw "Amount Mode 'X' requires these Standard Fields: Reference Number, Debit, Credit" as soon as the user uploaded a sample file — auto-detect made the form dirty, and any later save ran into a setup the user hadn't finished yet. The dialog interrupted the very flow it was supposed to support. Removed the entire _validate_file_format hook. The same check already lives in excel_parser.parse_excel — it fires only when the user actually tries to import a statement, which is the right moment to demand that the format be complete. Saving a half-configured form is fine: users can come back and finish later. --- .../bank_statement_importer.py | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.py b/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.py index c23e062..f6f2f30 100644 --- a/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.py +++ b/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.py @@ -2,23 +2,10 @@ # For license information, please see license.txt import frappe -from frappe import _ from frappe.model.document import Document -# Standard fields the parser needs depending on the chosen amount_mode. -# Date + Reference Number are always required. -_REQUIRED_BY_MODE = { - "Single column with sign": ("Date", "Reference Number", "Amount"), - "Separate debit/credit columns": ("Date", "Reference Number", "Debit", "Credit"), - "Single column + direction column": ("Date", "Reference Number", "Amount", "Direction"), -} - - class BankStatementImporter(Document): - def validate(self): - self._validate_file_format() - def on_update(self): # Keep the registry records in sync with the mapping child tables: # removing a row OR clearing its erp_customer / erp_supplier flips the @@ -26,33 +13,6 @@ class BankStatementImporter(Document): self._sync_customer_statuses() self._sync_supplier_statuses() - def _validate_file_format(self): - # Only validate when the user has started filling in the File Format tab. - # An empty Bank Integration is allowed (e.g. just created, before any setup). - if not (self.column_mappings or self.amount_mode or self.header_row): - return - - mode = self.amount_mode or "Separate debit/credit columns" - mapped = { - (row.standard_field or "").strip() - for row in (self.column_mappings or []) - if row.excel_column and row.standard_field - } - required = _REQUIRED_BY_MODE.get(mode, ()) - missing = [f for f in required if f not in mapped] - if mapped and missing: - frappe.throw(_( - "Amount Mode '{0}' requires these Standard Fields in the Column Mappings table: {1}. " - "Add a row for each missing field." - ).format(mode, ", ".join(missing))) - - if mode == "Single column + direction column": - if not (self.direction_debit_values or "").strip() and not (self.direction_credit_values or "").strip(): - frappe.throw(_( - "Mode 'Single column + direction column' requires at least one of " - "'Debit Values' or 'Credit Values' to be filled (comma-separated)." - )) - def _sync_customer_statuses(self): mapped_names = { row.bi_customer_name