Back to ER Diagrams
Regulatory Integrations

Regulatory Integrations Logic

Indian government-mandated integrations including TReDS (Trade Receivables Discounting System) for MSME invoice financing, GeM (Government e-Marketplace) for government procurement, and E-Invoicing with IRP for GST compliance.

15 PostgreSQL Tables
3 MongoDB Collections
GST Compliant
Real-Time API Sync

1. Overview

The Regulatory Integrations module enables compliance with Indian government mandates for MSME procurement and trade finance. It covers three key integrations that are now mandatory for enterprises dealing with MSMEs and government entities.

TReDS
Invoice Financing
GeM
Govt Marketplace
E-Invoice
GST IRP
15
Tables

Key Regulatory Requirements

  • TReDS: Mandatory for buyers with turnover > ₹500 Cr (MSME Development Act 2006, amended 2018)
  • GeM: Mandatory for all government departments and PSUs (GFR 2017 Rule 149)
  • E-Invoicing: Mandatory for businesses with turnover > ₹5 Cr (GST Notification 13/2020)
  • 45-Day Payment: MSME payments must be settled within 45 days (Section 15 of MSMED Act)

2. TReDS Integration (Trade Receivables Discounting)

TReDS enables MSMEs to get their invoices financed by uploading receivables on RBI-authorized platforms. Buyers accept invoices, and financiers bid to discount them, providing working capital to MSMEs.

TReDS Invoice Financing Flow
=============================

MSME Vendor                     Buyer (ProKure)                    TReDS Platform                  Financier
    |                               |                                   |                              |
    |-------- Invoice PO ---------> |                                   |                              |
    |                               |                                   |                              |
    |                               |--- Upload Invoice to TReDS -----> |                              |
    |                               |    (After 3-way match)            |                              |
    |                               |                                   |                              |
    |                               | <-- Notify Acceptance Request --- |                              |
    |                               |                                   |                              |
    |                               |--- Accept/Reject Invoice -------> |                              |
    |                               |    (Within 48 hours)              |                              |
    |                               |                                   |                              |
    |                               |                                   | <-- Bid for Factoring ------ |
    |                               |                                   |    (Discount rate)           |
    |                               |                                   |                              |
    | <-- Receive Early Payment (T+2) ----------------------------- Financier pays MSME ------------- |
    |                               |                                   |                              |
    |                               | <-- Payment Due (T+45 days) ----- |                              |
    |                               |                                   |                              |
    |                               |--- Pay Financier + Interest ----> |-------- Settlement -------> |

TReDS Database Schema

regulatory.treds_registrations

Buyer and seller registration details with TReDS platforms (RXIL, M1xchange, Invoicemart).

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • entity_type VARCHAR(10) NOT NULL — BUYER, SELLER
  • entity_id UUID NOT NULL — company_id or vendor_id
  • platform VARCHAR(20) NOT NULL — RXIL, M1XCHANGE, INVOICEMART
  • platform_entity_id VARCHAR(50) — ID assigned by TReDS platform
  • gstin VARCHAR(15) NOT NULL
  • pan VARCHAR(10) NOT NULL
  • udyam_number VARCHAR(20) — MSME Udyam registration number
  • bank_account_id UUID FK — linked settlement account
  • registration_status VARCHAR(20) NOT NULL — PENDING, ACTIVE, SUSPENDED, REJECTED
  • registered_at TIMESTAMPTZ
  • last_synced_at TIMESTAMPTZ
  • api_credentials JSONB — encrypted API keys
  • metadata JSONB
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, entity_type, platform), (gstin), (platform_entity_id)

regulatory.treds_invoices

