fix: multiple pricing rule with margin type not working

This commit is contained in:
Rohit Waghchaure 2020-12-24 22:44:31 +05:30
parent 9fe7f235d0
commit ba5b603a0b
2 changed files with 14 additions and 2 deletions

View File

@ -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)
or (pricing_rule.margin_type == 'Percentage')):
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
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':
pricing_rule_rate = 0.0
if pricing_rule.currency == args.currency:

View File

@ -164,7 +164,15 @@ def _get_tree_conditions(args, parenttype, table, allow_blank=True):
frappe.throw(_("Invalid {0}").format(args.get(field)))
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 allow_blank: parent_groups.append('')