mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
fix: coupon code validation logic
This commit is contained in:
@@ -728,16 +728,15 @@ def get_pricing_rule_items(pr_doc, other_items=False) -> list:
|
|||||||
|
|
||||||
def validate_coupon_code(coupon_name):
|
def validate_coupon_code(coupon_name):
|
||||||
coupon = frappe.get_doc("Coupon Code", coupon_name)
|
coupon = frappe.get_doc("Coupon Code", coupon_name)
|
||||||
if coupon.valid_from:
|
if coupon.valid_from and coupon.valid_from > getdate(today()):
|
||||||
if coupon.valid_from > getdate(today()):
|
frappe.throw(_("Sorry, this coupon code's validity has not started"))
|
||||||
frappe.throw(_("Sorry, this coupon code's validity has not started"))
|
elif coupon.valid_upto and coupon.valid_upto < getdate(today()):
|
||||||
elif coupon.valid_upto:
|
frappe.throw(_("Sorry, this coupon code's validity has expired"))
|
||||||
if coupon.valid_upto < getdate(today()):
|
|
||||||
frappe.throw(_("Sorry, this coupon code's validity has expired"))
|
|
||||||
elif coupon.maximum_use and coupon.used >= coupon.maximum_use:
|
elif coupon.maximum_use and coupon.used >= coupon.maximum_use:
|
||||||
frappe.throw(_("Sorry, this coupon code is no longer valid"))
|
frappe.throw(_("Sorry, this coupon code is no longer valid"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_coupon_code_count(coupon_name, transaction_type):
|
def update_coupon_code_count(coupon_name, transaction_type):
|
||||||
coupon = frappe.get_doc("Coupon Code", coupon_name)
|
coupon = frappe.get_doc("Coupon Code", coupon_name)
|
||||||
if coupon:
|
if coupon:
|
||||||
|
|||||||
Reference in New Issue
Block a user