Invoices uploaded to TReDS for factoring with buyer acceptance tracking.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • invoice_id UUID FK NOT NULL — finance.invoices reference
  • invoice_number VARCHAR(50) NOT NULL — DENORM
  • po_id UUID FK — linked PO
  • po_number VARCHAR(50) — DENORM
  • vendor_id UUID FK NOT NULL
  • vendor_name VARCHAR(200) — DENORM
  • vendor_gstin VARCHAR(15) — DENORM
  • platform VARCHAR(20) NOT NULL
  • platform_invoice_id VARCHAR(50) — TReDS platform reference
  • invoice_amount DECIMAL(18,4) NOT NULL
  • invoice_date DATE NOT NULL
  • due_date DATE NOT NULL
  • upload_status VARCHAR(20) NOT NULL — PENDING, UPLOADED, ACCEPTED, REJECTED, FACTORED, SETTLED
  • uploaded_at TIMESTAMPTZ
  • buyer_acceptance_status VARCHAR(20) — PENDING, ACCEPTED, REJECTED
  • buyer_accepted_at TIMESTAMPTZ
  • buyer_rejection_reason TEXT
  • acceptance_deadline TIMESTAMPTZ — 48h from upload
  • is_auto_accepted BOOLEAN DEFAULT FALSE — auto-accept if deadline passes
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, upload_status), (invoice_id), (vendor_id, platform), (acceptance_deadline)

regulatory.treds_factoring_requests

Factoring bids from financiers and accepted financing details.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • treds_invoice_id UUID FK NOT NULL
  • financier_id UUID FK NOT NULL
  • financier_name VARCHAR(200) — DENORM
  • bid_amount DECIMAL(18,4) NOT NULL — discounted amount offered
  • discount_rate DECIMAL(8,4) NOT NULL — annualized rate %
  • bid_validity TIMESTAMPTZ
  • bid_status VARCHAR(20) NOT NULL — PENDING, ACCEPTED, REJECTED, EXPIRED
  • is_winning_bid BOOLEAN DEFAULT FALSE
  • accepted_at TIMESTAMPTZ
  • disbursement_date DATE — when MSME receives funds
  • disbursement_reference VARCHAR(50)
  • created_at TIMESTAMPTZ DEFAULT NOW()

Indexes: (treds_invoice_id), (financier_id), (bid_status, is_winning_bid)

regulatory.treds_financiers

Master list of financiers (banks/NBFCs) registered on TReDS platforms.

  • id UUID PK DEFAULT gen_random_uuid()
  • platform VARCHAR(20) NOT NULL
  • financier_code VARCHAR(20) NOT NULL
  • financier_name VARCHAR(200) NOT NULL
  • financier_type VARCHAR(20) NOT NULL — BANK, NBFC
  • ifsc_code VARCHAR(11)
  • typical_discount_range JSONB — {"min": 8.5, "max": 12.0}
  • is_active BOOLEAN DEFAULT TRUE
  • metadata JSONB
  • created_at TIMESTAMPTZ DEFAULT NOW()

Indexes: (platform, financier_code), (is_active)

regulatory.treds_settlements

Settlement tracking for buyer payments to financiers.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • treds_invoice_id UUID FK NOT NULL
  • factoring_request_id UUID FK NOT NULL
  • financier_id UUID FK NOT NULL
  • original_amount DECIMAL(18,4) NOT NULL
  • interest_amount DECIMAL(18,4) NOT NULL
  • total_payable DECIMAL(18,4) NOT NULL
  • due_date DATE NOT NULL
  • settlement_status VARCHAR(20) NOT NULL — PENDING, PAID, OVERDUE
  • paid_at TIMESTAMPTZ
  • payment_reference VARCHAR(50)
  • overdue_days INTEGER DEFAULT 0
  • penalty_amount DECIMAL(18,4) DEFAULT 0
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, settlement_status), (due_date), (financier_id)

TReDS Business Rules

  • BR-TREDS-001: Invoice must be 3-way matched before TReDS upload
  • BR-TREDS-002: Buyer must accept/reject within 48 hours (auto-accept if no action)
  • BR-TREDS-003: Only MSME-registered vendors eligible for TReDS
  • BR-TREDS-004: Settlement must occur within 45 days of invoice date (MSMED Act)
  • BR-TREDS-005: Penalty interest applicable for overdue payments

