Skip to content

Commit

Permalink
Merge pull request #2099 from resilient-tech/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
vorasmit authored May 3, 2024
2 parents b1100d4 + 30b47d1 commit 40fb75e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion india_compliance/gst_india/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
24 changes: 19 additions & 5 deletions india_compliance/gst_india/utils/gstin_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion india_compliance/gst_india/utils/test_gstin_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestGstinInfo(unittest.TestCase):
"addr": {
"bnm": "",
"bno": "8-A",
"city": "",
"city": "Vadodara",
"dst": "Vadodara",
"flno": "Saimee society No.2",
"lg": "",
Expand Down

0 comments on commit 40fb75e

Please sign in to comment.