diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index d4f634a99d1..8ae2eb704c6 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -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")) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 6990310b59b..872327f12bb 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -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)