mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
fix: coupon code limits and add external plaftorm code
(cherry picked from commit 70ed75a397)
# Conflicts:
# erpnext/accounts/doctype/coupon_code/coupon_code.json
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
"customer",
|
"customer",
|
||||||
"column_break_4",
|
"column_break_4",
|
||||||
"coupon_code",
|
"coupon_code",
|
||||||
|
"from_external_ecomm_platform",
|
||||||
"pricing_rule",
|
"pricing_rule",
|
||||||
"uses",
|
"uses",
|
||||||
"valid_from",
|
"valid_from",
|
||||||
@@ -60,11 +61,12 @@
|
|||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval !doc.from_external_ecomm_platform",
|
||||||
"fieldname": "pricing_rule",
|
"fieldname": "pricing_rule",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Pricing Rule",
|
"label": "Pricing Rule",
|
||||||
"options": "Pricing Rule",
|
"mandatory_depends_on": "eval: !doc.from_external_ecomm_platform",
|
||||||
"reqd": 1
|
"options": "Pricing Rule"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "uses",
|
"fieldname": "uses",
|
||||||
@@ -113,12 +115,24 @@
|
|||||||
"options": "Coupon Code",
|
"options": "Coupon Code",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "from_external_ecomm_platform",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "From External Ecomm Platform"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
<<<<<<< HEAD
|
||||||
"modified": "2019-10-19 14:48:14.602481",
|
"modified": "2019-10-19 14:48:14.602481",
|
||||||
|
=======
|
||||||
|
"links": [],
|
||||||
|
"modified": "2024-06-28 06:17:01.833399",
|
||||||
|
>>>>>>> 70ed75a397 (fix: coupon code limits and add external plaftorm code)
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Coupon Code",
|
"name": "Coupon Code",
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ class CouponCode(Document):
|
|||||||
coupon_type: DF.Literal["Promotional", "Gift Card"]
|
coupon_type: DF.Literal["Promotional", "Gift Card"]
|
||||||
customer: DF.Link | None
|
customer: DF.Link | None
|
||||||
description: DF.TextEditor | None
|
description: DF.TextEditor | None
|
||||||
|
from_external_ecomm_platform: DF.Check
|
||||||
maximum_use: DF.Int
|
maximum_use: DF.Int
|
||||||
pricing_rule: DF.Link
|
pricing_rule: DF.Link | None
|
||||||
used: DF.Int
|
used: DF.Int
|
||||||
valid_from: DF.Date | None
|
valid_from: DF.Date | None
|
||||||
valid_upto: DF.Date | None
|
valid_upto: DF.Date | None
|
||||||
|
|||||||
@@ -732,7 +732,7 @@ def validate_coupon_code(coupon_name):
|
|||||||
elif coupon.valid_upto:
|
elif coupon.valid_upto:
|
||||||
if coupon.valid_upto < getdate(today()):
|
if coupon.valid_upto < getdate(today()):
|
||||||
frappe.throw(_("Sorry, this coupon code's validity has expired"))
|
frappe.throw(_("Sorry, this coupon code's validity has expired"))
|
||||||
elif 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"))
|
||||||
|
|
||||||
|
|
||||||
@@ -740,7 +740,10 @@ 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:
|
||||||
if transaction_type == "used":
|
if transaction_type == "used":
|
||||||
if coupon.used < coupon.maximum_use:
|
if not coupon.maximum_use:
|
||||||
|
coupon.used = coupon.used + 1
|
||||||
|
coupon.save(ignore_permissions=True)
|
||||||
|
elif coupon.used < coupon.maximum_use:
|
||||||
coupon.used = coupon.used + 1
|
coupon.used = coupon.used + 1
|
||||||
coupon.save(ignore_permissions=True)
|
coupon.save(ignore_permissions=True)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user