fix: apply price list rate
This commit is contained in:
parent
9aea017990
commit
e2295b4e2f
@ -1483,48 +1483,46 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
}
|
}
|
||||||
|
|
||||||
_set_values_for_item_list(children) {
|
_set_values_for_item_list(children) {
|
||||||
var me = this;
|
const items_rule_dict = {};
|
||||||
var items_rule_dict = {};
|
|
||||||
|
|
||||||
for(var i=0, l=children.length; i<l; i++) {
|
for (const child of children) {
|
||||||
var d = children[i] ;
|
const existing_pricing_rule = frappe.model.get_value(child.doctype, child.name, "pricing_rules");
|
||||||
let item_row = frappe.get_doc(d.doctype, d.name);
|
|
||||||
var existing_pricing_rule = frappe.model.get_value(d.doctype, d.name, "pricing_rules");
|
for (const [key, value] of Object.entries(child)) {
|
||||||
for(var k in d) {
|
if (!["doctype", "name"].includes(key)) {
|
||||||
var v = d[k];
|
if (key === "price_list_rate") {
|
||||||
if (["doctype", "name"].indexOf(k)===-1) {
|
frappe.model.set_value(child.doctype, child.name, "rate", value);
|
||||||
if(k=="price_list_rate") {
|
|
||||||
item_row['rate'] = v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k !== 'free_item_data') {
|
if (key !== "free_item_data") {
|
||||||
item_row[k] = v;
|
frappe.model.set_value(child.doctype, child.name, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.model.round_floats_in(item_row, ["price_list_rate", "discount_percentage"]);
|
frappe.model.round_floats_in(
|
||||||
|
frappe.get_doc(child.doctype, child.name),
|
||||||
|
["price_list_rate", "discount_percentage"],
|
||||||
|
);
|
||||||
|
|
||||||
// if pricing rule set as blank from an existing value, apply price_list
|
// if pricing rule set as blank from an existing value, apply price_list
|
||||||
if(!me.frm.doc.ignore_pricing_rule && existing_pricing_rule && !d.pricing_rules) {
|
if (!this.frm.doc.ignore_pricing_rule && existing_pricing_rule && !child.pricing_rules) {
|
||||||
me.apply_price_list(frappe.get_doc(d.doctype, d.name));
|
this.apply_price_list(frappe.get_doc(child.doctype, child.name));
|
||||||
} else if(!d.pricing_rules) {
|
} else if (!child.pricing_rules) {
|
||||||
me.remove_pricing_rule(frappe.get_doc(d.doctype, d.name));
|
this.remove_pricing_rule(frappe.get_doc(child.doctype, child.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.free_item_data.length > 0) {
|
if (child.free_item_data.length > 0) {
|
||||||
me.apply_product_discount(d);
|
this.apply_product_discount(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.apply_rule_on_other_items) {
|
if (child.apply_rule_on_other_items) {
|
||||||
items_rule_dict[d.name] = d;
|
items_rule_dict[child.name] = child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
me.frm.refresh_field('items');
|
this.apply_rule_on_other_items(items_rule_dict);
|
||||||
me.apply_rule_on_other_items(items_rule_dict);
|
this.calculate_taxes_and_totals();
|
||||||
|
|
||||||
me.calculate_taxes_and_totals();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_rule_on_other_items(args) {
|
apply_rule_on_other_items(args) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user