feat: add document verification API serializers and views
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 35s

This commit is contained in:
vickytechkey 2026-10-25 14:49:56 +05:30
parent 6521343ea1
commit 100a4390e7
2 changed files with 34 additions and 11 deletions

View file

@ -12,6 +12,12 @@ class VerifyDocumentRequestSerializer(serializers.Serializer):
required=True,
help_text="Document verification attributes (e.g. pan_number, name, dob, etc.)",
)
business_name = serializers.CharField(
required=False,
allow_blank=True,
allow_null=True,
help_text="Optional legal entity or trade name of the business to match against GSTIN.",
)
preferred_vendor = serializers.CharField(
required=False,
allow_null=True,
@ -39,6 +45,12 @@ class VerifySellerPanGstRequestSerializer(serializers.Serializer):
max_length=15,
help_text="Optional GSTIN entered by seller to cross-verify against linked GST records.",
)
business_name = serializers.CharField(
required=False,
allow_blank=True,
allow_null=True,
help_text="Optional legal entity or trade name of the business to match against GSTIN.",
)
preferred_vendor = serializers.CharField(
required=False,
allow_blank=True,

View file

@ -372,6 +372,7 @@ class SellerPanGstVerifyView(APIView):
seller_name = serializer.validated_data["seller_name"].strip()
pan = serializer.validated_data["pan"].strip().upper()
entered_gstin = (serializer.validated_data.get("gstin") or "").strip().upper()
business_name = (serializer.validated_data.get("business_name") or request.data.get("business_name") or "").strip()
preferred_vendor = serializer.validated_data.get("preferred_vendor")
start_time = time.time()
@ -492,10 +493,8 @@ class SellerPanGstVerifyView(APIView):
gstin_matched = True
break
# Validate that 15-character GSTIN contains the 10-character PAN at chars 3-12
if len(target_gstin) == 15 and target_gstin[2:12].upper() != pan.upper():
gstin_matched = False
gst_error = f"GSTIN '{target_gstin}' does not match the provided PAN card '{pan}'."
# Do not restrict GSTIN to individual PAN. Entities/companies have their own PAN inside their GSTIN.
# Just verify that the GSTIN exists and is active.
# Check if matching record has legal_name
if matching_gst_record and matching_gst_record.get("legal_name"):
@ -529,7 +528,19 @@ class SellerPanGstVerifyView(APIView):
if not verified_gst_name and gstin_matched:
verified_gst_name = verified_pan_name
# Compare GST legal name against seller full name and verified PAN name
# Compare GST legal name and trade name against business name (as per GST), seller name, and verified PAN name
gst_candidates = [n for n in [verified_gst_name, gst_details.get("legalName"), gst_details.get("tradeName")] if n]
# 1. Primary: Match against entered business name (as per GST)
if business_name:
for candidate in gst_candidates:
b_match = compare_names(business_name, candidate)
if b_match["matched"]:
gst_name_match = b_match
break
# 2. Fallback: Match against seller name or verified PAN name
if not gst_name_match.get("matched", False):
if verified_gst_name:
gst_name_match = compare_names(seller_name, verified_gst_name)
if not gst_name_match["matched"] and verified_pan_name: