From dcdd3e8cc452bd31c4707ea93bf176d585e5822f Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Wed, 24 Jan 2024 01:48:10 +0100 Subject: [PATCH 1/2] fix: don't overwrite existing terms in transaction (cherry picked from commit 77b044f1a6e7273b21ce5a884429875b10d3bb2e) # Conflicts: # erpnext/public/js/controllers/transaction.js --- erpnext/public/js/controllers/transaction.js | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a3d4d880b294..3e7317598386 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -809,6 +809,40 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe me.frm.set_value("tc_name", company_doc.default_buying_terms); } } +<<<<<<< HEAD +======= + + if ( + company_doc.default_selling_terms && + frappe.meta.has_field(me.frm.doc.doctype, "tc_name") && + [ + "Sales Invoice", + "Quotation", + "Sales Order", + "Delivery Note", + ].includes(me.frm.doc.doctype) && + !me.frm.doc.tc_name + ) { + me.frm.set_value("tc_name", company_doc.default_selling_terms); + } + + if ( + company_doc.default_buying_terms && + frappe.meta.has_field(me.frm.doc.doctype, "tc_name") && + [ + "Request for Quotation", + "Supplier Quotation", + "Purchase Order", + // Purchase Invoice is excluded as per issue #3345 + "Material Request", + "Purchase Receipt", + ].includes(me.frm.doc.doctype) && + !me.frm.doc.tc_name + ) { + me.frm.set_value("tc_name", company_doc.default_buying_terms); + } + +>>>>>>> 77b044f1a6 (fix: don't overwrite existing terms in transaction) frappe.run_serially([ () => me.frm.script_manager.trigger("currency"), () => me.update_item_tax_map(), From ba55d0ede778f79ec2f24e462e30c31166594165 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Wed, 31 Jan 2024 13:19:19 +0100 Subject: [PATCH 2/2] chore: resolve conflicts --- erpnext/public/js/controllers/transaction.js | 38 ++------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 3e7317598386..05f512f5c4a6 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -798,51 +798,17 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } let selling_doctypes_for_tc = ["Sales Invoice", "Quotation", "Sales Order", "Delivery Note"]; if (company_doc.default_selling_terms && frappe.meta.has_field(me.frm.doc.doctype, "tc_name") && - selling_doctypes_for_tc.indexOf(me.frm.doc.doctype) != -1) { + selling_doctypes_for_tc.includes(me.frm.doc.doctype) && !me.frm.doc.tc_name) { me.frm.set_value("tc_name", company_doc.default_selling_terms); } let buying_doctypes_for_tc = ["Request for Quotation", "Supplier Quotation", "Purchase Order", "Material Request", "Purchase Receipt"]; // Purchase Invoice is excluded as per issue #3345 if (company_doc.default_buying_terms && frappe.meta.has_field(me.frm.doc.doctype, "tc_name") && - buying_doctypes_for_tc.indexOf(me.frm.doc.doctype) != -1) { + buying_doctypes_for_tc.includes(me.frm.doc.doctype) && !me.frm.doc.tc_name) { me.frm.set_value("tc_name", company_doc.default_buying_terms); } } -<<<<<<< HEAD -======= - - if ( - company_doc.default_selling_terms && - frappe.meta.has_field(me.frm.doc.doctype, "tc_name") && - [ - "Sales Invoice", - "Quotation", - "Sales Order", - "Delivery Note", - ].includes(me.frm.doc.doctype) && - !me.frm.doc.tc_name - ) { - me.frm.set_value("tc_name", company_doc.default_selling_terms); - } - - if ( - company_doc.default_buying_terms && - frappe.meta.has_field(me.frm.doc.doctype, "tc_name") && - [ - "Request for Quotation", - "Supplier Quotation", - "Purchase Order", - // Purchase Invoice is excluded as per issue #3345 - "Material Request", - "Purchase Receipt", - ].includes(me.frm.doc.doctype) && - !me.frm.doc.tc_name - ) { - me.frm.set_value("tc_name", company_doc.default_buying_terms); - } - ->>>>>>> 77b044f1a6 (fix: don't overwrite existing terms in transaction) frappe.run_serially([ () => me.frm.script_manager.trigger("currency"), () => me.update_item_tax_map(),