From 4dcd502b760d68e5cefe14b94e1df9f35b2c8775 Mon Sep 17 00:00:00 2001 From: ravibharathi656 Date: Thu, 25 Sep 2025 22:38:58 +0530 Subject: [PATCH] fix: set cost center in taxes if not set (cherry picked from commit b75940bf0ea759ef5e868dc7bca92fedb62ac192) # Conflicts: # erpnext/public/js/controllers/transaction.js --- erpnext/public/js/controllers/transaction.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ed7e4bf623b..0af61025653 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2137,16 +2137,22 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe this.frm.doc.name).options, "master_name": this.frm.doc.taxes_and_charges }, - callback: function(r) { - if(!r.exc) { - if(me.frm.doc.shipping_rule && me.frm.doc.taxes) { - for (let tax of r.message) { + callback: function (r) { + if (!r.exc) { + let taxes = r.message; + taxes.forEach((tax) => { + if (me.frm.doc?.cost_center && !tax.cost_center) { + tax.cost_center = me.frm.doc.cost_center; + } + }); + if (me.frm.doc.shipping_rule && me.frm.doc.taxes) { + for (let tax of taxes) { me.frm.add_child("taxes", tax); } refresh_field("taxes"); } else { - me.frm.set_value("taxes", r.message); + me.frm.set_value("taxes", taxes); me.calculate_taxes_and_totals(); } }