fix: on changing qty free item not removed (#21250)

This commit is contained in:
rohitwaghchaure
2020-04-14 12:49:38 +05:30
committed by GitHub
parent 335d35a988
commit 4eea8bd2c0
2 changed files with 21 additions and 12 deletions

View File

@@ -546,7 +546,13 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}
},
() => me.conversion_factor(doc, cdt, cdn, true),
() => me.remove_pricing_rule(item)
() => me.remove_pricing_rule(item),
() => {
if (item.apply_rule_on_other_items) {
let key = item.name;
me.apply_rule_on_other_items({key: item});
}
}
]);
}
}
@@ -1356,20 +1362,22 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
apply_rule_on_other_items: function(args) {
const me = this;
const fields = ["discount_percentage", "discount_amount", "rate"];
const fields = ["discount_percentage", "pricing_rules", "discount_amount", "rate"];
for(var k in args) {
let data = args[k];
me.frm.doc.items.forEach(d => {
if (in_list(data.apply_rule_on_other_items, d[data.apply_rule_on])) {
for(var k in data) {
if (in_list(fields, k)) {
frappe.model.set_value(d.doctype, d.name, k, data[k]);
if (data && 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])) {
for(var k in data) {
if (in_list(fields, k) && data[k]) {
frappe.model.set_value(d.doctype, d.name, k, data[k]);
}
}
}
}
});
});
}
}
},