fix: multiple pricing rule issue (#24515)
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 9d9d1b3..35c6cd3 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -121,7 +121,7 @@
def before_cancel(self):
validate_einvoice_fields(self)
-
+
def on_trash(self):
# delete sl and gl entries on deletion of transaction
if frappe.db.get_single_value('Accounts Settings', 'delete_linked_ledger_entries'):
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 76309f8..452246e 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -616,7 +616,6 @@
self.doc.precision("base_write_off_amount"))
def calculate_margin(self, item):
-
rate_with_margin = 0.0
base_rate_with_margin = 0.0
if item.price_list_rate:
@@ -625,8 +624,8 @@
for d in get_applied_pricing_rules(item.pricing_rules):
pricing_rule = frappe.get_cached_doc('Pricing Rule', d)
- if (pricing_rule.margin_type in ['Amount', 'Percentage'] and pricing_rule.currency == self.doc.currency)\
- or (pricing_rule.margin_type == 'Percentage'):
+ if (pricing_rule.margin_rate_or_amount and pricing_rule.currency == self.doc.currency and
+ pricing_rule.margin_type in ['Amount', 'Percentage']):
item.margin_type = pricing_rule.margin_type
item.margin_rate_or_amount = pricing_rule.margin_rate_or_amount
has_margin = True