From 79ed02bb2ca4986be96f230f43b68c8c82d1e9e8 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:30:20 +0100 Subject: [PATCH 1/3] fix: translatability (cherry picked from commit 6d43d46fbcdbb360eeeb3a3df359a061925a9350) --- erpnext/public/js/controllers/transaction.js | 41 +++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 6423fd78fe9..bd8f6bc0110 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1020,25 +1020,30 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe due_date() { // due_date is to be changed, payment terms template and/or payment schedule must // be removed as due_date is automatically changed based on payment terms - if (this.frm.doc.due_date && !this.frm.updating_party_details && !this.frm.doc.is_pos) { - if (this.frm.doc.payment_terms_template || - (this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length)) { - var message1 = ""; - var message2 = ""; - var final_message = __("Please clear the") + " "; - - if (this.frm.doc.payment_terms_template) { - message1 = __("selected Payment Terms Template"); - final_message = final_message + message1; - } - - if ((this.frm.doc.payment_schedule || []).length) { - message2 = __("Payment Schedule Table"); - if (message1.length !== 0) message2 = " and " + message2; - final_message = final_message + message2; - } - frappe.msgprint(final_message); + if ( + this.frm.doc.due_date && + !this.frm.updating_party_details && + !this.frm.doc.is_pos && + ( + this.frm.doc.payment_terms_template || + this.frm.doc.payment_schedule?.length + ) + ) { + const to_clear = []; + if (this.frm.doc.payment_terms_template) { + to_clear.push("Payment Terms Template"); } + + if (this.frm.doc.payment_schedule?.length) { + to_clear.push("Payment Schedule Table"); + } + + frappe.msgprint( + __( + "Please clear the selected {0}", + [frappe.utils.comma_and(to_clear.map(dt => __(dt)))] + ) + ); } } From db647a4e4274a8a05a6726acffe016e8cd421361 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:38:34 +0200 Subject: [PATCH 2/3] fix: wording --- erpnext/public/js/controllers/transaction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index bd8f6bc0110..15f235f8456 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1040,7 +1040,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe frappe.msgprint( __( - "Please clear the selected {0}", + "Please clear the {0}", [frappe.utils.comma_and(to_clear.map(dt => __(dt)))] ) ); From 830290c859cc8dae0a2e33a6ae9d97b8505d08a0 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:39:17 +0100 Subject: [PATCH 3/3] feat: clear payment terms and schedule --- erpnext/public/js/controllers/transaction.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 1f22c7c64e2..8e90853ad06 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1060,11 +1060,16 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe to_clear.push("Payment Schedule Table"); } - frappe.msgprint( + frappe.confirm( __( - "Please clear the {0}", + "Do you want to clear the selected {0}?", [frappe.utils.comma_and(to_clear.map(dt => __(dt)))] - ) + ), + () => { + this.frm.set_value("payment_terms_template", ""); + this.frm.clear_table("payment_schedule"); + this.frm.refresh_field("payment_schedule"); + } ); } }