From 38cb5a98bfb7cd85f09f9363c6fbfe823c253a28 Mon Sep 17 00:00:00 2001 From: DHINESH00 <18csa09@karpagamtech.ac.in> Date: Thu, 19 Dec 2024 17:15:11 +0530 Subject: [PATCH 1/2] fix: update discounting on mixed conditions (cherry picked from commit d541259da9ddd0c32ec6307c879b129d3df304e3) --- erpnext/public/js/controllers/transaction.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 79ed7d0a836..e1714dae308 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1825,18 +1825,16 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe apply_rule_on_other_items(args) { const me = this; - const fields = ["discount_percentage", "pricing_rules", "discount_amount", "rate"]; + const fields = ["pricing_rules"]; for(var k in args) { let data = args[k]; if (data && data.apply_rule_on_other_items && JSON.parse(data.apply_rule_on_other_items)) { + fields.push(frappe.scrub(data.pricing_rule_for)) me.frm.doc.items.forEach(d => { - if (in_list(JSON.parse(data.apply_rule_on_other_items), d[data.apply_rule_on]) && d.item_code === data.item_code) { + if (in_list(JSON.parse(data.apply_rule_on_other_items), d[data.apply_rule_on])) { for(var k in data) { - if (data.pricing_rule_for == "Discount Percentage" && data.apply_rule_on_other_items && k == "discount_amount") { - continue; - } if (in_list(fields, k) && data[k] && (data.price_or_product_discount === 'Price' || k === 'pricing_rules')) { frappe.model.set_value(d.doctype, d.name, k, data[k]); From 1d5a73a325b5d3c7c2cd7660ec066e3cf95f32e4 Mon Sep 17 00:00:00 2001 From: DHINESH00 <18csa09@karpagamtech.ac.in> Date: Mon, 23 Dec 2024 11:23:23 +0530 Subject: [PATCH 2/2] fix: Semgrep rules (cherry picked from commit 547c8004ebc51a0cb1efbe7b20b58a4963377db8) --- 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 e1714dae308..fb43cb46860 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1833,7 +1833,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe if (data && data.apply_rule_on_other_items && JSON.parse(data.apply_rule_on_other_items)) { fields.push(frappe.scrub(data.pricing_rule_for)) me.frm.doc.items.forEach(d => { - if (in_list(JSON.parse(data.apply_rule_on_other_items), d[data.apply_rule_on])) { + if (JSON.parse(data.apply_rule_on_other_items).includes(d[data.apply_rule_on])) { for(var k in data) { if (in_list(fields, k) && data[k] && (data.price_or_product_discount === 'Price' || k === 'pricing_rules')) {