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

This commit is contained in:
Lovin Maxwell 2021-08-26 18:24:02 +03:00 committed by GitHub
parent ae55eab599
commit f91faac7cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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':