fix: multiple pricing rule issue (#24509)

This commit is contained in:
rohitwaghchaure
2021-02-01 20:22:14 +05:30
committed by GitHub
parent fb016edb7a
commit bf7317d4e2
3 changed files with 20 additions and 28 deletions

View File

@@ -616,7 +616,6 @@ class calculate_taxes_and_totals(object):
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 @@ class calculate_taxes_and_totals(object):
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