fix: on changing qty free item not removed (#21251)
This commit is contained in:
parent
dd78eb3842
commit
fc31dbef12
@ -178,7 +178,8 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
|
||||
|
||||
if pricing_rules[0].mixed_conditions and doc:
|
||||
stock_qty, amount, items = get_qty_and_rate_for_mixed_conditions(doc, pr_doc, args)
|
||||
pricing_rules[0].apply_rule_on_other_items = items
|
||||
for pricing_rule_args in pricing_rules:
|
||||
pricing_rule_args.apply_rule_on_other_items = items
|
||||
|
||||
elif pricing_rules[0].is_cumulative:
|
||||
items = [args.get(frappe.scrub(pr_doc.get('apply_on')))]
|
||||
@ -329,9 +330,9 @@ def get_qty_and_rate_for_mixed_conditions(doc, pr_doc, args):
|
||||
if pr_doc.mixed_conditions:
|
||||
amt = args.get('qty') * args.get("price_list_rate")
|
||||
if args.get("item_code") != row.get("item_code"):
|
||||
amt = row.get('qty') * row.get("price_list_rate")
|
||||
amt = row.get('qty') * (row.get("price_list_rate") or args.get("rate"))
|
||||
|
||||
sum_qty += row.get("stock_qty") or args.get("stock_qty")
|
||||
sum_qty += row.get("stock_qty") or args.get("stock_qty") or args.get("qty")
|
||||
sum_amt += amt
|
||||
|
||||
if pr_doc.is_cumulative:
|
||||
|
@ -559,7 +559,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});
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1394,20 +1400,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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user