feat: price margin in buying (#24685)

This commit is contained in:
Anupam Kumar
2021-03-15 11:11:28 +05:30
committed by GitHub
parent 5165859e51
commit ed42afc5e8
12 changed files with 208 additions and 79 deletions

View File

@@ -141,29 +141,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
this.apply_price_list();
},
price_list_rate: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
let item_rate = item.price_list_rate;
if (doc.doctype == "Purchase Order" && item.blanket_order_rate) {
item_rate = item.blanket_order_rate;
}
if (item.discount_percentage) {
item.discount_amount = flt(item_rate) * flt(item.discount_percentage) / 100;
}
if (item.discount_amount) {
item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item));
} else {
item.rate = item_rate;
}
this.calculate_taxes_and_totals();
},
discount_percentage: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
item.discount_amount = 0.0;