From 5084b9bd4bb27d907edf5a70ad8d9dcd4913e3eb Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Wed, 21 Feb 2024 16:39:28 +0530 Subject: [PATCH] fix: check for pricing rules on item (cherry picked from commit ecd83b12abb19e0e41a50e914a89b320e1f577eb) (cherry picked from commit 32d96423795c99ed2cc46cf1cc04fbf636dac5c7) --- erpnext/public/js/controllers/transaction.js | 48 ++++++++++---------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index c0298a4f14..1533c7055c 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1509,31 +1509,33 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } remove_pricing_rule_for_item(item) { - let me = this; - return this.frm.call({ - method: "erpnext.accounts.doctype.pricing_rule.pricing_rule.remove_pricing_rule_for_item", - args: { - pricing_rules: item.pricing_rules, - item_details: { - "doctype": item.doctype, - "name": item.name, - "item_code": item.item_code, - "pricing_rules": item.pricing_rules, - "parenttype": item.parenttype, - "parent": item.parent, - "price_list_rate": item.price_list_rate + if (item.pricing_rules){ + let me = this; + return this.frm.call({ + method: "erpnext.accounts.doctype.pricing_rule.pricing_rule.remove_pricing_rule_for_item", + args: { + pricing_rules: item.pricing_rules, + item_details: { + "doctype": item.doctype, + "name": item.name, + "item_code": item.item_code, + "pricing_rules": item.pricing_rules, + "parenttype": item.parenttype, + "parent": item.parent, + "price_list_rate": item.price_list_rate + }, + item_code: item.item_code, + rate: item.price_list_rate, }, - item_code: item.item_code, - rate: item.price_list_rate, - }, - callback: function(r) { - if (!r.exc && r.message) { - me.remove_pricing_rule(r.message); - me.calculate_taxes_and_totals(); - if(me.frm.doc.apply_discount_on) me.frm.trigger("apply_discount_on"); + callback: function(r) { + if (!r.exc && r.message) { + me.remove_pricing_rule(r.message); + me.calculate_taxes_and_totals(); + if(me.frm.doc.apply_discount_on) me.frm.trigger("apply_discount_on"); + } } - } - }); + }); + } } apply_pricing_rule(item, calculate_taxes_and_totals) {