diff --git a/src/claim-request-management/claim-request-management.service.ts b/src/claim-request-management/claim-request-management.service.ts index 36e6e6d..d6a77d9 100644 --- a/src/claim-request-management/claim-request-management.service.ts +++ b/src/claim-request-management/claim-request-management.service.ts @@ -3889,7 +3889,7 @@ export class ClaimRequestManagementService { return { BeginDate: insurance.startDate ?? null, BuiltYear: - Number(inquiryMapped.ModelField ?? inquiryMapped.ModelCii) || null, + Number(inquiryMapped.ModelField ?? inquiryMapped.ModelCii) || Number(inquiryMapped.PrdDate) || null, ChassisNo: inquiryMapped.ChassisNumberField ?? inquiryMapped.ShsNum ?? @@ -5066,6 +5066,25 @@ export class ClaimRequestManagementService { warning, fileName: candidate.fileName, }); + + // Schedule a retry for this individual file via autoSubmitFanavaranAttachment, + // which handles idempotency (won't re-upload if already recorded as submitted) + // and has its own inner retry/back-off via scheduleFanavaranRetry. + await this.scheduleFanavaranRetry( + claimCaseId, + "attachments", + () => + this.autoSubmitFanavaranAttachment( + claimCaseId, + { + path: candidate.path, + fileName: candidate.fileName, + source: candidate.source, + }, + { clientKey, auditSource: FanavaranAuditSource.AUTO_SUBMIT }, + ), + `${logPrefix} [${i + 1}/${pending.length}] retry`, + ); } if (i < pending.length - 1) { @@ -9667,6 +9686,7 @@ export class ClaimRequestManagementService { accepted: boolean; phase?: "PRICED_PARTS_FOR_FACTORS" | "FINAL_APPROVAL"; fanavaran?: FanavaranAutoSubmitResult; + fanavaranExpertise?: FanavaranExpertiseSubmitResult; }> { if (!Types.ObjectId.isValid(claimRequestId)) { throw new BadRequestException("Invalid claim request id"); @@ -9940,6 +9960,7 @@ export class ClaimRequestManagementService { accepted: true, phase: "FINAL_APPROVAL", fanavaran, + fanavaranExpertise, }; } diff --git a/src/expert-claim/expert-claim.service.ts b/src/expert-claim/expert-claim.service.ts index 01a7db3..ed231cb 100644 --- a/src/expert-claim/expert-claim.service.ts +++ b/src/expert-claim/expert-claim.service.ts @@ -2429,24 +2429,20 @@ export class ExpertClaimService { await this.claimRequestManagementService.autoSubmitToFanavaranV2OnClaimCompleted( claimRequestId, ); - const fanavaranExpertise = - await this.claimRequestManagementService.autoSubmitFanavaranExpertiseOnExpertReply( - claimRequestId, - ); + // Expertise (stage 4) is intentionally NOT submitted here. + // It is only triggered after the owner's final approval signature + // (submitOwnerInsurerApprovalSignV2), because until that point the + // expert review is not considered final — the user can still object. return { message: this.appendFanavaranAutoSubmitToMessage( - this.appendFanavaranAutoSubmitToMessage( - "Factors were reviewed with expert repricing on rejected lines. The claim is completed without an owner signature (temporary policy; may require owner acceptance later).", - fanavaran, - ), - fanavaranExpertise, + "Factors were reviewed with expert repricing on rejected lines. The claim is completed without an owner signature (temporary policy; may require owner acceptance later).", + fanavaran, ), claimRequestId, claimStatus: ClaimStatus.APPROVED, caseStatus: ClaimCaseStatus.COMPLETED, outcome: "REJECTED_REPRICED_AUTO_COMPLETED", fanavaran, - fanavaranExpertise, }; } @@ -2463,25 +2459,21 @@ export class ExpertClaimService { await this.claimRequestManagementService.autoSubmitToFanavaranV2OnClaimCompleted( claimRequestId, ); - const fanavaranExpertise = - await this.claimRequestManagementService.autoSubmitFanavaranExpertiseOnExpertReply( - claimRequestId, - ); + // Expertise (stage 4) is intentionally NOT submitted here. + // It is only triggered after the owner's final approval signature + // (submitOwnerInsurerApprovalSignV2), because until that point the + // expert review is not considered final — the user can still object. return { message: this.appendFanavaranAutoSubmitToMessage( - this.appendFanavaranAutoSubmitToMessage( - "All factors were approved by the expert. The claim is completed without an additional owner signature.", - fanavaran, - ), - fanavaranExpertise, + "All factors were approved by the expert. The claim is completed without an additional owner signature.", + fanavaran, ), claimRequestId, claimStatus: ClaimStatus.APPROVED, caseStatus: ClaimCaseStatus.COMPLETED, outcome: "ALL_APPROVED_AUTO_COMPLETED", fanavaran, - fanavaranExpertise, }; }