From c18beaea6b9cbb79ac24bfd6182999337bc7e441 Mon Sep 17 00:00:00 2001 From: "bhaveshkumar.j" Date: Mon, 21 Oct 2024 18:22:30 +0000 Subject: [PATCH 1/3] fix: coupon code validation logic (cherry picked from commit d04257a32dd705868cc662399dcc893003a5b59c) # Conflicts: # erpnext/accounts/doctype/pricing_rule/utils.py --- erpnext/accounts/doctype/pricing_rule/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 0032e539e44..0b0a3235b3a 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -715,6 +715,7 @@ def get_pricing_rule_items(pr_doc, other_items=False) -> list: def validate_coupon_code(coupon_name): coupon = frappe.get_doc("Coupon Code", coupon_name) +<<<<<<< HEAD if coupon.valid_from: if coupon.valid_from > getdate(today()): @@ -723,9 +724,17 @@ def validate_coupon_code(coupon_name): if coupon.valid_upto < getdate(today()): frappe.throw(_("Sorry, this coupon code's validity has expired")) elif coupon.used >= coupon.maximum_use: +======= + if coupon.valid_from and coupon.valid_from > getdate(today()): + frappe.throw(_("Sorry, this coupon code's validity has not started")) + elif coupon.valid_upto and 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: +>>>>>>> d04257a32d (fix: coupon code validation logic) frappe.throw(_("Sorry, this coupon code is no longer valid")) + def update_coupon_code_count(coupon_name, transaction_type): coupon = frappe.get_doc("Coupon Code", coupon_name) if coupon: From 719565c8973f18783fb44503536317a0d8e25a9f Mon Sep 17 00:00:00 2001 From: "bhaveshkumar.j" Date: Mon, 21 Oct 2024 18:23:39 +0000 Subject: [PATCH 2/3] fix: remove extra space (cherry picked from commit 1561a9e1bf6b179dddae2861160d224b6983ced1) --- erpnext/accounts/doctype/pricing_rule/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 0b0a3235b3a..48f81629244 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -734,7 +734,6 @@ def validate_coupon_code(coupon_name): frappe.throw(_("Sorry, this coupon code is no longer valid")) - def update_coupon_code_count(coupon_name, transaction_type): coupon = frappe.get_doc("Coupon Code", coupon_name) if coupon: From 2af36383cc33455041c82040a2deb58e5455ecbe Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 22 Oct 2024 10:16:57 +0530 Subject: [PATCH 3/3] chore: resolve conflict --- erpnext/accounts/doctype/pricing_rule/utils.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 48f81629244..0b3117365c0 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -715,22 +715,11 @@ def get_pricing_rule_items(pr_doc, other_items=False) -> list: def validate_coupon_code(coupon_name): coupon = frappe.get_doc("Coupon Code", coupon_name) -<<<<<<< HEAD - - if coupon.valid_from: - if coupon.valid_from > getdate(today()): - frappe.throw(_("Sorry, this coupon code's validity has not started")) - elif coupon.valid_upto: - if coupon.valid_upto < getdate(today()): - frappe.throw(_("Sorry, this coupon code's validity has expired")) - elif coupon.used >= coupon.maximum_use: -======= if coupon.valid_from and coupon.valid_from > getdate(today()): frappe.throw(_("Sorry, this coupon code's validity has not started")) elif coupon.valid_upto and 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: ->>>>>>> d04257a32d (fix: coupon code validation logic) frappe.throw(_("Sorry, this coupon code is no longer valid"))