diff --git a/india_compliance/gst_india/utils/__init__.py b/india_compliance/gst_india/utils/__init__.py index 44e7b7119..5e29db78d 100644 --- a/india_compliance/gst_india/utils/__init__.py +++ b/india_compliance/gst_india/utils/__init__.py @@ -940,24 +940,26 @@ def validate_invoice_number(doc, throw=True): if not throw: return is_valid_length and is_valid_format + if is_valid_length and is_valid_format: + return + title = _("Invalid GST Transaction Name") if not is_valid_length: message = _( "Transaction Name must be 16 characters or fewer to meet GST requirements" ) - if doc.doctype == "Purchase Invoice": - frappe.msgprint(message, title=title) - return - - frappe.throw(message, title=title) - - if not is_valid_format: + else: message = _( "Transaction Name should start with an alphanumeric character and can" " only contain alphanumeric characters, dash (-) and slash (/) to meet GST requirements" ) - frappe.throw(message, title=title) + + if doc.doctype == "Purchase Invoice": + frappe.msgprint(message, title=title) + return + + frappe.throw(message, title=title) def handle_server_errors(settings, doc, document_type, error):