From 48585c94ffc99dd5e1daceca98e78eae63a81ec8 Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 18 Jun 2019 19:11:17 +0530 Subject: [PATCH] fix: Consider discount_amount only when provided to calculate rate After selecting item_code in items table and not entering rate, Clicking elsewhere will set rate to NaN. All DocTypes on buying side have this bug. --- erpnext/public/js/controllers/buying.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 7e61f03af9..97c823d053 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -144,7 +144,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ item.discount_amount = flt(item_rate) * flt(item.discount_percentage) / 100; } - item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item)); + if (item.discount_amount) { + item.rate = flt((item.price_list_rate) - (item.discount_amount), precision('rate', item)); + } this.calculate_taxes_and_totals(); },