Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion POS/src/components/sale/CouponDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const couponResource = createResource({
makeParams() {
return {
coupon_code: couponCode.value,
customer: props.customer,
customer: props.customer || "",
company: props.company,
};
},
Expand Down Expand Up @@ -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 = "";

Expand Down
5 changes: 4 additions & 1 deletion pos_next/api/offers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")}

Expand Down
Loading