Browse Source

Merge pull request #29027 from frappe/mergify/bp/develop/pr-28953

fix(UX): Optimize rate updation on changing price list (backport #28953)
develop
Deepesh Garg 3 years ago
committed by GitHub
parent
commit
85d47e809b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      erpnext/public/js/controllers/transaction.js
  2. 2
      erpnext/stock/get_item_details.py

13
erpnext/public/js/controllers/transaction.js

@ -680,7 +680,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
// check if child doctype is Sales Order Item/Qutation Item and calculate the rate
// check if child doctype is Sales Order Item/Quotation Item and calculate the rate
if (in_list(["Quotation Item", "Sales Order Item", "Delivery Note Item", "Sales Invoice Item", "POS Invoice Item", "Purchase Invoice Item", "Purchase Order Item", "Purchase Receipt Item"]), cdt)
this.apply_pricing_rule_on_item(item);
else
@ -1582,25 +1582,27 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
_set_values_for_item_list(children) {
var me = this;
var price_list_rate_changed = false;
var items_rule_dict = {};
for(var i=0, l=children.length; i<l; i++) {
var d = children[i] ;
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(var k in d) {
var v = d[k];
if (["doctype", "name"].indexOf(k)===-1) {
if(k=="price_list_rate") {
if(flt(v) != flt(d.price_list_rate)) price_list_rate_changed = true;
item_row['rate'] = v;
}
if (k !== 'free_item_data') {
frappe.model.set_value(d.doctype, d.name, k, v);
item_row[k] = v;
}
}
}
frappe.model.round_floats_in(item_row, ["price_list_rate", "discount_percentage"]);
// 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) {
me.apply_price_list(frappe.get_doc(d.doctype, d.name));
@ -1617,9 +1619,10 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
}
}
me.frm.refresh_field('items');
me.apply_rule_on_other_items(items_rule_dict);
if(!price_list_rate_changed) me.calculate_taxes_and_totals();
me.calculate_taxes_and_totals();
}
apply_rule_on_other_items(args) {

2
erpnext/stock/get_item_details.py

@ -1097,7 +1097,7 @@ def apply_price_list(args, as_doc=False):
}
def apply_price_list_on_item(args):
item_doc = frappe.get_doc("Item", args.item_code)
item_doc = frappe.db.get_value("Item", args.item_code, ['name', 'variant_of'], as_dict=1)
item_details = get_price_list_rate(args, item_doc)
item_details.update(get_pricing_rule_for_item(args, item_details.price_list_rate))

Loading…
Cancel
Save