fix: Pricing Rule on Transaction Based on Coupon (#26949) (#27182)

(cherry picked from commit f91faac7cd)

Co-authored-by: Lovin Maxwell <lovinmaxwell@gmail.com>
This commit is contained in:
Frappe PR Bot
2021-08-26 21:33:20 +05:30
committed by GitHub
parent 8dae084f23
commit 485b55a799

View File

@@ -475,7 +475,20 @@ def apply_pricing_rule_on_transaction(doc):
frappe.msgprint(_("User has not applied rule on the invoice {0}")
.format(doc.name))
else:
doc.set(field, d.get(pr_field))
if not d.coupon_code_based:
doc.set(field, d.get(pr_field))
elif doc.get('coupon_code'):
# coupon code based pricing rule
coupon_code_pricing_rule = frappe.db.get_value('Coupon Code', doc.get('coupon_code'), 'pricing_rule')
if coupon_code_pricing_rule == d.name:
# if selected coupon code is linked with pricing rule
doc.set(field, d.get(pr_field))
else:
# reset discount if not linked
doc.set(field, 0)
else:
# if coupon code based but no coupon code selected
doc.set(field, 0)
doc.calculate_taxes_and_totals()
elif d.price_or_product_discount == 'Product':