stage transition issue resolved

This commit is contained in:
laxman h 2026-04-28 13:12:20 +05:30
parent b6938abc7c
commit ede68caefc
7 changed files with 2390 additions and 417 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Royal Enfield Onboarding</title> <title>Royal Enfield Onboarding</title>
<script type="module" crossorigin src="/assets/index-CAe70IkM.js"></script> <script type="module" crossorigin src="/assets/index-C_7C7ZNJ.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DkEVuJwH.css"> <link rel="stylesheet" crossorigin href="/assets/index-COwSK6pX.css">
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,163 @@
# RE Dealer System - Test Coverage Tracker
This tracker is maintained separately from the test stories document.
Update module by module as execution progresses.
---
## Status Legend
- `Not Started` - Test story not executed yet
- `In Progress` - Execution started but not finalized
- `Executed` - Execution completed
- `Blocked` - Cannot execute due to dependency/environment issue
Result values:
- `Pass`
- `Fail`
- `NA` (Not applicable or not executed yet)
---
## Overall Coverage
| Metric | Count |
|---|---:|
| Total Test Stories | 61 |
| Executed | 0 |
| Passed | 0 |
| Failed | 0 |
| Blocked | 0 |
| Remaining | 61 |
---
## Module Summary
| Module | Total | Executed | Passed | Failed | Blocked | Remaining |
|---|---:|---:|---:|---:|---:|---:|
| Module 1 - Dealer Onboarding | 22 | 0 | 0 | 0 | 0 | 22 |
| Module 2 - Dealer Resignation | 9 | 0 | 0 | 0 | 0 | 9 |
| Module 3 - Dealer Termination | 12 | 0 | 0 | 0 | 0 | 12 |
| Module 4 - Constitutional Change | 3 | 0 | 0 | 0 | 0 | 3 |
| Module 5 - Dealer Relocation | 3 | 0 | 0 | 0 | 0 | 3 |
| Module 6 - Full and Final (F&F) Settlement | 6 | 0 | 0 | 0 | 0 | 6 |
| Module 7 - Finance Dashboard | 2 | 0 | 0 | 0 | 0 | 2 |
| Module 8 - Admin and System Configuration | 4 | 0 | 0 | 0 | 0 | 4 |
---
## Module 1 - Dealer Onboarding
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 1.1.1 | Applicant Submits Application (Opportunity Location) | Not Started | NA | | | |
| 1.1.2 | Applicant Submits Application (Non-Opportunity Location) | Not Started | NA | | | |
| 1.1.3 | Application Submission Validation Failure | Not Started | NA | | | |
| 1.2.1 | Applicant Completes Questionnaire | Not Started | NA | | | |
| 1.3.1 | DD-Admin Shortlists Application | Not Started | NA | | | |
| 1.3.2 | DD-Admin Archives Application | Not Started | NA | | | |
| 1.4.1 | DD-Admin Schedules Interview (Level 1) | Not Started | NA | | | |
| 1.4.2 | DD-ZM + RBM Fill KT Matrix and Feedback (Level 1) | Not Started | NA | | | |
| 1.4.3 | Level 2 Evaluation (DD-Lead + ZBH) | Not Started | NA | | | |
| 1.4.4 | Level 3 Final Evaluation and AI Summary (NBH + DD-Head) | Not Started | NA | | | |
| 1.5.1 | FDD Partner Submits Due Diligence Report | Not Started | NA | | | |
| 1.5.2 | Finance Team Reviews FDD Report | Not Started | NA | | | |
| 1.6.1 | DD-Admin Triggers LOI Document Request | Not Started | NA | | | |
| 1.6.2 | Security Deposit Validation | Not Started | NA | | | |
| 1.6.3 | LOI Approval Chain (Finance -> DD-Head -> NBH) | Not Started | NA | | | |
| 1.6.4 | LOI Issuance to Applicant | Not Started | NA | | | |
| 1.7.1 | DD-Admin Triggers Dealer Code Creation | Not Started | NA | | | |
| 1.8.1 | Architectural Work Assignment and Completion | Not Started | NA | | | |
| 1.8.2 | Statutory Document Collection and Verification | Not Started | NA | | | |
| 1.9.1 | LOA Approval and Issuance | Not Started | NA | | | |
| 1.10.1 | EOR Completion by Functional Teams | Not Started | NA | | | |
| 1.11.1 | Dealership Inauguration and Closure | Not Started | NA | | | |
---
## Module 2 - Dealer Resignation
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 2.1 | Dealer Initiates Resignation via Portal | Not Started | NA | | | |
| 2.2 | DD-ASM Reviews and Forwards Resignation | Not Started | NA | | | |
| 2.3 | RBM + DD-ZM Joint Evaluation | Not Started | NA | | | |
| 2.4 | ZBH Review | Not Started | NA | | | |
| 2.5 | DD-Lead Review and Presentation | Not Started | NA | | | |
| 2.6 | NBH Final Approval | Not Started | NA | | | |
| 2.7 | Legal Issues Resignation Acceptance Letter | Not Started | NA | | | |
| 2.8 | DD-Admin Closure and F&F Trigger | Not Started | NA | | | |
| 2.9 | Dealer Withdraws Resignation Request | Not Started | NA | | | |
---
## Module 3 - Dealer Termination
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 3.1 | ASM Creates Termination Request | Not Started | NA | | | |
| 3.2 | RBM + DD-ZM Review | Not Started | NA | | | |
| 3.3 | ZBH Review | Not Started | NA | | | |
| 3.4 | DD-Lead Review and Legal Assignment | Not Started | NA | | | |
| 3.5 | Legal Verification | Not Started | NA | | | |
| 3.6 | DD-Head Review -> NBH Evaluation | Not Started | NA | | | |
| 3.7 | Show Cause Notice (SCN) Issuance | Not Started | NA | | | |
| 3.8 | Joint Review of Dealer Response -> NBH Final Decision | Not Started | NA | | | |
| 3.9 | CEO and CCO Final Authorization | Not Started | NA | | | |
| 3.10 | Legal Issues Termination Letter | Not Started | NA | | | |
| 3.11 | DD-Admin Communication and F&F Trigger | Not Started | NA | | | |
| 3.12 | Immediate Termination (Unethical Practice) | Not Started | NA | | | |
---
## Module 4 - Constitutional Change
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 4.1 | Dealer Initiates Constitutional Change Request | Not Started | NA | | | |
| 4.2 | Multi-Level Review and Approval | Not Started | NA | | | |
| 4.3 | Legal Validation and Master Data Update | Not Started | NA | | | |
---
## Module 5 - Dealer Relocation
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 5.1 | Dealer Initiates Relocation Request | Not Started | NA | | | |
| 5.2 | Multi-Level Review and Approval | Not Started | NA | | | |
| 5.3 | Final Approval and Master Data Update | Not Started | NA | | | |
---
## Module 6 - Full and Final (F&F) Settlement
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 6.1 | F&F Case Initiation | Not Started | NA | | | |
| 6.2 | Department Clearance Submission (All 16 Departments) | Not Started | NA | | | |
| 6.3 | Finance Consolidates F&F Summary | Not Started | NA | | | |
| 6.4 | Dealer Discussion and Acknowledgment | Not Started | NA | | | |
| 6.5 | Final Finance Approval and Payment Processing | Not Started | NA | | | |
| 6.6 | F&F Closure | Not Started | NA | | | |
---
## Module 7 - Finance Dashboard
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 7.1 | Security Deposit Verification (Onboarding) | Not Started | NA | | | |
| 7.2 | Finance Flags Payment Discrepancy | Not Started | NA | | | |
---
## Module 8 - Admin and System Configuration
| Test Story ID | Title | Execution Status | Result | Owner | Last Updated | Notes |
|---|---|---|---|---|---|---|
| 8.1.1 | Admin Configures SLA for a Workflow Activity | Not Started | NA | | | |
| 8.1.2 | SLA Breach and Escalation Flow | Not Started | NA | | | |
| 8.2.1 | Admin Creates Email Template | Not Started | NA | | | |
| 8.3.1 | Admin Creates New Opportunity Window | Not Started | NA | | | |

