From 4cee5609e9a4a39da5ff0ede46b22427e0f466dd Mon Sep 17 00:00:00 2001 From: Vishakh Desai Date: Mon, 29 Apr 2024 11:31:16 +0530 Subject: [PATCH 1/2] fix: remove check digit validation for transporter id (cherry picked from commit 8cfa2090646bcca7deb6afa6549cfebecaedaff0) --- india_compliance/gst_india/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/india_compliance/gst_india/utils/__init__.py b/india_compliance/gst_india/utils/__init__.py index 4718f8be6..4c3ad08f3 100644 --- a/india_compliance/gst_india/utils/__init__.py +++ b/india_compliance/gst_india/utils/__init__.py @@ -171,7 +171,7 @@ def validate_gstin( title=_("Invalid {0}").format(label), ) - if not (is_transporter_id and gstin.startswith("88")): + if not is_transporter_id: validate_gstin_check_digit(gstin, label) if is_tcs_gstin and not TCS.match(gstin): From 8d6f43b3dd30103bd3d0127750d44f6797b5f250 Mon Sep 17 00:00:00 2001 From: Lakshit Jain <108322669+ljain112@users.noreply.github.com> Date: Thu, 2 May 2024 19:44:13 +0530 Subject: [PATCH 2/2] fix: avoid duplicate address keys in gstin info based on key priority (#2094) Co-authored-by: Sagar Vora (cherry picked from commit 0875bfba00a37dde320613fd893421bb00a6b10b) --- .../gst_india/utils/gstin_info.py | 24 +++++++++++++++---- .../gst_india/utils/test_gstin_info.py | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/india_compliance/gst_india/utils/gstin_info.py b/india_compliance/gst_india/utils/gstin_info.py index add8fe451..a46d03c0c 100644 --- a/india_compliance/gst_india/utils/gstin_info.py +++ b/india_compliance/gst_india/utils/gstin_info.py @@ -22,6 +22,11 @@ "URP": "Unregistered", } +# order of address keys is important +KEYS_TO_SANITIZE = ("dst", "stcd", "pncd", "bno", "flno", "bnm", "st", "loc", "city") +KEYS_TO_FILTER_DUPLICATES = frozenset(("dst", "bnm", "st", "loc", "city")) +CHARACTERS_TO_STRIP = f"{whitespace}," + @frappe.whitelist() def get_gstin_info(gstin, *, throw_error=True): @@ -121,12 +126,21 @@ def _get_address(address): def _extract_address_lines(address): """merge and divide address into exactly two lines""" - unique_values = set() - for key, value in address.items(): - value = value.strip(f"{whitespace},") - address[key] = value if value not in unique_values else None - unique_values.add(value) + + for key in KEYS_TO_SANITIZE: + value = address.get(key, "").strip(CHARACTERS_TO_STRIP) + + if key not in KEYS_TO_FILTER_DUPLICATES: + address[key] = value + continue + + if value not in unique_values: + address[key] = value + unique_values.add(value) + continue + + address[key] = "" address_line1 = ", ".join( titlecase(value) diff --git a/india_compliance/gst_india/utils/test_gstin_info.py b/india_compliance/gst_india/utils/test_gstin_info.py index 3471f2173..c8ad1a6a2 100644 --- a/india_compliance/gst_india/utils/test_gstin_info.py +++ b/india_compliance/gst_india/utils/test_gstin_info.py @@ -14,7 +14,7 @@ class TestGstinInfo(unittest.TestCase): "addr": { "bnm": "", "bno": "8-A", - "city": "", + "city": "Vadodara", "dst": "Vadodara", "flno": "Saimee society No.2", "lg": "",