From a27e9b08f527df25493065c616e5bb672c1e3e3b Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Mon, 18 May 2026 13:10:22 +0000 Subject: [PATCH] fix(file-format): offer to re-run auto-detect on sample re-upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously a re-upload (clear → re-attach) just refreshed the Excel Column dropdown and silently kept the existing mapping rows — pointing the user at the new file but leaving the table tied to the old one. Now the form asks before overwriting: empty table still auto-detects silently, populated table prompts with a Confirm dialog before clearing and re-running. --- .../bank_statement_importer.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.js b/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.js index 2e71e6b..44741f2 100644 --- a/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.js +++ b/jey_erp/jey_erp/doctype/bank_statement_importer/bank_statement_importer.js @@ -189,14 +189,24 @@ const BIFileFormat = { }); }, - // Called when the user attaches / replaces the Sample Excel File. Refresh - // the Excel Column dropdown and, if the table is still empty, run - // auto-detect silently. We never overwrite a user-filled table. + // Called when the user attaches / replaces / clears the Sample Excel File. + // Refresh the Excel Column dropdown, then either auto-detect silently + // (empty table) or ask before overwriting an existing mapping (re-upload). onSampleFileChange(frm) { this.applySampleHeaders(frm, /*force*/ true); + if (!frm.doc.sample_file) return; + const hasRows = (frm.doc.column_mappings || []).some(r => r.excel_column || r.standard_field); - if (!frm.doc.sample_file || hasRows) return; - this.autoDetect(frm, /*silent*/ true); + if (!hasRows) { + this.autoDetect(frm, /*silent*/ true); + return; + } + frappe.confirm( + __('Re-run auto-detect and replace the existing {0} Column Mapping row(s)?', [ + frm.doc.column_mappings.length, + ]), + () => this.autoDetect(frm, /*silent*/ true), + ); }, setColumnOptions(frm, headers) {