fix: Run get_item_tax_info and set_taxes serially

This commit is contained in:
Saif Ur Rehman 2018-12-28 04:59:42 +05:00
parent aca374e478
commit e414a92d55

View File

@ -1319,32 +1319,34 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
} }
}); });
//todo run serially? frappe.run_serially([
erpnext.utils.set_taxes(this.frm, "tax_category"); () => {
if(item_codes.length) {
if(item_codes.length) { return this.frm.call({
return this.frm.call({ method: "erpnext.stock.get_item_details.get_item_tax_info",
method: "erpnext.stock.get_item_details.get_item_tax_info", args: {
args: { tax_category: cstr(me.frm.doc.tax_category),
tax_category: cstr(me.frm.doc.tax_category), item_codes: item_codes
item_codes: item_codes },
}, callback: function(r) {
callback: function(r) { if(!r.exc) {
if(!r.exc) { $.each(me.frm.doc.items || [], function(i, item) {
$.each(me.frm.doc.items || [], function(i, item) { if(item.item_code && r.message.hasOwnProperty(item.item_code)) {
if(item.item_code && r.message.hasOwnProperty(item.item_code)) { item.item_tax_template = r.message[item.item_code].item_tax_template;
item.item_tax_template = r.message[item.item_code].item_tax_template; item.item_tax_rate = r.message[item.item_code].item_tax_rate;
item.item_tax_rate = r.message[item.item_code].item_tax_rate; } else {
} else { item.item_tax_template = "";
item.item_tax_template = ""; item.item_tax_rate = "{}";
item.item_tax_rate = "{}"; }
});
me.calculate_taxes_and_totals();
} }
}); }
me.calculate_taxes_and_totals(); });
}
} }
}); },
} () => erpnext.utils.set_taxes(this.frm, "tax_category"),
]);
}, },
item_tax_template: function(doc, cdt, cdn) { item_tax_template: function(doc, cdt, cdn) {