feat: complete in-person claims without final sign

This commit is contained in:
SepehrYahyaee
2026-09-01 15:03:08 +03:30
parent 6880de5960
commit ae49031c55
16 changed files with 249 additions and 162 deletions

View File

@@ -10462,9 +10462,9 @@ export class RequestManagementService {
/**
* V5 variant of expertUploadBlameVideoV3.
* Same flow as V3/V4 but additionally marks the linked claim with
* `requiresFileMakerApproval: true` so that after the owner signs,
* the claim is held at WAITING_FOR_FILE_MAKER_APPROVAL rather than
* being auto-submitted to fanavaran.
* `requiresFileMakerApproval: true` so that after expert work completes,
* the claim is held at WAITING_FOR_FILE_MAKER_APPROVAL. FileMaker approval
* completes the claim; Fanavaran submission is manual.
*/
async expertUploadBlameVideoV5(
expert: any,
@@ -10612,7 +10612,7 @@ export class RequestManagementService {
videoId,
status: req.status,
message: file
? "Blame accident video uploaded. File is now in expert review queue. After the full claim flow completes and the owner signs, the FileMaker must approve before fanavaran submission."
? "Blame accident video uploaded. File is now in expert review queue. After the full claim flow completes, the FileMaker must approve before manual Fanavaran submission."
: "File completed. Claim is now ready for damage expert review.",
};
}
@@ -10625,7 +10625,7 @@ export class RequestManagementService {
* - claim.status === WAITING_FOR_FILE_MAKER_APPROVAL
* - actor is FILE_MAKER and is the original creator of the linked blame file
*
* On approval: triggers fanavaran submission and moves claim to COMPLETED.
* On approval: completes the claim. Fanavaran submission is manual.
*/
async fileMakerApproveV5(
fileMaker: any,
@@ -10669,16 +10669,14 @@ export class RequestManagementService {
metadata: {},
};
// V5 approval: move claim to INSURER_REVIEW_AWAITING_OWNER_SIGN so the
// owner can now sign. Clear requiresFileMakerApproval so that when the
// owner later signs and autoSubmitToFanavaranV2OnClaimCompleted runs, it
// does not re-intercept the claim as a pending V5 gate.
// V5 approval is the final V5 gate. The damaged-party final signature is
// no longer required, and Fanavaran submission is intentionally manual.
await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, {
$set: {
status: ClaimCaseStatus.INSURER_REVIEW_AWAITING_OWNER_SIGN,
status: ClaimCaseStatus.COMPLETED,
claimStatus: ClaimStatus.APPROVED,
requiresFileMakerApproval: false,
"workflow.currentStep": ClaimWorkflowStep.INSURER_REVIEW,
"workflow.currentStep": ClaimWorkflowStep.CLAIM_COMPLETED,
"workflow.nextStep": ClaimWorkflowStep.CLAIM_COMPLETED,
},
$push: {
@@ -10686,36 +10684,12 @@ export class RequestManagementService {
},
});
// Notify the owner that the claim is ready for their signature.
const notifyUserId = (claim as any).damagedPartyUserId ?? (claim as any).owner?.userId;
if (notifyUserId && claim.blameRequestId) {
const blame = await this.blameRequestDbService.findById(
String(claim.blameRequestId),
);
const ownerParty = (blame?.parties || []).find(
(p: any) =>
p?.person?.userId && String(p.person.userId) === String(notifyUserId),
);
const ownerPhone = ownerParty?.person?.phoneNumber
?? (await this.userDbService.findOne({ _id: new Types.ObjectId(String(notifyUserId)) }))?.mobile;
if (ownerPhone && typeof ownerPhone === "string") {
await this.smsOrchestrationService.sendSignatureReviewNotice({
receptor: ownerPhone,
fileKind: "claim",
publicId: claim.publicId,
expertLastName: actorName.split(/\s+/).pop() || "کارشناس",
link: this.smsOrchestrationService.buildClaimLink(claimRequestId, "v2"),
});
}
}
return {
claimRequestId,
publicId: claim.publicId,
status: ClaimCaseStatus.INSURER_REVIEW_AWAITING_OWNER_SIGN,
status: ClaimCaseStatus.COMPLETED,
message:
"Claim approved by FileMaker. Owner has been notified to sign. " +
"Once the owner signs, the claim will be completed and submitted to Fanavaran.",
"Claim approved by FileMaker and completed. Submit it to Fanavaran manually when ready.",
};
}