View File

@ -45,6 +45,24 @@ const configs = [
{ documentType: 'First Fill Receipt', stageCode: 'LOA Approval', allowedRoles: [ROLES.DEALER, ROLES.FINANCE, ROLES.DD_HEAD, ROLES.NBH, ROLES.SUPER_ADMIN], isMandatory: true }, { documentType: 'First Fill Receipt', stageCode: 'LOA Approval', allowedRoles: [ROLES.DEALER, ROLES.FINANCE, ROLES.DD_HEAD, ROLES.NBH, ROLES.SUPER_ADMIN], isMandatory: true },
{ documentType: 'LOI Acknowledgement Copy', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES }, { documentType: 'LOI Acknowledgement Copy', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES },
{ documentType: 'Nodal Agreement', stageCode: 'LOI Approval', allowedRoles: [ROLES.LEGAL_ADMIN, ROLES.DEALER, ROLES.SUPER_ADMIN] }, { documentType: 'Nodal Agreement', stageCode: 'LOI Approval', allowedRoles: [ROLES.LEGAL_ADMIN, ROLES.DEALER, ROLES.SUPER_ADMIN] },
{ documentType: 'DIP Booklet', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Profile Sheet', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Dealership Application Form', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Interview Feedback Forms', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Land Selection Criteria Sheet', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Logic Note and Comparative Logic Note', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Zonal Evaluation Form', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Authorization Letter', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'City Map (PPT)', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Proposed Location Photos (minimum 20, PPT)', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Layout Drawings (PPT)', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Viability Sheet', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Project Plan', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Self-signed PAN/Aadhaar of all partners', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'CIBIL Reports of all partners', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Dealership Name & Address Email from RBM', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Rental / Lease Agreement or Consent Letter from Landlord', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
{ documentType: 'Security Deposit Proof', stageCode: 'LOI Issue', allowedRoles: ALL_ROLES, isMandatory: true, module: 'ONBOARDING' },
// Architecture Team Documents // Architecture Team Documents
{ documentType: 'Architecture Assignment Document', stageCode: 'Architecture Team Assigned', allowedRoles: [ROLES.ARCHITECTURE, ROLES.SUPER_ADMIN, ROLES.DD_ADMIN] }, { documentType: 'Architecture Assignment Document', stageCode: 'Architecture Team Assigned', allowedRoles: [ROLES.ARCHITECTURE, ROLES.SUPER_ADMIN, ROLES.DD_ADMIN] },

View File

@ -264,312 +264,312 @@ async function triggerWorkflow() {
}, leadToken); }, leadToken);
const interviewId2 = intv2Response.data.id; const interviewId2 = intv2Response.data.id;
// log(5.1, 'DD-Lead Giving Feedback...'); log(5.1, 'DD-Lead Giving Feedback...');
// await apiRequest('/assessment/level2-feedback', 'POST', { await apiRequest('/assessment/level2-feedback', 'POST', {
// interviewId: interviewId2, interviewId: interviewId2,
// overallScore: 9.5, overallScore: 9.5,
// feedbackItems: [ feedbackItems: [
// { type: 'Strategic Vision', comments: 'Excellent strategic planning.' }, { type: 'Strategic Vision', comments: 'Excellent strategic planning.' },
// { type: 'Management Capabilities', comments: 'Strong team leadership.' }, { type: 'Management Capabilities', comments: 'Strong team leadership.' },
// { type: 'Operational Understanding', comments: 'Knows the local market well.' } { type: 'Operational Understanding', comments: 'Knows the local market well.' }
// ], ],
// recommendation: 'Selected' recommendation: 'Selected'
// }, leadToken); }, leadToken);
// log(5.15, 'ZBH Giving Feedback...'); log(5.15, 'ZBH Giving Feedback...');
// const zbhToken = await login(zbhUser.email); const zbhToken = await login(zbhUser.email);
// await apiRequest('/assessment/level2-feedback', 'POST', { await apiRequest('/assessment/level2-feedback', 'POST', {
// interviewId: interviewId2, interviewId: interviewId2,
// overallScore: 9.0, overallScore: 9.0,
// feedbackItems: [ feedbackItems: [
// { type: 'Strategic Vision', comments: 'Good alignment with brand.' }, { type: 'Strategic Vision', comments: 'Good alignment with brand.' },
// { type: 'Key Strengths', comments: 'Great location proposed.' }, { type: 'Key Strengths', comments: 'Great location proposed.' },
// { type: 'Areas of Concern', comments: 'None at this time.' } { type: 'Areas of Concern', comments: 'None at this time.' }
// ], ],
// recommendation: 'Selected' recommendation: 'Selected'
// }, zbhToken); }, zbhToken);
// log(5.2, 'DD-Lead Finalizing Level 2 Decision...'); log(5.2, 'DD-Lead Finalizing Level 2 Decision...');
// await apiRequest('/assessment/decision', 'POST', { await apiRequest('/assessment/decision', 'POST', {
// interviewId: interviewId2, interviewId: interviewId2,
// decision: 'Approved', decision: 'Approved',
// remarks: 'Cleared Level 2' remarks: 'Cleared Level 2'
// }, leadToken); }, leadToken);
// log(5, 'Level 2 Complete.'); log(5, 'Level 2 Complete.');
// await delay(); await delay();
// // 6. LEVEL-3 INTERVIEW // 6. LEVEL-3 INTERVIEW
// log(6, 'Scheduling Level 3 Interview...'); log(6, 'Scheduling Level 3 Interview...');
// const headUser = users.data.find(u => u.email === EMAILS.DD_HEAD); const headUser = users.data.find(u => u.email === EMAILS.DD_HEAD);
// const nbhUser = users.data.find(u => u.email === EMAILS.NBH); const nbhUser = users.data.find(u => u.email === EMAILS.NBH);
// const intv3Response = await apiRequest('/assessment/interviews', 'POST', { const intv3Response = await apiRequest('/assessment/interviews', 'POST', {
// applicationId: applicationUUID, applicationId: applicationUUID,
// level: 3, level: 3,
// scheduledAt: new Date(Date.now() + 259200000).toISOString(), scheduledAt: new Date(Date.now() + 259200000).toISOString(),
// type: 'In-Person', type: 'In-Person',
// location: 'HO', location: 'HO',
// participants: [headUser.id, nbhUser.id] participants: [headUser.id, nbhUser.id]
// }, leadToken); }, leadToken);
// const interviewId3 = intv3Response.data.id; const interviewId3 = intv3Response.data.id;
// log(6.1, 'NBH Giving Feedback...'); log(6.1, 'NBH Giving Feedback...');
// const nbhToken = await login(EMAILS.NBH); const nbhToken = await login(EMAILS.NBH);
// await apiRequest('/assessment/level2-feedback', 'POST', { await apiRequest('/assessment/level2-feedback', 'POST', {
// interviewId: interviewId3, interviewId: interviewId3,
// overallScore: 10, overallScore: 10,
// feedbackItems: [ feedbackItems: [
// { type: 'Business Vision & Strategy', comments: 'Highly recommended for this market.' }, { type: 'Business Vision & Strategy', comments: 'Highly recommended for this market.' },
// { type: 'Leadership & Decision Making', comments: 'Shows great potential.' } { type: 'Leadership & Decision Making', comments: 'Shows great potential.' }
// ], ],
// recommendation: 'Selected' recommendation: 'Selected'
// }, nbhToken); }, nbhToken);
// log(6.15, 'DD-Head Giving Feedback...'); log(6.15, 'DD-Head Giving Feedback...');
// const headToken = await login(EMAILS.DD_HEAD); const headToken = await login(EMAILS.DD_HEAD);
// await apiRequest('/assessment/level2-feedback', 'POST', { await apiRequest('/assessment/level2-feedback', 'POST', {
// interviewId: interviewId3, interviewId: interviewId3,
// overallScore: 9.5, overallScore: 9.5,
// feedbackItems: [ feedbackItems: [
// { type: 'Operational & Financial Readiness', comments: 'Financially sound.' }, { type: 'Operational & Financial Readiness', comments: 'Financially sound.' },
// { type: 'Brand Alignment', comments: 'Understands Royal Enfield ethos perfectly.' } { type: 'Brand Alignment', comments: 'Understands Royal Enfield ethos perfectly.' }
// ], ],
// recommendation: 'Selected' recommendation: 'Selected'
// }, headToken); }, headToken);
// log(6.2, 'Head Finalizing Level 3 Decision...'); log(6.2, 'Head Finalizing Level 3 Decision...');
// await apiRequest('/assessment/decision', 'POST', { await apiRequest('/assessment/decision', 'POST', {
// interviewId: interviewId3, interviewId: interviewId3,
// decision: 'Approved', decision: 'Approved',
// remarks: 'Cleared Level 3. Moving to FDD.' remarks: 'Cleared Level 3. Moving to FDD.'
// }, headToken); }, headToken);
// log(6, 'Level 3 Complete. Stage is now FDD Verification.'); log(6, 'Level 3 Complete. Stage is now FDD Verification.');
// await delay(); await delay();
// // 6.3 FDD ASSIGNMENT // 6.3 FDD ASSIGNMENT
// log(6.3, 'Admin Assigning Application to FDD Agency...'); log(6.3, 'Admin Assigning Application to FDD Agency...');
// const fddUser = users.data.find(u => u.email === EMAILS.FDD); const fddUser = users.data.find(u => u.email === EMAILS.FDD);
// await apiRequest('/fdd/assign', 'POST', { await apiRequest('/fdd/assign', 'POST', {
// applicationId: applicationUUID, applicationId: applicationUUID,
// assignedToAgency: fddUser.id assignedToAgency: fddUser.id
// }, adminToken); }, adminToken);
// log(6.3, 'FDD Agency assigned successfully.'); log(6.3, 'FDD Agency assigned successfully.');
// await delay(); await delay();
// // 7. FDD MILESTONE // 7. FDD MILESTONE
// log(7, 'FDD Agency Discovery & Report Upload...'); log(7, 'FDD Agency Discovery & Report Upload...');
// const fddToken = await login(EMAILS.FDD); const fddToken = await login(EMAILS.FDD);
// // FETCH ASSIGNMENT ID // FETCH ASSIGNMENT ID
// const assignmentRes = await apiRequest(`/fdd/${applicationUUID}`, 'GET', null, fddToken); const assignmentRes = await apiRequest(`/fdd/${applicationUUID}`, 'GET', null, fddToken);
// const assignmentId = assignmentRes.data.id; const assignmentId = assignmentRes.data.id;
// log(7, `Found Assignment ID: ${assignmentId}`); log(7, `Found Assignment ID: ${assignmentId}`);
// await apiRequest('/fdd/report', 'POST', { await apiRequest('/fdd/report', 'POST', {
// assignmentId, assignmentId,
// findings: 'Finance records clean.', findings: 'Finance records clean.',
// recommendation: 'Approved' recommendation: 'Approved'
// }, fddToken); }, fddToken);
// log(7.1, 'Admin Approving FDD Final Stage...'); log(7.1, 'Admin Approving FDD Final Stage...');
// await apiRequest('/assessment/stage-decision', 'POST', { await apiRequest('/assessment/stage-decision', 'POST', {
// applicationId: applicationUUID, applicationId: applicationUUID,
// stageCode: 'FDD_VERIFICATION', stageCode: 'FDD_VERIFICATION',
// decision: 'Approved', decision: 'Approved',
// remarks: 'FDD documents verified.' remarks: 'FDD documents verified.'
// }, adminToken); }, adminToken);
// log(7, 'FDD Milestone Complete.'); log(7, 'FDD Milestone Complete.');
// await delay(); await delay();
// log(7.4, 'Uploading mandatory documents prior to LOI generation...'); log(7.4, 'Uploading mandatory documents prior to LOI generation...');
// const requiredDocs = ['CIBIL Report', 'Proposed Site City Map', 'Bank Statement', 'GST Certificate', 'PAN Card']; const requiredDocs = ['CIBIL Report', 'Proposed Site City Map', 'Bank Statement', 'GST Certificate', 'PAN Card'];
// for (const doc of requiredDocs) { for (const doc of requiredDocs) {
// await mockUploadDocument(applicationUUID, adminToken, doc); await mockUploadDocument(applicationUUID, adminToken, doc);
// } }
// await delay(1000); await delay(1000);
// // 7.5 LOI APPROVAL // 7.5 LOI APPROVAL
// log(7.5, 'LOI Generation & Approval...'); log(7.5, 'LOI Generation & Approval...');
// const loiRes = await apiRequest('/loi/request', 'POST', { applicationId: applicationUUID }, adminToken); const loiRes = await apiRequest('/loi/request', 'POST', { applicationId: applicationUUID }, adminToken);
// const loiRequestId = loiRes.data.id; const loiRequestId = loiRes.data.id;
// // Head Approval // Head Approval
// await apiRequest(`/loi/request/${loiRequestId}/approve`, 'POST', { await apiRequest(`/loi/request/${loiRequestId}/approve`, 'POST', {
// action: 'Approved', action: 'Approved',
// remarks: 'Head Authorization for LOI' remarks: 'Head Authorization for LOI'
// }, headToken); }, headToken);
// // NBH Approval // NBH Approval
// await apiRequest(`/loi/request/${loiRequestId}/approve`, 'POST', { await apiRequest(`/loi/request/${loiRequestId}/approve`, 'POST', {
// action: 'Approved', action: 'Approved',
// remarks: 'NBH Authorization for LOI' remarks: 'NBH Authorization for LOI'
// }, nbhToken); }, nbhToken);
// log(7.5, 'LOI Milestone Complete.'); log(7.5, 'LOI Milestone Complete.');
// await delay(); await delay();
// // 8. PAYMENT GATE (SECURITY DEPOSIT FIRST AS PER CURRENT FLOW) // 8. PAYMENT GATE (SECURITY DEPOSIT FIRST AS PER CURRENT FLOW)
// log(8, 'Finance Verifying SECURITY_DEPOSIT to unlock LOI Issued...'); log(8, 'Finance Verifying SECURITY_DEPOSIT to unlock LOI Issued...');
// const financeToken = await login(EMAILS.FINANCE); const financeToken = await login(EMAILS.FINANCE);
// await apiRequest('/loa/security-deposit', 'POST', { await apiRequest('/loa/security-deposit', 'POST', {
// applicationId: applicationUUID, applicationId: applicationUUID,
// amount: 500000, amount: 500000,
// paymentReference: 'PAY-888999', paymentReference: 'PAY-888999',
// depositType: 'SECURITY_DEPOSIT', depositType: 'SECURITY_DEPOSIT',
// status: 'Verified' status: 'Verified'
// }, financeToken); }, financeToken);
// log(8, 'Security Deposit Verified.') log(8, 'Security Deposit Verified.')
// // 9. GENERATE DEALER CODES (align with backend gate: LOI Issued required) // 9. GENERATE DEALER CODES (align with backend gate: LOI Issued required)
// let statusBeforeCodeGen = await getApplicationStatus(applicationUUID, adminToken); let statusBeforeCodeGen = await getApplicationStatus(applicationUUID, adminToken);
// log(9, `Current status before code generation: ${statusBeforeCodeGen}`); log(9, `Current status before code generation: ${statusBeforeCodeGen}`);
// log(9, 'Ensuring mandatory PAN/GST/Bank fields before code generation...'); log(9, 'Ensuring mandatory PAN/GST/Bank fields before code generation...');
// await ensureMandatoryCodeGenFields(applicationUUID, adminToken); await ensureMandatoryCodeGenFields(applicationUUID, adminToken);
// await delay(300); await delay(300);
// if (statusBeforeCodeGen === 'Security Details') { if (statusBeforeCodeGen === 'Security Details') {
// log(9, 'Status is Security Details; re-verifying Security Deposit to move to LOI Issued...'); log(9, 'Status is Security Details; re-verifying Security Deposit to move to LOI Issued...');
// await apiRequest('/loa/security-deposit', 'POST', { await apiRequest('/loa/security-deposit', 'POST', {
// applicationId: applicationUUID, applicationId: applicationUUID,
// amount: 500000, amount: 500000,
// paymentReference: `PAY-RETRY-${Date.now()}`, paymentReference: `PAY-RETRY-${Date.now()}`,
// depositType: 'SECURITY_DEPOSIT', depositType: 'SECURITY_DEPOSIT',
// status: 'Verified' status: 'Verified'
// }, financeToken); }, financeToken);
// await delay(); await delay();
// statusBeforeCodeGen = await getApplicationStatus(applicationUUID, adminToken); statusBeforeCodeGen = await getApplicationStatus(applicationUUID, adminToken);
// log(9, `Status after re-verify: ${statusBeforeCodeGen}`); log(9, `Status after re-verify: ${statusBeforeCodeGen}`);
// } }
// // Current backend flow keeps app at "Security Details" until explicit admin transition. // Current backend flow keeps app at "Security Details" until explicit admin transition.
// if (statusBeforeCodeGen === 'Security Details') { if (statusBeforeCodeGen === 'Security Details') {
// log(9, 'Applying admin transition from Security Details -> LOI Issued...'); log(9, 'Applying admin transition from Security Details -> LOI Issued...');
// await apiRequest(`/onboarding/applications/${applicationUUID}/status`, 'PUT', { await apiRequest(`/onboarding/applications/${applicationUUID}/status`, 'PUT', {
// status: 'LOI Issued', status: 'LOI Issued',
// stage: 'LOI', stage: 'LOI',
// reason: 'E2E script alignment: unlock dealer code generation after Security Details checks.' reason: 'E2E script alignment: unlock dealer code generation after Security Details checks.'
// }, adminToken); }, adminToken);
// await delay(); await delay();
// statusBeforeCodeGen = await getApplicationStatus(applicationUUID, adminToken); statusBeforeCodeGen = await getApplicationStatus(applicationUUID, adminToken);
// log(9, `Status after admin transition: ${statusBeforeCodeGen}`); log(9, `Status after admin transition: ${statusBeforeCodeGen}`);
// } }
// if (statusBeforeCodeGen !== 'LOI Issued' && statusBeforeCodeGen !== 'Dealer Code Generation') { if (statusBeforeCodeGen !== 'LOI Issued' && statusBeforeCodeGen !== 'Dealer Code Generation') {
// throw new Error(`Cannot generate codes: expected LOI Issued/Dealer Code Generation, got ${statusBeforeCodeGen}`); throw new Error(`Cannot generate codes: expected LOI Issued/Dealer Code Generation, got ${statusBeforeCodeGen}`);
// } }
// log(9, 'Admin Generating SAP Dealer Codes...'); log(9, 'Admin Generating SAP Dealer Codes...');
// await apiRequest(`/onboarding/applications/${applicationUUID}/generate-codes`, 'POST', {}, adminToken); await apiRequest(`/onboarding/applications/${applicationUUID}/generate-codes`, 'POST', {}, adminToken);
// log(9, 'Dealer Codes Generated.'); log(9, 'Dealer Codes Generated.');
// await delay(); await delay();
// // 10. FIRST FILL (POST CODE-GENERATION) // 10. FIRST FILL (POST CODE-GENERATION)
// log(10, 'Finance Verifying FIRST FILL (₹15L)...'); log(10, 'Finance Verifying FIRST FILL (₹15L)...');
// await apiRequest('/loa/security-deposit', 'POST', { await apiRequest('/loa/security-deposit', 'POST', {
// applicationId: applicationUUID, applicationId: applicationUUID,
// amount: 1500000, amount: 1500000,
// paymentReference: 'PAY-FIN-999', paymentReference: 'PAY-FIN-999',
// depositType: 'FIRST_FILL', depositType: 'FIRST_FILL',
// status: 'Verified' status: 'Verified'
// }, financeToken); }, financeToken);
// log(10, 'Final Security Deposit Verified.'); log(10, 'Final Security Deposit Verified.');
// await delay(); await delay();
// // 11. ADMIN UPDATING STATUTORY & BANK DETAILS // 11. ADMIN UPDATING STATUTORY & BANK DETAILS
// log(11, 'Admin Updating Statutory & Bank Details for LOA Approval Gate...'); log(11, 'Admin Updating Statutory & Bank Details for LOA Approval Gate...');
// await apiRequest(`/onboarding/applications/${applicationUUID}`, 'PUT', { await apiRequest(`/onboarding/applications/${applicationUUID}`, 'PUT', {
// accountHolderName: 'Ramesh Automobiles Private Limited', accountHolderName: 'Ramesh Automobiles Private Limited',
// panNumber: 'ABCDE1234F', panNumber: 'ABCDE1234F',
// gstNumber: '07ABCDE1234F1Z5', gstNumber: '07ABCDE1234F1Z5',
// bankName: 'HDFC Bank', bankName: 'HDFC Bank',
// accountNumber: '50100223344556', accountNumber: '50100223344556',
// ifscCode: 'HDFC0001234' ifscCode: 'HDFC0001234'
// }, adminToken); }, adminToken);
// log(11, 'Statutory & Bank details updated.'); log(11, 'Statutory & Bank details updated.');
// await delay(); await delay();
// // 12. FINAL LOA APPROVAL // 12. FINAL LOA APPROVAL
// log(12, 'NBH & Head Approving Final LOA...'); log(12, 'NBH & Head Approving Final LOA...');
// const loaRes = await apiRequest('/loa/request', 'POST', { applicationId: applicationUUID }, headToken); const loaRes = await apiRequest('/loa/request', 'POST', { applicationId: applicationUUID }, headToken);
// const finalLoaRequestId = loaRes.data.id; const finalLoaRequestId = loaRes.data.id;
// await apiRequest(`/loa/request/${finalLoaRequestId}/approve`, 'POST', { await apiRequest(`/loa/request/${finalLoaRequestId}/approve`, 'POST', {
// action: 'Approved', action: 'Approved',
// remarks: 'Head Authorization (Level 1)' remarks: 'Head Authorization (Level 1)'
// }, headToken); }, headToken);
// await apiRequest(`/loa/request/${finalLoaRequestId}/approve`, 'POST', { await apiRequest(`/loa/request/${finalLoaRequestId}/approve`, 'POST', {
// action: 'Approved', action: 'Approved',
// remarks: 'NBH Approval (Level 2)' remarks: 'NBH Approval (Level 2)'
// }, nbhToken); }, nbhToken);
// log(12, 'LOA Fully Approved.'); log(12, 'LOA Fully Approved.');
// await delay(); await delay();
// // 13. EOR (EVIDENCE OF READINESS) CHECKLIST VERIFICATION // 13. EOR (EVIDENCE OF READINESS) CHECKLIST VERIFICATION
// log(13, 'Admin Initializing EOR Checklist (100% Readiness Requirement)...'); log(13, 'Admin Initializing EOR Checklist (100% Readiness Requirement)...');
// const eorInit = await apiRequest('/eor', 'POST', { applicationId: applicationUUID }, adminToken); const eorInit = await apiRequest('/eor', 'POST', { applicationId: applicationUUID }, adminToken);
// const checklistId = eorInit.data.id; const checklistId = eorInit.data.id;
// log(13, `EOR Checklist Created (ID: ${checklistId})`); log(13, `EOR Checklist Created (ID: ${checklistId})`);
// log(13.1, 'Auditor Verifying all 12 mandatory EOR items as COMPLIANT...'); log(13.1, 'Auditor Verifying all 12 mandatory EOR items as COMPLIANT...');
// const eorItems = [ const eorItems = [
// { itemType: 'Sales', description: 'Sales Standards' }, { itemType: 'Sales', description: 'Sales Standards' },
// { itemType: 'Service', description: 'Service & Spares' }, { itemType: 'Service', description: 'Service & Spares' },
// { itemType: 'IT', description: 'DMS infra' }, { itemType: 'IT', description: 'DMS infra' },
// { itemType: 'Training', description: 'Manpower Training' }, { itemType: 'Training', description: 'Manpower Training' },
// { itemType: 'Statutory', description: 'Trade certificate with test ride bikes registration' }, { itemType: 'Statutory', description: 'Trade certificate with test ride bikes registration' },
// { itemType: 'Statutory', description: 'GST certificate including Accessories & Apparels billing' }, { itemType: 'Statutory', description: 'GST certificate including Accessories & Apparels billing' },
// { itemType: 'Finance', description: 'Inventory Funding' }, { itemType: 'Finance', description: 'Inventory Funding' },
// { itemType: 'IT', description: 'Virtual code availability' }, { itemType: 'IT', description: 'Virtual code availability' },
// { itemType: 'Finance', description: 'Vendor payments' }, { itemType: 'Finance', description: 'Vendor payments' },
// { itemType: 'Marketing', description: 'Details for website submission' }, { itemType: 'Marketing', description: 'Details for website submission' },
// { itemType: 'Insurance', description: 'Infra Insurance both Showroom and Service center' }, { itemType: 'Insurance', description: 'Infra Insurance both Showroom and Service center' },
// { itemType: 'IT', description: 'Auto ordering' } { itemType: 'IT', description: 'Auto ordering' }
// ]; ];
// for (const item of eorItems) { for (const item of eorItems) {
// process.stdout.write(`.`); // Visual progress process.stdout.write(`.`); // Visual progress
// await apiRequest(`/eor/item/${checklistId}`, 'POST', { await apiRequest(`/eor/item/${checklistId}`, 'POST', {
// ...item, ...item,
// isCompliant: true, isCompliant: true,
// remarks: 'Verified by Auditor - Compliant' remarks: 'Verified by Auditor - Compliant'
// }, adminToken); }, adminToken);
// } }
// console.log('\n[STEP 13.1] All EOR items marked as compliant.'); console.log('\n[STEP 13.1] All EOR items marked as compliant.');
// log(13.2, 'Auditor Submitting Final EOR Audit...'); log(13.2, 'Auditor Submitting Final EOR Audit...');
// await apiRequest(`/eor/audit/${checklistId}`, 'POST', { await apiRequest(`/eor/audit/${checklistId}`, 'POST', {
// status: 'Completed', status: 'Completed',
// overallComments: 'Dealer is 100% ready for inauguration. All infra and statutory items verified.' overallComments: 'Dealer is 100% ready for inauguration. All infra and statutory items verified.'
// }, adminToken); }, adminToken);
// // Status check // Status check
// const finalAppStatus = await apiRequest(`/onboarding/applications/${applicationUUID}`, 'GET', null, adminToken); const finalAppStatus = await apiRequest(`/onboarding/applications/${applicationUUID}`, 'GET', null, adminToken);
// log(13.2, `Application Status after EOR: ${finalAppStatus.data.overallStatus}`); log(13.2, `Application Status after EOR: ${finalAppStatus.data.overallStatus}`);
// await delay(); await delay();
// // 14. FINAL ONBOARDING // 14. FINAL ONBOARDING
// log(14, 'Admin Finalizing Dealer Onboarding...'); log(14, 'Admin Finalizing Dealer Onboarding...');
// await apiRequest('/dealers', 'POST', { applicationId: applicationUUID }, adminToken); await apiRequest('/dealers', 'POST', { applicationId: applicationUUID }, adminToken);
// await delay(); await delay();
// // 15. VERIFICATION // 15. VERIFICATION
// log(15, 'Verifying Dealer Record Creation...'); log(15, 'Verifying Dealer Record Creation...');
// const dealerRes = await apiRequest(`/dealers/application/${applicationUUID}`, 'GET', null, adminToken); const dealerRes = await apiRequest(`/dealers/application/${applicationUUID}`, 'GET', null, adminToken);
// if (!dealerRes.success || !dealerRes.data) { if (!dealerRes.success || !dealerRes.data) {
// throw new Error('Verification Failed: Dealer record not found after onboarding.'); throw new Error('Verification Failed: Dealer record not found after onboarding.');
// } }
// log(15, `Dealer Found: ${dealerRes.data.legalName} (${dealerRes.data.id})`); log(15, `Dealer Found: ${dealerRes.data.legalName} (${dealerRes.data.id})`);
// log(15.1, 'Verifying User Account Role Update...'); log(15.1, 'Verifying User Account Role Update...');
// const userRes = await apiRequest(`/admin/users`, 'GET', null, adminToken); const userRes = await apiRequest(`/admin/users`, 'GET', null, adminToken);
// const dealerUser = userRes.data.find(u => u.email === PROSPECT_EMAIL); const dealerUser = userRes.data.find(u => u.email === PROSPECT_EMAIL);
// if (!dealerUser || dealerUser.roleCode !== 'Dealer') { if (!dealerUser || dealerUser.roleCode !== 'Dealer') {
// throw new Error(`Verification Failed: User role not updated to 'Dealer'. Current role: ${dealerUser?.roleCode}`); throw new Error(`Verification Failed: User role not updated to 'Dealer'. Current role: ${dealerUser?.roleCode}`);
// } }
// log(15.1, `User role confirmed: ${dealerUser.roleCode}`); log(15.1, `User role confirmed: ${dealerUser.roleCode}`);
// log(15.2, '--- WORKFLOW COMPLETED SUCCESSFULLY! ---'); log(15.2, '--- WORKFLOW COMPLETED SUCCESSFULLY! ---');
// log(15.2, `The application ${applicationId} is now at 'ONBOARDED' status and Dealer profile is active.`); log(15.2, `The application ${applicationId} is now at 'ONBOARDED' status and Dealer profile is active.`);
} }
/** /**