feat: pricing rule enhancements
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index a246822..965d2b0 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -140,8 +140,18 @@
discount_percentage: function(doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
+ item.discount_amount = 0.0;
+ this.apply_discount_on_item(doc, cdt, cdn, 'discount_percentage');
+ },
+
+ discount_amount: function(doc, cdt, cdn) {
+ this.apply_discount_on_item(doc, cdt, cdn, 'discount_amount');
+ },
+
+ apply_discount_on_item: function(doc, cdt, cdn, field) {
+ var item = frappe.get_doc(cdt, cdn);
if(!item.price_list_rate) {
- item.discount_percentage = 0.0;
+ item[field] = 0.0;
} else {
this.price_list_rate(doc, cdt, cdn);
}