Skip to content

Phase 10: Supplier Portal & AFD

Duration: 3 days Goal: Implement Supplier self-service portal per DPR Section 3.7


Supplier Portal enabling:

  • Self-registration and onboarding
  • Product application submission
  • Sample submission tracking
  • AFD-I and AFD-II integration
  • Document upload and status tracking

class SupplierRegistration(BaseDocType):
"""Supplier self-registration request."""
# Company Info
company_name: str = Field(max_length=200)
company_type: str # Manufacturer, Marketer, Brand Owner
# Statutory
gstin: str
pan: str
cin: str | None = None # Company Identification Number
# MSME (if applicable)
msme_registered: bool = False
udyam_number: str | None = None
msme_category: str | None = None # Micro, Small, Medium
# Special Categories
is_startup: bool = False
dpiit_number: str | None = None
is_women_owned: bool = False
is_divyangjan_owned: bool = False
is_ex_serviceman: bool = False
# Contact
contact_person: str
email: str
phone: str
address: str
# Documents
gst_certificate: str | None = None # FK to File
pan_card: str | None = None
msme_certificate: str | None = None
company_profile: str | None = None
# Verification
gstin_verified: bool = False
pan_verified: bool = False
# Status
status: str = "Draft" # Draft, Submitted, Under Review, Approved, Rejected
# On Approval
supplier_code: str | None = None
class Meta:
table_name = "supplier_registration"
  • Create SupplierRegistration DocType
  • GSTIN verification API integration
  • UDYAM portal verification
  • Auto-create Supplier on approval

class SupplierProductSubmission(BaseDocType):
"""Product submission from Supplier portal."""
supplier: str # FK to Supplier
# Product Details
product_name: str
brand_name: str
barcode: str
hsn_code: str
# Pricing
mrp: Decimal
proposed_trade_price: Decimal
discount_percent: Decimal
# Classification
category: str # GS, LIF, AFD-I, AFD-II
item_group: str
# For Liquor (LIF)
is_liquor: bool = False
bottle_in_origin: bool = False # BIO vs BII
edp_pan_india: Decimal | None = None # Ex-Distillery Price
# Standards & Certifications
fssai_license: str | None = None
bis_certification: str | None = None
agmark: str | None = None
# Documents
tds_certificate: str | None = None
product_images: list[str] = Field(default_factory=list)
lab_report: str | None = None
costing_sheet: str | None = None
# Sample
sample_submitted: bool = False
sample_submission_date: date | None = None
sample_tracking_number: str | None = None
# Status
status: str = "Draft"
# Link to internal application
product_application: str | None = None # FK to ProductApplication
class Meta:
table_name = "supplier_product_submission"
  • Create SupplierProductSubmission DocType
  • Smart Consumer App barcode validation
  • Auto-create ProductApplication on submit
  • Sample submission instructions

class AFDOrderI(BaseDocType):
"""Against Firm Demand - Category I (4-wheelers, 2-wheelers, white goods)."""
# Beneficiary
customer: str # Link to Outlet
outlet: str # FK to Outlet
# Product
item: str # FK to Item
supplier: str # FK to Supplier
# Pricing (from AFD portal)
mrp: Decimal
legacy_erp_price: Decimal
discount_amount: Decimal
# Order
order_date: date
delivery_date: date | None = None
# Payment
payment_mode: str # Online, Cheque, RTGS
payment_status: str = "Pending"
payment_reference: str | None = None
# Delivery
delivery_status: str = "Pending" # Pending, Dispatched, Delivered
delivery_address: str
# Status
status: str = "Draft"
class Meta:
table_name = "afd_order_i"
class AFDOrderII(BaseDocType):
"""Against Firm Demand - Category II (lower value white goods)."""
customer: str
outlet: str
customer_id: str
depot: str # Fulfilled via Depot
item: str
quantity: int = 1
mrp: Decimal
legacy_erp_price: Decimal
status: str = "Draft"
class Meta:
table_name = "afd_order_ii"
  • Create AFD DocTypes
  • AFD portal sync (external)
  • Member eligibility check
  • Depot stock allocation for AFD-II

class SampleSubmission(BaseDocType):
"""Track physical sample submission from Supplier."""
supplier: str
product_submission: str # FK to SupplierProductSubmission
# Sample Details
sample_description: str
quantity: int
# Shipping
courier_name: str | None = None
tracking_number: str | None = None
shipped_date: date | None = None
# Receipt at Legacy ERP HO
received_date: date | None = None
received_by: str | None = None
barcode_validated: bool = False
# Storage
sample_location: str | None = None
# Return
return_requested: bool = False
return_date: date | None = None
status: str = "Pending" # Pending, In Transit, Received, Returned
class Meta:
table_name = "sample_submission"
  • Create SampleSubmission DocType
  • Courier tracking integration (optional)
  • Barcode scanner validation
  • Sample return workflow

Widget Data
Active Products Count of items in Legacy ERP catalogue
Pending Applications Products under review
Orders This Month AFD orders received
Payments Due Outstanding payments from Legacy ERP
Sample Status Track submitted samples
  • Refine.dev Supplier Dashboard
  • Real-time application status
  • Payment history view
  • Document repository

class SupplierPaymentGateway(BaseDocType):
"""Track registration/application fees paid by Supplier."""
supplier: str
payment_type: str # Registration Fee, Stage-I Fee, Stage-II Fee
amount: Decimal
# Gateway
gateway: str # Razorpay, PayU, etc.
transaction_id: str
payment_status: str # Pending, Success, Failed
# Receipt
receipt_number: str | None = None
payment_date: datetime | None = None
class Meta:
table_name = "supplier_payment_gateway"
  • Create SupplierPaymentGateway DocType
  • Payment gateway integration
  • Auto-receipt generation
  • Fee calculation based on product count

Endpoint Method Description
/api/supplier/register POST Self-registration
/api/supplier/verify-gstin POST GSTIN verification
/api/supplier/products GET, POST Product submissions
/api/supplier/products/{id}/submit-sample POST Mark sample shipped
/api/supplier/applications/{id}/status GET Application status
/api/supplier/payments GET Payment history
/api/supplier/afd/orders GET AFD orders

Separate Refine.dev app for Supplier self-service:

supplier-portal/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ pages/
β”‚ β”‚ β”œβ”€β”€ Dashboard.tsx
β”‚ β”‚ β”œβ”€β”€ Products/
β”‚ β”‚ β”‚ β”œβ”€β”€ List.tsx
β”‚ β”‚ β”‚ β”œβ”€β”€ Create.tsx
β”‚ β”‚ β”‚ └── Status.tsx
β”‚ β”‚ β”œβ”€β”€ Samples/
β”‚ β”‚ β”‚ └── Track.tsx
β”‚ β”‚ β”œβ”€β”€ AFD/
β”‚ β”‚ β”‚ └── Orders.tsx
β”‚ β”‚ └── Payments/
β”‚ β”‚ └── History.tsx
β”‚ └── components/
β”‚ β”œβ”€β”€ ProductForm.tsx
β”‚ β”œβ”€β”€ DocumentUpload.tsx
β”‚ └── StatusTimeline.tsx

  • Supplier self-registration working
  • GSTIN/PAN verification
  • Product submission creates internal application
  • Sample tracking end-to-end
  • AFD orders synced
  • Payment gateway functional
  • Supplier dashboard shows real-time data