feat: added coupon code functionality onsales invoice

This commit is contained in:
“Khushi
2024-03-14 12:04:09 +05:30
parent 10bb1c31a2
commit a0247d11bd
2 changed files with 4 additions and 2 deletions

View File

@@ -740,10 +740,10 @@ def validate_coupon_code(coupon_name):
if coupon.valid_from:
if coupon.valid_from > getdate(today()):
frappe.throw(_("Sorry, this coupon code's validity has not started"))
if coupon.valid_upto:
elif coupon.valid_upto:
if coupon.valid_upto < getdate(today()):
frappe.throw(_("Sorry, this coupon code's validity has expired"))
if coupon.used >= coupon.maximum_use:
elif coupon.used >= coupon.maximum_use:
frappe.throw(_("Sorry, this coupon code is no longer valid"))

View File

@@ -271,6 +271,8 @@ class SalesInvoice(SellingController):
validate_inter_company_party(
self.doctype, self.customer, self.company, self.inter_company_invoice_reference
)
# Validating coupon code
if self.coupon_code:
validate_coupon_code(self.coupon_code)