From b06a86541bfb384bc9e458a53348cd05d4d95666 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 8 Apr 2025 20:39:14 +0200 Subject: [PATCH 1/6] refactor: use `doc` parameter instead of `this.frm.doc` (cherry picked from commit 87c21a89fe4bf3261d3a9a7d0a7d9eeefa7ea3d8) --- erpnext/public/js/controllers/transaction.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index cbd80a3c45f..d6541c6496b 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1039,32 +1039,32 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } } - due_date() { + due_date(doc) { // 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 there is only one row in payment schedule child table, set its due date as the due date - if (this.frm.doc.payment_schedule.length == 1){ - this.frm.doc.payment_schedule[0].due_date = this.frm.doc.due_date; + if (doc.payment_schedule.length == 1){ + doc.payment_schedule[0].due_date = doc.due_date; this.frm.refresh_field("payment_schedule"); return } if ( - this.frm.doc.due_date && + doc.due_date && !this.frm.updating_party_details && - !this.frm.doc.is_pos && + !doc.is_pos && ( - this.frm.doc.payment_terms_template || - this.frm.doc.payment_schedule?.length + doc.payment_terms_template || + doc.payment_schedule?.length ) ) { const to_clear = []; - if (this.frm.doc.payment_terms_template) { + if (doc.payment_terms_template) { to_clear.push("Payment Terms Template"); } - if (this.frm.doc.payment_schedule?.length) { + if (doc.payment_schedule?.length) { to_clear.push("Payment Schedule Table"); } From cf00d427998f7f59741df7644c02e8c732c2001e Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 8 Apr 2025 20:40:50 +0200 Subject: [PATCH 2/6] fix: recognize trigger from child table (cherry picked from commit c55c77f4e9c48bbebe36cfc29ffbebde2b5bbaaa) --- erpnext/public/js/controllers/transaction.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index d6541c6496b..a468cf1b2b9 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1039,9 +1039,14 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } } - due_date(doc) { + due_date(doc, cdt) { // 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 (doc.doctype !== cdt) { + // triggered by change to the due_date field in payment schedule child table + // do nothing to avoid infinite clearing loop + return; + } // if there is only one row in payment schedule child table, set its due date as the due date if (doc.payment_schedule.length == 1){ From 0c260baacd50c1af90acfd885016b30a9a9dae4b Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 8 Apr 2025 20:53:04 +0200 Subject: [PATCH 3/6] fix: use the actual field label (cherry picked from commit 8a4db6958127a5c8c8d0c755c0e8e64bdf6321ab) --- erpnext/public/js/controllers/transaction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a468cf1b2b9..093d928a9d3 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1066,11 +1066,11 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe ) { const to_clear = []; if (doc.payment_terms_template) { - to_clear.push("Payment Terms Template"); + to_clear.push(__(frappe.meta.get_label(cdt, "payment_terms_template"))); } if (doc.payment_schedule?.length) { - to_clear.push("Payment Schedule Table"); + to_clear.push(__(frappe.meta.get_label(cdt, "payment_schedule"))); } frappe.confirm( From 35daf669fe9b5bdfe3a9f1976f0e39b9c52108eb Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 8 Apr 2025 20:53:29 +0200 Subject: [PATCH 4/6] fix: clarify confirmation message (cherry picked from commit 57be8a85d6ebbf9e71b5f1f6389891d2b887f6c0) --- erpnext/public/js/controllers/transaction.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 093d928a9d3..7238e356d29 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1075,8 +1075,11 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe frappe.confirm( __( - "Do you want to clear the selected {0}?", - [frappe.utils.comma_and(to_clear.map(dt => __(dt)))] + "For the new {0} to take effect, would you like to clear the current {1}?", + [ + __(frappe.meta.get_label(cdt, "due_date")), + frappe.utils.comma_and(to_clear) + ], ), () => { this.frm.set_value("payment_terms_template", ""); From 14efeb4acd4d79018e5520c729cab8b57ff011a1 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 8 Apr 2025 20:54:52 +0200 Subject: [PATCH 5/6] chore: add context (cherry picked from commit c00f62d54a099b75d9b65ab548c51b5856ae7f9f) --- erpnext/public/js/controllers/transaction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 7238e356d29..9c6ae5afa98 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1080,6 +1080,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe __(frappe.meta.get_label(cdt, "due_date")), frappe.utils.comma_and(to_clear) ], + "Clear payment terms template and/or payment schedule when due date is changed" ), () => { this.frm.set_value("payment_terms_template", ""); From b5353e4ad1b8f2f14e1a0731b1596503ead3ec92 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:19:34 +0200 Subject: [PATCH 6/6] chore: add german translation --- erpnext/translations/de.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/translations/de.csv b/erpnext/translations/de.csv index 5197b33b47f..8c735dc0e7c 100644 --- a/erpnext/translations/de.csv +++ b/erpnext/translations/de.csv @@ -8340,6 +8340,7 @@ Please set a Company,Bitte legen Sie eine Firma fest, "Sorry, this coupon code's validity has expired",Die Gültigkeit dieses Gutscheincodes ist leider abgelaufen, "Sorry, this coupon code is no longer valid",Dieser Gutscheincode ist leider nicht mehr gültig, For the 'Apply Rule On Other' condition the field {0} is mandatory,Für die Bedingung 'Regel auf andere anwenden' ist das Feld {0} obligatorisch, +"For the new {0} to take effect, would you like to clear the current {1}?","Möchten sie die/den aktuelle(n) {1} entfernen, damit das neue {0} angewendet wird?",Clear payment terms template and/or payment schedule when due date is changed {1} Not in Stock,{1} Nicht auf Lager, Only {0} in Stock for item {1},Nur {0} auf Lager für Artikel {1}, Please enter a coupon code,Bitte geben Sie einen Gutscheincode ein,