Skip to content

Commit

Permalink
Merge pull request #44217 from frappe/mergify/bp/version-15-hotfix/pr…
Browse files Browse the repository at this point in the history
…-44104

fix: check if pricing rule matches with coupon code (backport #44104)
  • Loading branch information
ruthra-kumar authored Nov 19, 2024
2 parents efdbe93 + 6089661 commit 610c483
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,16 @@ def get_pricing_rule_for_item(args, doc=None, for_validate=False):
get_pricing_rule_items(pricing_rule, other_items=fetch_other_item) or []
)

if pricing_rule.coupon_code_based == 1:
if not args.coupon_code:
return item_details

coupon_code = frappe.db.get_value(
doctype="Coupon Code", filters={"pricing_rule": pricing_rule.name}, fieldname="name"
)
if args.coupon_code != coupon_code:
continue

if pricing_rule.get("suggestion"):
continue

Expand All @@ -476,9 +486,6 @@ def get_pricing_rule_for_item(args, doc=None, for_validate=False):
pricing_rule.apply_rule_on_other_items
)

if pricing_rule.coupon_code_based == 1 and args.coupon_code is None:
return item_details

if not pricing_rule.validate_applied_rule:
if pricing_rule.price_or_product_discount == "Price":
apply_price_discount_rule(pricing_rule, item_details, args)
Expand Down

0 comments on commit 610c483

Please sign in to comment.