Skip to content

Commit

Permalink
refactor: update error message and title to be more generic (#2763)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 authored Nov 22, 2024
1 parent 5822292 commit 4b63388
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ def test_validate_invoice_length(self):

self.assertRaisesRegex(
frappe.exceptions.ValidationError,
"GST Invoice Number cannot exceed 16 characters",
"Transaction Name must be 16 characters or fewer to meet GST requirements",
pinv.save,
)
12 changes: 7 additions & 5 deletions india_compliance/gst_india/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,17 +936,19 @@ def validate_invoice_number(doc, throw=True):

if not is_valid_length:
frappe.throw(
_("GST Invoice Number cannot exceed 16 characters"),
title=_("Invalid GST Invoice Number"),
_(
"Transaction Name must be 16 characters or fewer to meet GST requirements"
),
title=_("Invalid GST Transaction Name"),
)

if not is_valid_format:
frappe.throw(
_(
"GST Invoice Number should start with an alphanumeric character and can"
" only contain alphanumeric characters, dash (-) and slash (/)"
"Transaction Name should start with an alphanumeric character and can"
" only contain alphanumeric characters, dash (-) and slash (/) to meet GST requirements"
),
title=_("Invalid GST Invoice Number"),
title=_("Invalid GST Transaction Name"),
)


Expand Down
6 changes: 4 additions & 2 deletions india_compliance/public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,14 @@ Object.assign(india_compliance, {
// returns a list of error messages if invoice number is invalid
let message_list = [];
if (invoice_number.length > 16) {
message_list.push("GST Invoice Number cannot exceed 16 characters");
message_list.push(
"Transaction Name must be 16 characters or fewer to meet GST requirements"
);
}

if (!GST_INVOICE_NUMBER_FORMAT.test(invoice_number)) {
message_list.push(
"GST Invoice Number should start with an alphanumeric character and can only contain alphanumeric characters, dash (-) and slash (/)."
"Transaction Name should start with an alphanumeric character and can only contain alphanumeric characters, dash (-) and slash (/) to meet GST requirements."
);
}

Expand Down

0 comments on commit 4b63388

Please sign in to comment.