mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
feat: coupon_code and referral_sales_partner functionality
This commit is contained in:
committed by
Rohit Waghchaure
parent
0bb99c15e5
commit
74dc3c99de
@@ -537,3 +537,29 @@ def get_address_territory(address_name):
|
||||
|
||||
def show_terms(doc):
|
||||
return doc.tc_name
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def apply_coupon_code(applied_code,applied_referral_sales_partner):
|
||||
quotation = True
|
||||
if applied_code:
|
||||
coupon_list=frappe.get_all('Coupon Code', filters={"docstatus": ("<", "2"), 'coupon_code':applied_code }, fields=['name'])
|
||||
if coupon_list:
|
||||
coupon_name=coupon_list[0].name
|
||||
from erpnext.accounts.doctype.pricing_rule.utils import validate_coupon_code
|
||||
validate_coupon_code(coupon_name)
|
||||
quotation = _get_cart_quotation()
|
||||
quotation.coupon_code=coupon_name
|
||||
quotation.flags.ignore_permissions = True
|
||||
quotation.save()
|
||||
if applied_referral_sales_partner:
|
||||
sales_partner_list=frappe.get_all('Sales Partner', filters={'docstatus': 0, 'referral_code':applied_referral_sales_partner }, fields=['name'])
|
||||
if sales_partner_list:
|
||||
sales_partner_name=sales_partner_list[0].name
|
||||
quotation.referral_sales_partner=sales_partner_name
|
||||
quotation.flags.ignore_permissions = True
|
||||
quotation.save()
|
||||
else:
|
||||
frappe.throw(_("Please enter valid coupon code !!"))
|
||||
else:
|
||||
frappe.throw(_("Please enter coupon code !!"))
|
||||
return quotation
|
||||
@@ -275,6 +275,40 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "show_apply_coupon_code_in_website",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Show Apply Coupon Code",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
|
||||
Reference in New Issue
Block a user