diff --git a/POS/src/components/sale/CouponDialog.vue b/POS/src/components/sale/CouponDialog.vue index 65ab34de..5bd94671 100644 --- a/POS/src/components/sale/CouponDialog.vue +++ b/POS/src/components/sale/CouponDialog.vue @@ -300,7 +300,7 @@ const couponResource = createResource({ makeParams() { return { coupon_code: couponCode.value, - customer: props.customer, + customer: props.customer || "", company: props.company, }; }, @@ -361,6 +361,12 @@ async function applyCoupon() { return; } + if (!props.customer) { + errorMessage.value = __("Please choose a customer"); + showError(errorMessage.value); + return; + } + applying.value = true; errorMessage.value = ""; diff --git a/pos_next/api/offers.py b/pos_next/api/offers.py index 70b48bf2..b219ab23 100644 --- a/pos_next/api/offers.py +++ b/pos_next/api/offers.py @@ -602,8 +602,11 @@ def get_active_coupons(customer: str, company: str) -> list[dict]: @frappe.whitelist() -def validate_coupon(coupon_code: str, customer: str, company: str) -> dict: +def validate_coupon(coupon_code: str, company: str, customer: str | None = None) -> dict: """Validate a coupon code and return its details""" + if not customer: + return {"valid": False, "message": _("Please choose a customer")} + if not frappe.db.table_exists("POS Coupon"): return {"valid": False, "message": _("Coupons are not enabled")}