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) {