3. GeM Integration (Government e-Marketplace)

GeM is the national procurement portal for government entities. Integration enables sellers to list products, participate in bids, and sync orders with ProKure for fulfillment tracking.

GeM Order Sync Flow
====================

GeM Portal                              ProKure                              Vendor System
    |                                       |                                      |
    |--- Webhook: New Catalog Request ----> |                                      |
    |                                       |--- Create/Update Catalog ----------> |
    |                                       |    (gem_catalogs)                    |
    | <-- Catalog Published ---------------- |                                      |
    |                                       |                                      |
    |--- Webhook: Bid Invitation ---------> |                                      |
    |                                       |--- Create gem_bids Record ---------> |
    |                                       |                                      |
    | <-- Bid Submission ------------------- |                                      |
    |                                       |                                      |
    |--- Webhook: Order Placed -----------> |                                      |
    |                                       |--- Create gem_orders --------------> |
    |                                       |--- Create internal PO --------------> |
    |                                       |                                      |
    |                                       |--- Sync Fulfillment Status --------> |
    | <-- ASN/Delivery Update -------------- |                                      |
    |                                       |                                      |
    | <-- Invoice Upload (e-Invoice) ------- |                                      |

GeM Database Schema

regulatory.gem_registrations

Seller registration details with GeM portal.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • company_id UUID FK NOT NULL
  • gem_seller_id VARCHAR(50) NOT NULL — GeM-assigned seller ID
  • gstin VARCHAR(15) NOT NULL
  • pan VARCHAR(10) NOT NULL
  • udyam_number VARCHAR(20)
  • registration_status VARCHAR(20) NOT NULL — PENDING, ACTIVE, SUSPENDED
  • seller_categories JSONB — authorized product categories
  • seller_rating DECIMAL(3,2) — GeM seller rating (1-5)
  • total_gem_orders INTEGER DEFAULT 0
  • total_gem_value DECIMAL(18,4) DEFAULT 0
  • api_credentials JSONB — encrypted API keys
  • webhook_url VARCHAR(500)
  • last_synced_at TIMESTAMPTZ
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id), (gem_seller_id), (gstin)

regulatory.gem_catalogs

Product catalogs listed on GeM with pricing and availability.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • gem_registration_id UUID FK NOT NULL
  • material_id UUID FK NOT NULL — internal product reference
  • gem_product_id VARCHAR(50) — GeM-assigned product ID
  • gem_category_id VARCHAR(20) NOT NULL
  • gem_category_name VARCHAR(200) — DENORM
  • product_name VARCHAR(200) NOT NULL
  • product_description TEXT
  • specifications JSONB — technical specs
  • unit_price DECIMAL(18,4) NOT NULL
  • currency_code VARCHAR(3) DEFAULT 'INR'
  • min_order_qty DECIMAL(18,4) DEFAULT 1
  • max_order_qty DECIMAL(18,4)
  • delivery_days INTEGER NOT NULL — promised delivery time
  • hsn_code VARCHAR(10)
  • gst_rate DECIMAL(5,2)
  • catalog_status VARCHAR(20) NOT NULL — DRAFT, PENDING, PUBLISHED, SUSPENDED
  • published_at TIMESTAMPTZ
  • valid_from DATE
  • valid_until DATE
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, catalog_status), (gem_product_id), (material_id), (gem_category_id)

regulatory.gem_bids

