4.0 KiB
Analysis: Dealer Claim & Unified Request Architecture
This document analyzes the current architecture and proposes an efficient approach to unify Dealer Claims and Custom Requests while supporting specialized data capture and versioning.
Current State
Both Custom Requests and Dealer Claims are already "unified" at the base level:
- Primary Collection:
workflow_requestsstores the core data (id, requestNumber, initiator, status, currentLevel). - Secondary Collection:
dealer_claimsstores the business-specific metadata (proposal, expenses, invoices, etc.) and is linked viarequestId.
This architecture naturally supports showing both in the same list.
Proposed Efficient Approach
To make these two paths truly "inline" and handle specialized steps efficiently, we recommend a Metadata-Driven Activity System.
1. Unified Listing
The UI should continue to use the existing listWorkflows endpoints. The backend already returns templateType, which the frontend can use to decide which icon or detail view to render.
2. Specialized Step Identification (Dual-Tag System)
To handle dynamic level shifts and accurately recognize the purpose of each step, we use two categories of tags on each ApprovalLevel.
Category A: Action Tags (stepAction)
Defines what special behavior is required in this step.
DEALER_PROPOSAL: Show proposal submission form.EXPENSE_CAPTURE: Show expense document upload form.PROPOSAL_EVALUATION: Show evaluation tools for the initiator/manager.NONE: Standard approve/reject UI.
Category B: Persona Tags (stepPersona)
Defines who is acting in this step (role-based logic).
INITIATOR: Used when the initiator acts as an approver (e.g., evaluating a dealer proposal).DEPARTMENT_LEAD: Standard leadership approval.ADDITIONAL_APPROVER: Distinguishes steps added manually from the template.
How it works together:
| Level | Level Name | stepAction |
stepPersona |
UI Behavior |
|---|---|---|---|---|
| 1 | Dealer Proposal | DEALER_PROPOSAL |
DEALER |
Full Proposal Form |
| 2 | Initiator Review | PROPOSAL_EVALUATION |
INITIATOR |
Inline evaluation checklist |
| 3 | Lead Approval | NONE |
DEPARTMENT_LEAD |
Simple Approve/Reject |
| 3b | Extra Check | NONE |
ADDITIONAL_APPROVER |
Manual Approval UI |
- Dynamic Insertions: If
Extra Checkis added, the following levels shift, but theirstepActiontags remain, so the UI NEVER breaks. - Resubmission: Rejection logic targets the latest completed level with
stepAction: 'DEALER_PROPOSAL'.
3. Versioning & Iterations
The user's requirement to track previous proposals during resubmission is handled via the Snapshotted Revisions pattern:
- The Main Store:
DealerClaim.proposalandDealerClaim.completionalways hold the active/latest values. - The Revision Store:
DealerClaim.revisions[]acts as an append-only audit trail.
Resubmission Flow:
- Request is rejected at Level 2/3/5.
- Workflow moves back to Level 1 or 4 (Dealer).
- Dealer edits the data.
- On Submit:
- Backend takes the current
proposalorcompletiondata. - Pushes it into
revisionswith a timestamp andtriggeredBy: 'SYSTEM_VERSION_SNAPSHOT'. - Overwrites the main object with the new data.
- Advances the workflow.
- Backend takes the current
4. Implementation Strategy
| Feature | Custom Request Path | Dealer Claim Path |
|---|---|---|
| Listing | Unified listWorkflows |
Unified listWorkflows |
| Details View | Standard UI | Enhanced UI (tabs for Expenses/Proposal) |
| Logic | Generic approveRequest |
approveRequest + DealerClaimService hook |
| Versioning | Activity Logs only | Snapshotted Revisions for re-submissions |
Key Advantage
This approach avoids creating "two separate systems". It treats a Dealer Claim as a "Custom Request with a specific metadata payload". The UI remains cohesive, and the backend logic for TAT, notifications, and status transitions stays shared.