merge upstream

This commit is contained in:
2026-07-28 16:58:26 +03:30
16 changed files with 749 additions and 50 deletions

View File

@@ -4140,12 +4140,14 @@ export class ExpertClaimService {
/**
* Claim list for FILE_REVIEWER.
*
* Visibility rules:
* Visibility rules (both V4 and V5 files):
* - WAITING_FOR_FILE_REVIEWER files made by a FileMaker that are either:
* (a) not yet assigned to any reviewer, OR
* (b) already assigned to THIS reviewer
* - WAITING_FOR_EXPERT files that are assigned to THIS reviewer
* (they completed the field work and the file is now in damage-expert queue)
* - Files already assigned to THIS reviewer (any post-assignment status)
*
* V4: isMadeByFileMaker=true, requiresFileMakerApproval=false
* V5: isMadeByFileMaker=true, requiresFileMakerApproval=true
*
* All scoped to this reviewer's insurance company via blame party clientId.
*/
@@ -4156,7 +4158,7 @@ export class ExpertClaimService {
const clientKey = requireActorClientKey(actor);
const reviewerOid = new Types.ObjectId(actor.sub);
// Find V4 blame files visible to this reviewer
// Find V4 and V5 blame files visible to this reviewer
const blames = (await this.blameRequestDbService.find(
{
isMadeByFileMaker: true,
@@ -4178,7 +4180,7 @@ export class ExpertClaimService {
{
lean: true,
select:
"_id type parties blameStatus status expert.decision assignedFileReviewerId",
"_id type parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval",
},
)) as any[];
@@ -4247,6 +4249,9 @@ export class ExpertClaimService {
(!!blame?.isMadeByFileMaker &&
String(blame?.status ?? "") === "WAITING_FOR_EXPERT"),
assignedToMe: !!assignedToMe,
requiresFileMakerApproval: !!(c as any).requiresFileMakerApproval,
fileMakerRejectionCount: (c as any).fileMakerRejectionCount ?? 0,
fileMakerRejectionReason: (c as any).fileMakerRejectionReason ?? undefined,
};
}) as ClaimListItemV2Dto[];
@@ -4254,8 +4259,9 @@ export class ExpertClaimService {
}
/**
* Claim list for FILE_MAKER — returns only the claims linked to blame files
* they personally created (V4 flow).
* Claim list for FILE_MAKER — returns claims linked to blame files they
* personally created (V4 and V5 flows).
* V4: requiresFileMakerApproval=false · V5: requiresFileMakerApproval=true
*/
private async getFileMakerClaimListV2(
actor: any,
@@ -4265,7 +4271,7 @@ export class ExpertClaimService {
const makerBlames = (await this.blameRequestDbService.find(
{ isMadeByFileMaker: true, initiatedByFieldExpertId: makerOid },
{ lean: true, select: "_id type parties blameStatus status expert.decision assignedFileReviewerId" },
{ lean: true, select: "_id type parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval" },
)) as any[];
if (makerBlames.length === 0) {
@@ -4273,9 +4279,10 @@ export class ExpertClaimService {
}
const blameIds = makerBlames.map((b) => b._id);
// Include all claims linked to this maker's blames — both V4 (requiresFileMakerApproval=false)
// and V5 (requiresFileMakerApproval=true).
const claims = (await this.claimCaseDbService.find({
blameRequestId: { $in: blameIds },
requiresFileMakerApproval: true,
})) as any[];
const blameById = new Map<string, any>(
@@ -4318,6 +4325,8 @@ export class ExpertClaimService {
createdAt: c.createdAt,
awaitingFactorValidation: claimIsAwaitingExpertFactorValidationV2(c),
requiresFileMakerApproval: !!(c as any).requiresFileMakerApproval,
fileMakerRejectionCount: (c as any).fileMakerRejectionCount ?? 0,
fileMakerRejectionReason: (c as any).fileMakerRejectionReason ?? undefined,
needsFileReviewerCompletion:
String(blame?.status ?? "") === "WAITING_FOR_FILE_REVIEWER" ||
(!!blame?.isMadeByFileMaker &&