Bid participation in GeM tenders and auctions.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • gem_registration_id UUID FK NOT NULL
  • gem_bid_id VARCHAR(50) NOT NULL — GeM tender/bid reference
  • bid_type VARCHAR(20) NOT NULL — L1, QCBS, RATE_CONTRACT, CUSTOM
  • buyer_organization VARCHAR(200) NOT NULL — govt department name
  • buyer_location VARCHAR(200)
  • bid_title VARCHAR(500) NOT NULL
  • bid_description TEXT
  • quantity_required DECIMAL(18,4)
  • estimated_value DECIMAL(18,4)
  • bid_submission_deadline TIMESTAMPTZ NOT NULL
  • technical_evaluation_date DATE
  • financial_opening_date DATE
  • emd_amount DECIMAL(18,4) — Earnest Money Deposit
  • emd_submitted BOOLEAN DEFAULT FALSE
  • our_bid_amount DECIMAL(18,4)
  • our_bid_submitted_at TIMESTAMPTZ
  • bid_status VARCHAR(20) NOT NULL — INVITED, SUBMITTED, TECHNICAL_PASS, TECHNICAL_FAIL, WON, LOST
  • is_l1 BOOLEAN — won as L1 bidder
  • award_date DATE
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, bid_status), (gem_bid_id), (bid_submission_deadline)

regulatory.gem_orders

Orders received through GeM portal with fulfillment tracking.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • gem_registration_id UUID FK NOT NULL
  • gem_order_id VARCHAR(50) NOT NULL UNIQUE — GeM order reference
  • gem_bid_id UUID FK — if from a bid
  • internal_po_id UUID FK — linked ProKure PO
  • internal_po_number VARCHAR(50) — DENORM
  • buyer_organization VARCHAR(200) NOT NULL
  • buyer_gstin VARCHAR(15)
  • consignee_name VARCHAR(200)
  • consignee_address TEXT
  • order_date DATE NOT NULL
  • order_amount DECIMAL(18,4) NOT NULL
  • gst_amount DECIMAL(18,4)
  • total_amount DECIMAL(18,4) NOT NULL
  • expected_delivery_date DATE NOT NULL
  • order_status VARCHAR(20) NOT NULL — RECEIVED, ACCEPTED, SHIPPED, DELIVERED, COMPLETED
  • shipment_tracking_number VARCHAR(100)
  • delivered_at TIMESTAMPTZ
  • crac_generated BOOLEAN DEFAULT FALSE — Consignee Receipt and Acceptance Certificate
  • crac_date DATE
  • payment_status VARCHAR(20) — PENDING, PARTIAL, PAID
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, order_status), (gem_order_id), (internal_po_id), (buyer_organization)

regulatory.gem_order_items

Line items for GeM orders.

  • id UUID PK DEFAULT gen_random_uuid()
  • gem_order_id UUID FK NOT NULL
  • gem_catalog_id UUID FK — linked catalog item
  • material_id UUID FK — internal product
  • item_description VARCHAR(500) NOT NULL
  • hsn_code VARCHAR(10)
  • quantity DECIMAL(18,4) NOT NULL
  • uom VARCHAR(20) NOT NULL
  • unit_price DECIMAL(18,4) NOT NULL
  • gst_rate DECIMAL(5,2)
  • gst_amount DECIMAL(18,4)
  • line_total DECIMAL(18,4) NOT NULL
  • delivered_qty DECIMAL(18,4) DEFAULT 0
  • accepted_qty DECIMAL(18,4) DEFAULT 0
  • created_at TIMESTAMPTZ DEFAULT NOW()

Indexes: (gem_order_id), (material_id)

regulatory.gem_sync_mappings

Mapping between GeM categories/products and internal master data.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • mapping_type VARCHAR(20) NOT NULL — CATEGORY, PRODUCT, UOM
  • gem_code VARCHAR(50) NOT NULL
  • gem_name VARCHAR(200)
  • internal_id UUID NOT NULL
  • internal_code VARCHAR(50) — DENORM
  • internal_name VARCHAR(200) — DENORM
  • is_active BOOLEAN DEFAULT TRUE
  • created_at TIMESTAMPTZ DEFAULT NOW()

