Fixed rejection flow data on v5

This commit is contained in:
SepehrYahyaee
2026-08-03 18:15:52 +03:30
parent 01c1be40c7
commit 793dc52640
2 changed files with 12 additions and 45 deletions

View File

@@ -8198,12 +8198,8 @@ export class ClaimRequestManagementService {
); );
} }
// 4. Validate outer parts haven't been selected yet. // 4. Validate outer parts haven't been selected yet
// Skip this guard when FileMaker rejected the claim and the FileReviewer
// is updating (overwriting) the previous selection.
const isFileMakerRejectedRerun = !!(claimCase as any).fileMakerRejectedPendingReview;
if ( if (
!isFileMakerRejectedRerun &&
claimCase.damage?.selectedParts && claimCase.damage?.selectedParts &&
claimCase.damage.selectedParts.length > 0 claimCase.damage.selectedParts.length > 0
) { ) {
@@ -8270,9 +8266,7 @@ export class ClaimRequestManagementService {
})); }));
const selectedPartIds = selectedItems.map((p) => p.id); const selectedPartIds = selectedItems.map((p) => p.id);
// 6. Update claim case with selected parts and move to next step. // 6. Update claim case with selected parts and move to next step
// Also clear fileMakerRejectedPendingReview now that the reviewer has
// actively re-submitted outer parts.
const updatedClaim = await this.claimCaseDbService.findByIdAndUpdate( const updatedClaim = await this.claimCaseDbService.findByIdAndUpdate(
claimRequestId, claimRequestId,
{ {
@@ -8282,10 +8276,7 @@ export class ClaimRequestManagementService {
status: ClaimCaseStatus.SELECTING_OTHER_PARTS, status: ClaimCaseStatus.SELECTING_OTHER_PARTS,
"workflow.currentStep": ClaimWorkflowStep.SELECT_OTHER_PARTS, "workflow.currentStep": ClaimWorkflowStep.SELECT_OTHER_PARTS,
"workflow.nextStep": ClaimWorkflowStep.CAPTURE_PART_DAMAGES, "workflow.nextStep": ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
$unset: { $unset: { "damage.selectedOuterParts": "" },
"damage.selectedOuterParts": "",
"fileMakerRejectedPendingReview": "",
},
$push: { $push: {
"workflow.completedSteps": ClaimWorkflowStep.SELECT_OUTER_PARTS, "workflow.completedSteps": ClaimWorkflowStep.SELECT_OUTER_PARTS,
history: { history: {
@@ -8410,11 +8401,8 @@ export class ClaimRequestManagementService {
); );
} }
// 4. Validate other parts and bank info haven't been submitted yet. // 4. Validate other parts and bank info haven't been submitted yet
// Skip when FileMaker rejected the claim — the FileReviewer can update bank info.
const isFileMakerRejectedRerun = !!(claimCase as any).fileMakerRejectedPendingReview;
if ( if (
!isFileMakerRejectedRerun &&
claimCase.money?.sheba && claimCase.money?.sheba &&
claimCase.money?.nationalCodeOfInsurer && claimCase.money?.nationalCodeOfInsurer &&
claimCase.workflow?.currentStep !== ClaimWorkflowStep.USER_EXPERT_RESEND claimCase.workflow?.currentStep !== ClaimWorkflowStep.USER_EXPERT_RESEND

View File

@@ -10615,51 +10615,30 @@ export class RequestManagementService {
const newRejectionCount = currentRejections + 1; const newRejectionCount = currentRejections + 1;
const actorName = `${fileMaker.firstName || ""} ${fileMaker.lastName || ""}`.trim(); const actorName = `${fileMaker.firstName || ""} ${fileMaker.lastName || ""}`.trim();
// Steps that belong to the re-run assessment cycle.
// Pulled from completedSteps so workflow ordering guards pass on re-run.
const assessmentSteps = [
ClaimWorkflowStep.SELECT_OUTER_PARTS,
ClaimWorkflowStep.SELECT_OTHER_PARTS,
ClaimWorkflowStep.CAPTURE_PART_DAMAGES,
ClaimWorkflowStep.USER_SUBMISSION_COMPLETE,
];
await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, { await this.claimCaseDbService.findByIdAndUpdate(claimRequestId, {
$set: { $set: {
status: ClaimCaseStatus.WAITING_FOR_DAMAGE_EXPERT, status: ClaimCaseStatus.WAITING_FOR_DAMAGE_EXPERT,
claimStatus: ClaimStatus.NEEDS_REVISION, claimStatus: ClaimStatus.NEEDS_REVISION,
fileMakerRejectionCount: newRejectionCount, fileMakerRejectionCount: newRejectionCount,
fileMakerRejectionReason: reason ?? null, fileMakerRejectionReason: reason ?? null,
// Land directly at SELECT_OUTER_PARTS: the FileReviewer sees the "workflow.currentStep": ClaimWorkflowStep.EXPERT_DAMAGE_ASSESSMENT,
// existing parts pre-populated and can adjust or confirm them. "workflow.nextStep": ClaimWorkflowStep.EXPERT_DAMAGE_ASSESSMENT,
"workflow.currentStep": ClaimWorkflowStep.SELECT_OUTER_PARTS,
"workflow.nextStep": ClaimWorkflowStep.SELECT_OTHER_PARTS,
"workflow.locked": false, "workflow.locked": false,
// Flag consumed by selectOuterPartsV2 / selectOtherPartsV2 to allow
// overwriting previously submitted data instead of throwing ConflictException.
"fileMakerRejectedPendingReview": true,
}, },
// Clear stale lock/evaluation fields and media that must be re-captured. // Clear stale lock fields and the owner-cycle evaluation data.
// Part selections (damage.selectedParts, damage.otherParts) are intentionally // evaluation.damageExpertReply is intentionally preserved so the FileReviewer
// preserved as a pre-populated starting point for the FileReviewer to adjust. // sees their previous prices / daghi / severity pre-populated in the claim
// detail and can adjust them. submitExpertReplyV2 overwrites it with $set.
// - assignedForReviewBy intentionally kept so the same reviewer
// is still scoped to this file on re-lock.
$unset: { $unset: {
"workflow.lockedAt": "", "workflow.lockedAt": "",
"workflow.expiredAt": "", "workflow.expiredAt": "",
"workflow.lockedBy": "", "workflow.lockedBy": "",
"workflow.preLockQueueSnapshot": "", "workflow.preLockQueueSnapshot": "",
"evaluation.damageExpertReply": "",
"evaluation.damageExpertResend": "", "evaluation.damageExpertResend": "",
"evaluation.ownerInsurerApproval": "", "evaluation.ownerInsurerApproval": "",
"evaluation.ownerPricedPartsApproval": "", "evaluation.ownerPricedPartsApproval": "",
// Photos and walk-around video must be re-taken for the new part set.
"media.damagedParts": "",
"media.captures": "",
"media.videoCaptureId": "",
},
// Remove assessment-cycle steps from completedSteps so workflow ordering
// guards pass when the FileReviewer re-runs each step.
$pull: {
"workflow.completedSteps": { $in: assessmentSteps },
}, },
$push: { $push: {
history: { history: {