fix: pricing rule not working for production discount
This commit is contained in:
@@ -1305,6 +1305,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
me.remove_pricing_rule(frappe.get_doc(d.doctype, d.name));
|
||||
}
|
||||
|
||||
if (d.free_item_data) {
|
||||
me.apply_product_discount(d.free_item_data);
|
||||
}
|
||||
|
||||
if (d.apply_rule_on_other_items) {
|
||||
items_rule_dict[d.name] = d;
|
||||
}
|
||||
@@ -1334,6 +1338,20 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
}
|
||||
},
|
||||
|
||||
apply_product_discount: function(free_item_data) {
|
||||
const items = this.frm.doc.items.filter(d => (d.item_code == free_item_data.item_code
|
||||
&& d.is_free_item)) || [];
|
||||
|
||||
if (!items.length) {
|
||||
let row_to_modify = frappe.model.add_child(this.frm.doc,
|
||||
this.frm.doc.doctype + ' Item', 'items');
|
||||
|
||||
for (let key in free_item_data) {
|
||||
row_to_modify[key] = free_item_data[key];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
apply_price_list: function(item, reset_plc_conversion) {
|
||||
// We need to reset plc_conversion_rate sometimes because the call to
|
||||
// `erpnext.stock.get_item_details.apply_price_list` is sensitive to its value
|
||||
|
||||
Reference in New Issue
Block a user