Indexes: (tenant_id, mapping_type, gem_code), (internal_id)

GeM Business Rules

  • BR-GEM-001: All govt orders must be fulfilled through GeM if product is listed
  • BR-GEM-002: Catalog prices must be at market rates (GeM price monitoring)
  • BR-GEM-003: Delivery must be within committed timeline or penalties apply
  • BR-GEM-004: E-invoice mandatory for all GeM orders
  • BR-GEM-005: CRAC required before payment processing
  • BR-GEM-006: EMD submission required for bids above threshold

4. E-Invoicing IRP Integration

E-Invoicing through Invoice Registration Portal (IRP) is mandatory for GST compliance. Each invoice receives a unique Invoice Reference Number (IRN) and QR code from the government portal.

E-Invoice Generation Flow
==========================

ProKure                              IRP (Invoice Registration Portal)              GST Portal
    |                                              |                                    |
    |--- Generate Invoice JSON ----------------->  |                                    |
    |   (Schema: e-Invoice v1.1)                   |                                    |
    |                                              |                                    |
    |                                              |--- Validate JSON Structure ------> |
    |                                              |--- Validate GSTIN ----------------> |
    |                                              |--- Validate HSN Codes ------------> |
    |                                              |                                    |
    | <-- IRN + Signed QR + Ack No --------------- |                                    |
    |                                              |                                    |
    |--- Store IRN in einvoice_irn_details ------> |                                    |
    |--- Update invoice with IRN, QR ------------- |                                    |
    |                                              |                                    |
    |--- Print Invoice with QR Code -------------- |                                    |
    |                                              |                                    |
    |                                              |--- Auto-populate GSTR-1 --------> |

E-Invoicing Database Schema

regulatory.einvoice_registrations

Company registration with E-Invoice IRP for API access.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • company_id UUID FK NOT NULL
  • gstin VARCHAR(15) NOT NULL
  • legal_name VARCHAR(200) NOT NULL
  • trade_name VARCHAR(200)
  • irp_username VARCHAR(50)
  • irp_credentials JSONB — encrypted API credentials
  • auth_token TEXT — current session token
  • token_expiry TIMESTAMPTZ
  • sandbox_mode BOOLEAN DEFAULT FALSE
  • auto_generate BOOLEAN DEFAULT TRUE — auto-generate on invoice creation
  • registration_status VARCHAR(20) NOT NULL — PENDING, ACTIVE, SUSPENDED
  • last_synced_at TIMESTAMPTZ
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id), (gstin), (company_id)

regulatory.einvoice_submissions

E-Invoice submission attempts with status tracking.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • einvoice_registration_id UUID FK NOT NULL
  • invoice_id UUID FK NOT NULL
  • invoice_number VARCHAR(50) NOT NULL — DENORM
  • invoice_date DATE NOT NULL — DENORM
  • invoice_type VARCHAR(10) NOT NULL — INV, CRN, DBN (Invoice, Credit Note, Debit Note)
  • document_type VARCHAR(10) NOT NULL — B2B, B2C, SEZWP, SEZWOP, EXPWP, EXPWOP
  • supplier_gstin VARCHAR(15) NOT NULL
  • recipient_gstin VARCHAR(15)
  • invoice_value DECIMAL(18,4) NOT NULL
  • taxable_value DECIMAL(18,4) NOT NULL
  • total_gst DECIMAL(18,4) NOT NULL
  • json_payload JSONB NOT NULL — full e-invoice JSON
  • submission_status VARCHAR(20) NOT NULL — PENDING, SUBMITTED, SUCCESS, FAILED, CANCELLED
  • submitted_at TIMESTAMPTZ
  • irn VARCHAR(64) — Invoice Reference Number (64 chars)
  • ack_number VARCHAR(20) — Acknowledgement number
  • ack_date TIMESTAMPTZ
  • error_code VARCHAR(20)
  • error_message TEXT
  • retry_count INTEGER DEFAULT 0
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, submission_status), (invoice_id), (irn), (supplier_gstin, invoice_date)

