Skip to content

Commit a9a26f3

Browse files
Abdeali099mergify[bot]
authored andcommitted
refactor: enhance GSTIN validation error messages
(cherry picked from commit 8969581)
1 parent d764c73 commit a9a26f3

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
@@ -268,20 +268,30 @@ Object.assign(india_compliance, {
268268
},
269269

270270
validate_gstin(gstin, show_msg = true) {
271+
const opts = { title: __("Error"), indicator: "red" };
272+
271273
if (!gstin || gstin.length !== 15) {
272-
if (show_msg) frappe.msgprint(__("GSTIN must be 15 characters long"));
274+
if (show_msg) {
275+
frappe.msgprint({
276+
message: __("GSTIN must be 15 characters long"),
277+
...opts,
278+
});
279+
}
280+
273281
return;
274282
}
275283

276284
gstin = gstin.trim().toUpperCase();
277285

278286
if (GSTIN_REGEX.test(gstin) && is_gstin_check_digit_valid(gstin)) {
279287
return gstin;
280-
} else {
281-
if (show_msg) frappe.msgprint(__("Invalid GSTIN"));
288+
} else if (show_msg) {
289+
frappe.msgprint({
290+
message: __("Invalid GSTIN"),
291+
...opts,
292+
});
282293
}
283294
},
284-
285295
guess_gst_category(gstin, country) {
286296
if (!gstin) {
287297
if (country && country !== "India") return "Overseas";

0 commit comments

Comments
 (0)