5.2 KiB
5.2 KiB
Claim Management - Approver Mapping Documentation
Overview
The Claim Management workflow has 8 fixed steps with specific approvers and action types. This document explains how approvers are mapped when a claim request is created.
8-Step Workflow Structure
Step 1: Dealer Proposal Submission
- Approver Type: Dealer (External)
- Action Type: SUBMIT (Dealer submits proposal documents)
- TAT: 72 hours
- Mapping: Uses
dealerEmailfrom claim data - Status: PENDING (waiting for dealer to submit)
Step 2: Requestor Evaluation
- Approver Type: Initiator (Internal RE Employee)
- Action Type: APPROVE/REJECT (Requestor reviews dealer proposal)
- TAT: 48 hours
- Mapping: Uses
initiatorId(the person who created the request) - Status: PENDING (waiting for requestor to evaluate)
Step 3: Department Lead Approval
- Approver Type: Department Lead (Internal RE Employee)
- Action Type: APPROVE/REJECT (Department lead approves and blocks IO budget)
- TAT: 72 hours
- Mapping:
- Option 1: Find user with role
MANAGEMENTin same department as initiator - Option 2: Use initiator's
managerfield from User model - Option 3: Find user with designation containing "Lead" or "Head" in same department
- Option 1: Find user with role
- Status: PENDING (waiting for department lead approval)
Step 4: Activity Creation
- Approver Type: System (Auto-processed)
- Action Type: AUTO (System automatically creates activity)
- TAT: 1 hour
- Mapping: System user (
system@royalenfield.com) - Status: Auto-approved when triggered
Step 5: Dealer Completion Documents
- Approver Type: Dealer (External)
- Action Type: SUBMIT (Dealer submits completion documents)
- TAT: 120 hours
- Mapping: Uses
dealerEmailfrom claim data - Status: PENDING (waiting for dealer to submit)
Step 6: Requestor Claim Approval
- Approver Type: Initiator (Internal RE Employee)
- Action Type: APPROVE/REJECT (Requestor approves completion)
- TAT: 48 hours
- Mapping: Uses
initiatorId - Status: PENDING (waiting for requestor approval)
Step 7: E-Invoice Generation
- Approver Type: System (Auto-processed via DMS)
- Action Type: AUTO (System generates e-invoice via DMS integration)
- TAT: 1 hour
- Mapping: System user (
system@royalenfield.com) - Status: Auto-approved when triggered
Step 8: Credit Note Confirmation
- Approver Type: Finance Team (Internal RE Employee)
- Action Type: APPROVE/REJECT (Finance confirms credit note)
- TAT: 48 hours
- Mapping:
- Option 1: Find user with role
MANAGEMENTand department contains "Finance" - Option 2: Find user with designation containing "Finance" or "Accountant"
- Option 3: Use configured finance team email from admin settings
- Option 1: Find user with role
- Status: PENDING (waiting for finance confirmation)
- Is Final Approver: Yes (final step)
Current Implementation Issues
Problems:
- Step 1 & 5: Dealer email not being used - using placeholder UUID
- Step 3: Department Lead not resolved - using placeholder UUID
- Step 8: Finance team not resolved - using placeholder UUID
- All steps: Using initiator email for non-initiator steps
Impact:
- Steps 1, 3, 5, 8 won't have correct approvers assigned
- Notifications won't be sent to correct users
- Workflow will be stuck waiting for non-existent approvers
Action Types Summary
| Step | Action Type | Description |
|---|---|---|
| 1 | SUBMIT | Dealer submits proposal (not approve/reject) |
| 2 | APPROVE/REJECT | Requestor evaluates proposal |
| 3 | APPROVE/REJECT | Department Lead approves and blocks budget |
| 4 | AUTO | System creates activity automatically |
| 5 | SUBMIT | Dealer submits completion documents |
| 6 | APPROVE/REJECT | Requestor approves completion |
| 7 | AUTO | System generates e-invoice via DMS |
| 8 | APPROVE/REJECT | Finance confirms credit note (FINAL) |
Approver Resolution Logic
For Dealer Steps (1, 5):
// Use dealer email from claim data
const dealerEmail = claimData.dealerEmail;
// Find or create dealer user (if dealer is external, may need special handling)
const dealerUser = await User.findOne({ where: { email: dealerEmail } });
// If dealer doesn't exist in system, create participant entry
For Department Lead (Step 3):
// Priority order:
1. Find user with same department and role = 'MANAGEMENT'
2. Use initiator.manager field to find manager
3. Find user with designation containing "Lead" or "Head" in same department
4. Fallback: Use initiator's manager email from User model
For Finance Team (Step 8):
// Priority order:
1. Find user with department containing "Finance" and role = 'MANAGEMENT'
2. Find user with designation containing "Finance" or "Accountant"
3. Use configured finance team email from admin_configurations table
4. Fallback: Use default finance email (e.g., finance@royalenfield.com)
Next Steps
The createClaimApprovalLevels() method needs to be updated to:
- Accept
dealerEmailparameter - Resolve Department Lead dynamically
- Resolve Finance team member dynamically
- Handle cases where approvers don't exist in the system