Skip to content

Commit df2a244

Browse files
authored
Merge pull request resilient-tech#3770 from resilient-tech/better-gstin-error-msg
refactor: enhance GSTIN validation error messages
2 parents 7307225 + 8969581 commit df2a244

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

india_compliance/public/js/utils.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,20 +307,30 @@ Object.assign(india_compliance, {
307307
},
308308

309309
validate_gstin(gstin, show_msg = true) {
310+
const opts = { title: __("Error"), indicator: "red" };
311+
310312
if (!gstin || gstin.length !== 15) {
311-
if (show_msg) frappe.msgprint(__("GSTIN must be 15 characters long"));
313+
if (show_msg) {
314+
frappe.msgprint({
315+
message: __("GSTIN must be 15 characters long"),
316+
...opts,
317+
});
318+
}
319+
312320
return;
313321
}
314322

315323
gstin = gstin.trim().toUpperCase();
316324

317325
if (GSTIN_REGEX.test(gstin) && is_gstin_check_digit_valid(gstin)) {
318326
return gstin;
319-
} else {
320-
if (show_msg) frappe.msgprint(__("Invalid GSTIN"));
327+
} else if (show_msg) {
328+
frappe.msgprint({
329+
message: __("Invalid GSTIN"),
330+
...opts,
331+
});
321332
}
322333
},
323-
324334
guess_gst_category(gstin, country) {
325335
if (!gstin) {
326336
if (country && country !== "India") return "Overseas";

0 commit comments

Comments
 (0)