Merge pull request #44798 from aerele/apply_pricing_rule

fix: update  discounting on mixed conditions
This commit is contained in:
ruthra kumar
2025-01-14 09:58:03 +05:30
committed by GitHub

View File

@@ -1867,18 +1867,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 (JSON.parse(data.apply_rule_on_other_items).includes(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]);