forked from Yara724/api
Fixed v4/v5 car capture flow
This commit is contained in:
@@ -8335,36 +8335,17 @@ export class ClaimRequestManagementService {
|
||||
) {
|
||||
captureStepCompletedOnThisUpload = true;
|
||||
|
||||
if (options?.v3InPersonFlow) {
|
||||
// V4/V5: no further upload steps after capture docs — finalise now.
|
||||
const finalStatus = options.requiresFileMakerApproval
|
||||
? ClaimCaseStatus.WAITING_FOR_FILE_MAKER_APPROVAL
|
||||
: ClaimCaseStatus.WAITING_FOR_DAMAGE_EXPERT;
|
||||
$set["status"] = finalStatus;
|
||||
$set["claimStatus"] = ClaimStatus.PENDING;
|
||||
$set["workflow.currentStep"] = ClaimWorkflowStep.USER_SUBMISSION_COMPLETE;
|
||||
$set["workflow.nextStep"] = ClaimWorkflowStep.EXPERT_DAMAGE_ASSESSMENT;
|
||||
|
||||
// Mark the linked blame as COMPLETED.
|
||||
if (claimCase.blameRequestId) {
|
||||
await this.blameRequestDbService.findByIdAndUpdate(
|
||||
String(claimCase.blameRequestId),
|
||||
{ $set: { status: BlameCaseStatus.COMPLETED } },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$set["status"] = ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS;
|
||||
$set["workflow.currentStep"] =
|
||||
ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS;
|
||||
$set["workflow.nextStep"] = ClaimWorkflowStep.USER_SUBMISSION_COMPLETE;
|
||||
}
|
||||
// Advance to walk-around video step (UPLOADING_REQUIRED_DOCUMENTS /
|
||||
// UPLOAD_REQUIRED_DOCUMENTS). For V4/V5 the claim is finalised in
|
||||
// setVideoCaptureV3 (car-capture), which is the last FileReviewer
|
||||
// action before handing off to the damage expert.
|
||||
$set["status"] = ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS;
|
||||
$set["workflow.currentStep"] = ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS;
|
||||
$set["workflow.nextStep"] = ClaimWorkflowStep.USER_SUBMISSION_COMPLETE;
|
||||
|
||||
completedStepsEntries.push(
|
||||
ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
|
||||
);
|
||||
completedStepsEntries.push(
|
||||
ClaimWorkflowStep.USER_SUBMISSION_COMPLETE,
|
||||
);
|
||||
historyEntries.push({
|
||||
type: "STEP_COMPLETED",
|
||||
actor: {
|
||||
@@ -8376,7 +8357,7 @@ export class ClaimRequestManagementService {
|
||||
metadata: {
|
||||
stepKey: ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
|
||||
description: options?.v3InPersonFlow
|
||||
? "V4/V5 capture complete. Claim ready for review."
|
||||
? "V4/V5 capture docs complete. Upload walk-around video to finalise."
|
||||
: "Angles, damaged parts, and capture-phase vehicle evidence are complete.",
|
||||
},
|
||||
});
|
||||
@@ -8540,7 +8521,9 @@ export class ClaimRequestManagementService {
|
||||
|
||||
const message = isCapturePhaseDocUpload
|
||||
? captureStepCompletedOnThisUpload
|
||||
? "Capture-phase documents and all damage captures are complete. Please proceed to upload the remaining required documents."
|
||||
? options?.v3InPersonFlow
|
||||
? "Capture-phase documents and all damage captures are complete. Upload the walk-around video (car-capture) to finalise."
|
||||
: "Capture-phase documents and all damage captures are complete. Please proceed to upload the remaining required documents."
|
||||
: remaining > 0
|
||||
? `Document saved. ${remaining} capture-phase document(s) still required (chassis, engine, metal plate).`
|
||||
: capturePhaseSequenceMessage(
|
||||
@@ -10584,7 +10567,7 @@ export class ClaimRequestManagementService {
|
||||
ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
`Complete all part/angle captures first. Expected ${ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS}, but current step is ${claimCase.workflow?.currentStep}`,
|
||||
`Complete capture-phase documents (chassis/engine) first. Expected ${ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS}, but current step is ${claimCase.workflow?.currentStep}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10607,12 +10590,53 @@ export class ClaimRequestManagementService {
|
||||
);
|
||||
}
|
||||
|
||||
return this.setVideoCaptureV2(
|
||||
// Store the walk-around video (shared V2 logic).
|
||||
const result = await this.setVideoCaptureV2(
|
||||
claimRequestId,
|
||||
fileDetail,
|
||||
currentUserId,
|
||||
actor,
|
||||
);
|
||||
|
||||
// V4/V5 (in-person FileReviewer flow): car-capture is the last step.
|
||||
// Both variants land at WAITING_FOR_DAMAGE_EXPERT here.
|
||||
// For V5 (requiresFileMakerApproval=true), autoSubmitToFanavaranV2OnClaimCompleted
|
||||
// intercepts COMPLETED → WAITING_FOR_FILE_MAKER_APPROVAL after expert review.
|
||||
await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, {
|
||||
$set: {
|
||||
status: ClaimCaseStatus.WAITING_FOR_DAMAGE_EXPERT,
|
||||
claimStatus: ClaimStatus.PENDING,
|
||||
"workflow.currentStep": ClaimWorkflowStep.USER_SUBMISSION_COMPLETE,
|
||||
"workflow.nextStep": ClaimWorkflowStep.EXPERT_DAMAGE_ASSESSMENT,
|
||||
},
|
||||
$push: {
|
||||
"workflow.completedSteps": ClaimWorkflowStep.USER_SUBMISSION_COMPLETE,
|
||||
history: {
|
||||
type: "STEP_COMPLETED",
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(currentUserId),
|
||||
actorName: claimCase.owner?.fullName || "User",
|
||||
actorType: actor?.role === RoleEnum.FILE_REVIEWER ? "file_reviewer" : "user",
|
||||
},
|
||||
timestamp: new Date(),
|
||||
metadata: {
|
||||
stepKey: ClaimWorkflowStep.USER_SUBMISSION_COMPLETE,
|
||||
description: "V4/V5 walk-around video uploaded. Claim ready for damage expert review.",
|
||||
v3InPersonFlow: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Mark the linked blame file as COMPLETED.
|
||||
if (claimCase.blameRequestId) {
|
||||
await this.blameRequestDbService.findByIdAndUpdate(
|
||||
String(claimCase.blameRequestId),
|
||||
{ $set: { status: BlameCaseStatus.COMPLETED } },
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async capturePartV3(
|
||||
|
||||
Reference in New Issue
Block a user