Skip to content

Commit

Permalink
fix: changes as per review
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Sep 30, 2024
1 parent 74fc6ed commit 3e4dcbf
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions india_compliance/gst_india/utils/gstin_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ def _get_gstin_info(gstin, *, throw_error=True):
response=get_formatted_response_for_status(response, gstin),
)

if response.get("errorCode") == "FO8000":
return get_formatted_response_for_status(response, gstin)

except Exception as exc:
if isinstance(exc, GSPServerError):
frappe.cache.set_value("gst_server_error", True, expires_in_sec=60)
Expand All @@ -79,9 +76,9 @@ def _get_gstin_info(gstin, *, throw_error=True):

gstin_info = frappe._dict(
gstin=response.gstin,
business_name=titlecase(business_name),
business_name=titlecase(business_name or ""),
gst_category=GST_CATEGORIES.get(response.dty, ""),
status=response.sts,
status=response.sts if response.sts else "Invalid",
)

if permanent_address := response.get("pradr"):
Expand Down Expand Up @@ -232,24 +229,16 @@ def get_formatted_response_for_status(response, gstin):
"""
Format response from Public API
"""
if response.get("errorCode") == "FO8000":
return frappe._dict(
{
"gstin": gstin,
"status": "Invalid",
}
)

return frappe._dict(
{
"gstin": response.gstin,
"gstin": response.gstin or gstin,
"registration_date": parse_datetime(
response.rgdt, day_first=True, throw=False
),
"cancelled_date": parse_datetime(
response.cxdt, day_first=True, throw=False
),
"status": response.sts,
"status": response.sts if response.sts else "Invalid",
}
)

Expand Down

0 comments on commit 3e4dcbf

Please sign in to comment.