Merge pull request #17980 from adityahase/fix-buying-items-rate
fix: Consider discount_amount only when provided to calculate rate
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 7e61f03..97c823d 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -144,7 +144,9 @@
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();
},