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