From e83bec4ea35c2ed411bb204fc9f663d689cd5247 Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Mon, 20 Jan 2025 18:01:31 +0530 Subject: [PATCH 1/2] fix: use user defined discount amount or default --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 4 ++-- erpnext/public/js/controllers/transaction.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 7ca0e4785a..1aa0f37b41 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -414,8 +414,8 @@ def get_pricing_rule_for_item(args, doc=None, for_validate=False): "parent": args.parent, "parenttype": args.parenttype, "child_docname": args.get("child_docname"), - "discount_percentage": 0.0, - "discount_amount": 0, + "discount_percentage": args.get("discount_percentage") or 0.0, + "discount_amount": args.get("discount_amount") or 0.0, } ) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 68dc9eae66..ba92e81cf4 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1839,7 +1839,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe "serial_no": d.serial_no, "batch_no": d.batch_no, "price_list_rate": d.price_list_rate, - "conversion_factor": d.conversion_factor || 1.0 + "conversion_factor": d.conversion_factor || 1.0, + "discount_percentage" : d.discount_percentage, + "discount_amount" : d.discount_amount, }); // if doctype is Quotation Item / Sales Order Iten then add Margin Type and rate in item_list -- GitLab From e41fb16c03ed1b1c4dcd4aa128ec64db5cc8d69c Mon Sep 17 00:00:00 2001 From: Sanket322 Date: Thu, 23 Jan 2025 11:55:12 +0530 Subject: [PATCH 2/2] fix: remove applied pricing rule --- erpnext/accounts/doctype/pricing_rule/pricing_rule.py | 2 -- erpnext/public/js/controllers/transaction.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 1aa0f37b41..cdda4aa165 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -414,8 +414,6 @@ def get_pricing_rule_for_item(args, doc=None, for_validate=False): "parent": args.parent, "parenttype": args.parenttype, "child_docname": args.get("child_docname"), - "discount_percentage": args.get("discount_percentage") or 0.0, - "discount_amount": args.get("discount_amount") or 0.0, } ) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ba92e81cf4..7f96b9e7ed 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1746,7 +1746,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe }, callback: function(r) { if (!r.exc && r.message) { - me.remove_pricing_rule(r.message, removed_pricing_rule); + me.remove_pricing_rule(r.message, removed_pricing_rule, item.name); me.calculate_taxes_and_totals(); if(me.frm.doc.apply_discount_on) me.frm.trigger("apply_discount_on"); } @@ -2025,7 +2025,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe }); } - remove_pricing_rule(item, removed_pricing_rule) { + remove_pricing_rule(item, removed_pricing_rule, row_name) { let me = this; const fields = ["discount_percentage", "discount_amount", "margin_rate_or_amount", "rate_with_margin"]; @@ -2064,6 +2064,13 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe me.trigger_price_list_rate(); } + else if(!item.is_free_item && row_name){ + me.frm.doc.items.forEach(d => { + if (d.name != row_name) return; + + Object.assign(d, item); + }); + } } trigger_price_list_rate() { -- GitLab