fix: suggestion threshold label and rule was not working for other items with min and max amount
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index c0a8c9e..c17610b 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1492,7 +1492,17 @@
frappe.model.set_value(child.doctype, child.name, "rate", value);
}
+ if (key === "pricing_rules") {
+ frappe.model.set_value(child.doctype, child.name, key, value);
+ }
+
if (key !== "free_item_data") {
+ if (child.apply_rule_on_other_items && JSON.parse(child.apply_rule_on_other_items).length) {
+ if (!in_list(JSON.parse(child.apply_rule_on_other_items), child.item_code)) {
+ continue;
+ }
+ }
+
frappe.model.set_value(child.doctype, child.name, key, value);
}
}
@@ -1510,11 +1520,11 @@
this.remove_pricing_rule(frappe.get_doc(child.doctype, child.name));
}
- if (child.free_item_data.length > 0) {
+ if (child.free_item_data && child.free_item_data.length > 0) {
this.apply_product_discount(child);
}
- if (child.apply_rule_on_other_items) {
+ if (child.apply_rule_on_other_items && JSON.parse(child.apply_rule_on_other_items).length) {
items_rule_dict[child.name] = child;
}
}
@@ -1530,11 +1540,11 @@
for(var k in args) {
let data = args[k];
- if (data && data.apply_rule_on_other_items) {
+ if (data && data.apply_rule_on_other_items && JSON.parse(data.apply_rule_on_other_items)) {
me.frm.doc.items.forEach(d => {
- if (in_list(data.apply_rule_on_other_items, d[data.apply_rule_on])) {
+ if (in_list(JSON.parse(data.apply_rule_on_other_items), 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')) {
+ 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]);
}
}