Merge pull request #24205 from rohitwaghchaure/pricing-rule-not-working-margin-v13-beta
fix: multiple pricing rule with margin type as Percentage is not working
This commit is contained in:
commit
a4d71d5c7f
@ -345,9 +345,13 @@ def apply_price_discount_rule(pricing_rule, item_details, args):
|
|||||||
if ((pricing_rule.margin_type in ['Amount', 'Percentage'] and pricing_rule.currency == args.currency)
|
if ((pricing_rule.margin_type in ['Amount', 'Percentage'] and pricing_rule.currency == args.currency)
|
||||||
or (pricing_rule.margin_type == 'Percentage')):
|
or (pricing_rule.margin_type == 'Percentage')):
|
||||||
item_details.margin_type = pricing_rule.margin_type
|
item_details.margin_type = pricing_rule.margin_type
|
||||||
item_details.margin_rate_or_amount = pricing_rule.margin_rate_or_amount
|
|
||||||
item_details.has_margin = True
|
item_details.has_margin = True
|
||||||
|
|
||||||
|
if pricing_rule.apply_multiple_pricing_rules and item_details.margin_rate_or_amount is not None:
|
||||||
|
item_details.margin_rate_or_amount += pricing_rule.margin_rate_or_amount
|
||||||
|
else:
|
||||||
|
item_details.margin_rate_or_amount = pricing_rule.margin_rate_or_amount
|
||||||
|
|
||||||
if pricing_rule.rate_or_discount == 'Rate':
|
if pricing_rule.rate_or_discount == 'Rate':
|
||||||
pricing_rule_rate = 0.0
|
pricing_rule_rate = 0.0
|
||||||
if pricing_rule.currency == args.currency:
|
if pricing_rule.currency == args.currency:
|
||||||
|
@ -164,7 +164,15 @@ def _get_tree_conditions(args, parenttype, table, allow_blank=True):
|
|||||||
frappe.throw(_("Invalid {0}").format(args.get(field)))
|
frappe.throw(_("Invalid {0}").format(args.get(field)))
|
||||||
|
|
||||||
parent_groups = frappe.db.sql_list("""select name from `tab%s`
|
parent_groups = frappe.db.sql_list("""select name from `tab%s`
|
||||||
where lft<=%s and rgt>=%s""" % (parenttype, '%s', '%s'), (lft, rgt))
|
where lft>=%s and rgt<=%s""" % (parenttype, '%s', '%s'), (lft, rgt))
|
||||||
|
|
||||||
|
if parenttype in ["Customer Group", "Item Group", "Territory"]:
|
||||||
|
parent_field = "parent_{0}".format(frappe.scrub(parenttype))
|
||||||
|
root_name = frappe.db.get_list(parenttype,
|
||||||
|
{"is_group": 1, parent_field: ("is", "not set")}, "name", as_list=1)
|
||||||
|
|
||||||
|
if root_name and root_name[0][0]:
|
||||||
|
parent_groups.append(root_name[0][0])
|
||||||
|
|
||||||
if parent_groups:
|
if parent_groups:
|
||||||
if allow_blank: parent_groups.append('')
|
if allow_blank: parent_groups.append('')
|
||||||
|
Loading…
Reference in New Issue
Block a user