Skip to content

Commit

Permalink
Merge pull request #2885 from resilient-tech/mergify/bp/version-15-ho…
Browse files Browse the repository at this point in the history
…tfix/pr-2873

fix: update HSN validation message for better ux (backport #2873)
  • Loading branch information
mergify[bot] authored Dec 20, 2024
2 parents 3ce2869 + 3fed0e8 commit bd167da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions india_compliance/gst_india/overrides/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ def test_missing_hsn_code(self):

self.assertRaisesRegex(
frappe.exceptions.ValidationError,
re.compile(r"^(Please enter a valid HSN/SAC code for.*)$"),
re.compile(
r"^(HSN/SAC must exist and should be 6 or 8 digits long for.*)$"
),
doc.submit,
)

Expand All @@ -277,7 +279,9 @@ def test_invalid_hsn_digits(self):
doc.save()
self.assertRaisesRegex(
frappe.exceptions.ValidationError,
re.compile(r"^(Please enter a valid HSN/SAC code for.*)$"),
re.compile(
r"^(HSN/SAC must exist and should be 6 or 8 digits long for.*)$"
),
doc.submit,
)

Expand Down
10 changes: 7 additions & 3 deletions india_compliance/gst_india/overrides/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,13 @@ def _validate_hsn_codes(doc, valid_hsn_length, throw=False, message=None):
frappe.throw(
_(
"{0}"
"Please enter a valid HSN/SAC code for the following row numbers:"
" <br>{1}"
).format(message or "", frappe.bold(", ".join(rows_with_invalid_hsn))),
"HSN/SAC must exist and should be {1} digits long"
" for the following row numbers: <br>{2}"
).format(
message or "",
join_list_with_custom_separators(valid_hsn_length),
frappe.bold(", ".join(rows_with_invalid_hsn)),
),
title=_("Invalid HSN/SAC"),
)

Expand Down

0 comments on commit bd167da

Please sign in to comment.