Merge pull request 'main' (#228) from s.hajizadeh/yara724api:main into main

Reviewed-on: Yara724/api#228
This commit is contained in:
2026-07-28 16:59:02 +03:30
2 changed files with 34 additions and 21 deletions

View File

@@ -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,
};
}

View File

@@ -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,
),
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,
),
claimRequestId,
claimStatus: ClaimStatus.APPROVED,
caseStatus: ClaimCaseStatus.COMPLETED,
outcome: "ALL_APPROVED_AUTO_COMPLETED",
fanavaran,
fanavaranExpertise,
};
}