regulatory.einvoice_irn_details

Successfully generated IRN details with QR code and signed invoice.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • einvoice_submission_id UUID FK NOT NULL UNIQUE
  • invoice_id UUID FK NOT NULL
  • irn VARCHAR(64) NOT NULL UNIQUE
  • ack_number VARCHAR(20) NOT NULL
  • ack_date TIMESTAMPTZ NOT NULL
  • signed_invoice TEXT NOT NULL — digitally signed JSON
  • signed_qr_code TEXT NOT NULL — QR code data
  • qr_code_image TEXT — Base64 encoded QR image
  • irp_response JSONB NOT NULL — full IRP response
  • valid_from TIMESTAMPTZ NOT NULL
  • is_cancelled BOOLEAN DEFAULT FALSE
  • cancel_reason VARCHAR(200)
  • cancelled_at TIMESTAMPTZ
  • created_at TIMESTAMPTZ DEFAULT NOW()

Indexes: (irn), (invoice_id), (tenant_id, is_cancelled)

regulatory.einvoice_cancellations

E-Invoice cancellation requests and approvals.

  • id UUID PK DEFAULT gen_random_uuid()
  • tenant_id UUID FK NOT NULL
  • irn_detail_id UUID FK NOT NULL
  • irn VARCHAR(64) NOT NULL
  • cancel_reason_code VARCHAR(10) NOT NULL — 1=Duplicate, 2=Data Entry Error, 3=Order Cancelled, 4=Others
  • cancel_reason VARCHAR(200) NOT NULL
  • requested_by UUID FK NOT NULL
  • requested_by_name VARCHAR(150) — DENORM
  • requested_at TIMESTAMPTZ NOT NULL
  • cancellation_status VARCHAR(20) NOT NULL — PENDING, APPROVED, REJECTED, SUBMITTED, SUCCESS, FAILED
  • approved_by UUID FK
  • approved_at TIMESTAMPTZ
  • irp_response JSONB
  • error_message TEXT
  • created_at TIMESTAMPTZ DEFAULT NOW()
  • updated_at TIMESTAMPTZ

Indexes: (tenant_id, cancellation_status), (irn), (irn_detail_id)

Note: E-Invoice cancellation only allowed within 24 hours of generation

E-Invoicing Business Rules

  • BR-EINV-001: E-Invoice mandatory for B2B invoices (turnover > ₹5 Cr)
  • BR-EINV-002: IRN must be generated within 24 hours of invoice date
  • BR-EINV-003: Cancellation only allowed within 24 hours of IRN generation
  • BR-EINV-004: Credit/Debit notes also require IRN
  • BR-EINV-005: QR code must be printed on physical invoice copy
  • BR-EINV-006: HSN codes mandatory (4-digit for turnover > ₹5 Cr, 6-digit for > ₹1.5 Cr, 8-digit for > ₹5 Cr from April 2025)
  • BR-EINV-007: Failed submissions must be retried with exponential backoff

5. MongoDB Audit Collections

MongoDB collections for API interaction logs and audit trails. Used for debugging, compliance reporting, and analytics.

treds_transaction_logs

All TReDS API interactions including uploads, acceptances, and settlements.

  • _id ObjectId PK
  • tenant_id UUID indexed
  • platform String — RXIL, M1XCHANGE, INVOICEMART
  • operation String — UPLOAD, ACCEPT, REJECT, FACTORING_REQUEST, SETTLEMENT
  • entity_type String — INVOICE, FACTORING, SETTLEMENT
  • entity_id UUID
  • request_payload Object — API request
  • response_payload Object — API response
  • http_status Number
  • success Boolean
  • error_details Object
  • latency_ms Number
  • user_id UUID
  • ip_address String
  • timestamp Date indexed
  • ttl_expiry Date — 7-year retention (compliance)

