Skip to content

Commit

Permalink
fix: avoid_dupliace in address
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Apr 16, 2024
1 parent a0f9b2d commit 127bc8f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions india_compliance/gst_india/utils/gstin_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,24 @@ def _get_address(address):
def _extract_address_lines(address):
"""merge and divide address into exactly two lines"""

unique_address = {}
for key in address:
address[key] = address[key].strip(f"{whitespace},")
if address[key] not in unique_address.values():
unique_address[key] = address[key].strip(f"{whitespace},")

address_line1 = ", ".join(
titlecase(value)
for key in ("bno", "flno", "bnm")
if (value := address.get(key))
if (value := unique_address.get(key))
)

address_line2 = ", ".join(
titlecase(value) for key in ("loc", "city") if (value := address.get(key))
titlecase(value)
for key in ("loc", "city")
if (value := unique_address.get(key))
)

if not (street := address.get("st")):
if not (street := unique_address.get("st")):
return address_line1, address_line2

street = titlecase(street)
Expand Down

0 comments on commit 127bc8f

Please sign in to comment.