2.2 KiB
2.2 KiB
Dealer Integration Implementation Status
This document summarizes the changes made to integrate the external Royal Enfield Dealer API and implement the dealer validation logic during request creation.
Completed Work
1. External Dealer API Integration
- Service:
DealerExternalServiceinsrc/services/dealerExternal.service.ts- Implemented
getDealerByCodeto fetch data fromhttps://api-uat2.royalenfield.com/DealerMaster. - Returns real-time GSTIN, Address, and location details.
- Implemented
- Controller & Routes: Integrated under
/api/v1/dealers-external/search/:dealerCode. - Enrichment:
DealerService.getDealerByCodenow automatically merges this external data into the system'sDealerInfo, benefiting PWC and PDF generation services.
2. Dealer Validation & Field Mapping Fix
- Strategic Mapping: Based on requirement, all dealer codes are now mapped against the
employeeNumberfield (HR ID) in theUsermodel, notemployeeId. - User Enrichment Service:
validateDealerUser(dealerCode)now searches byemployeeNumber. - SSO Alignment:
AuthService.tsnow extractsdealer_codefrom the authentication response and persists it toemployeeNumber. - Dealer Service:
getDealerByCodeuses jobTitle-based validation against theUsertable as the primary lookup.
3. Claim Workflow Integration
- Dealer Claim Service:
createClaimRequestvalidates the dealer immediately and overrides approver steps 1 and 4 with the validated user. - Workflow Controller: Enforces dealer validation for all
DEALER CLAIMtemplates and any request containing adealerCode.
4. E-Invoice & PDF Alignment
- PWC Integration:
generateSignedInvoicenow uses the enrichedDealerInfocontaining the correct external GSTIN and state code. - Invoice PDF:
PdfServicecorrectly displays the external dealer name, GSTIN, and POS from the source of truth.
Conclusion
All integrated components have been verified via test scripts and end-to-end flow analysis. The dependency on the local dealers table has been successfully minimized, and the system now relies on the User table and External API as the primary sources of dealer information.