gem_sync_logs

GeM catalog sync, bid submissions, and order webhook logs.

  • _id ObjectId PK
  • tenant_id UUID indexed
  • sync_type String — CATALOG_PUSH, CATALOG_PULL, BID_SUBMIT, ORDER_WEBHOOK, STATUS_UPDATE
  • gem_entity_type String — CATALOG, BID, ORDER
  • gem_entity_id String
  • internal_entity_id UUID
  • direction String — INBOUND, OUTBOUND
  • request_payload Object
  • response_payload Object
  • sync_status String — SUCCESS, FAILED, PARTIAL
  • error_details Object
  • records_processed Number
  • duration_ms Number
  • timestamp Date indexed
  • ttl_expiry Date — 3-year retention

einvoice_api_logs

E-Invoice IRP API calls for IRN generation and cancellation.

  • _id ObjectId PK
  • tenant_id UUID indexed
  • gstin String indexed
  • operation String — GENERATE_IRN, CANCEL_IRN, GET_IRN_BY_DOC, GET_GSTIN_DETAILS
  • invoice_id UUID
  • invoice_number String
  • irn String
  • request_payload Object — sanitized (no sensitive data)
  • response_payload Object — includes IRN if success
  • http_status Number
  • irp_error_code String
  • irp_error_message String
  • success Boolean indexed
  • latency_ms Number
  • retry_attempt Number
  • user_id UUID
  • timestamp Date indexed
  • ttl_expiry Date — 7-year retention (tax compliance)

6. API Endpoints

RESTful API endpoints for regulatory integrations.

TReDS APIs

MethodEndpointDescription
GET/api/treds/registrationsList TReDS registrations
POST/api/treds/invoices/uploadUpload invoice to TReDS
POST/api/treds/invoices/{id}/acceptAccept invoice for factoring
POST/api/treds/invoices/{id}/rejectReject invoice
GET/api/treds/factoring-requests/{invoiceId}Get factoring bids
GET/api/treds/settlementsList pending settlements

GeM APIs

MethodEndpointDescription
GET/api/gem/catalogsList GeM catalogs
POST/api/gem/catalogsCreate/publish catalog item
GET/api/gem/bidsList bid invitations
POST/api/gem/bids/{id}/submitSubmit bid response
GET/api/gem/ordersList GeM orders
POST/api/gem/orders/{id}/acceptAccept order
PUT/api/gem/orders/{id}/fulfillmentUpdate fulfillment status
POST/api/gem/webhooksGeM webhook receiver

E-Invoicing APIs

MethodEndpointDescription
POST/api/einvoice/generateGenerate IRN for invoice
GET/api/einvoice/{invoiceId}Get IRN details
GET/api/einvoice/irn/{irn}Lookup by IRN
POST/api/einvoice/{irn}/cancelRequest IRN cancellation
GET/api/einvoice/pendingList invoices pending IRN
POST/api/einvoice/bulk-generateBulk IRN generation

7. Background Jobs

Scheduled jobs for regulatory integration processing.

JobScheduleAction
TReDS Invoice UploadEvery 15 minsUpload matched invoices to TReDS
TReDS Acceptance CheckEvery hourCheck acceptance status, auto-accept if 48h passed
TReDS Settlement ReminderDaily (9 AM)Alert for upcoming settlements
GeM Catalog SyncEvery 6 hoursSync catalog prices and availability
GeM Bid MonitorEvery 30 minsCheck for new bid invitations
GeM Order SyncEvery 15 minsSync order status updates
E-Invoice Batch GenerateEvery 5 minsGenerate IRN for pending invoices
E-Invoice Retry FailedEvery 30 minsRetry failed IRN generations
E-Invoice Token RefreshEvery 30 minsRefresh IRP auth tokens before expiry
Compliance ReportMonthly (1st)Generate MSME compliance report