From 0c5a2fe38b44c4f2e89b45d22014da800c35addf Mon Sep 17 00:00:00 2001 From: SepehrYahyaee <7heycallmegray@gmail.com> Date: Wed, 1 Jul 2026 15:58:45 +0330 Subject: [PATCH] Fixed accident-details bug --- .../claim-request-management.service.ts | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/claim-request-management/claim-request-management.service.ts b/src/claim-request-management/claim-request-management.service.ts index b85e157..c9cd589 100644 --- a/src/claim-request-management/claim-request-management.service.ts +++ b/src/claim-request-management/claim-request-management.service.ts @@ -5132,10 +5132,14 @@ export class ClaimRequestManagementService { currentUserId: string, actorRole?: string, ): Promise { - if ( - ![RoleEnum.FIELD_EXPERT, RoleEnum.REGISTRAR].includes(actorRole as any) || - !claimCase?.blameRequestId - ) { + const isFieldLikeRole = [ + RoleEnum.FIELD_EXPERT, + RoleEnum.REGISTRAR, + RoleEnum.FILE_MAKER, + RoleEnum.FILE_REVIEWER, + ].includes(actorRole as any); + + if (!isFieldLikeRole || !claimCase?.blameRequestId) { return currentUserId; } const blameRequest = await this.blameRequestDbService.findById( @@ -5143,7 +5147,7 @@ export class ClaimRequestManagementService { ); if (!blameRequest || blameRequest.creationMethod !== "IN_PERSON") return currentUserId; - if (actorRole === RoleEnum.FIELD_EXPERT) { + if (actorRole === RoleEnum.FIELD_EXPERT || actorRole === RoleEnum.FILE_MAKER) { if ( !blameRequest.expertInitiated || !blameRequest.initiatedByFieldExpertId || @@ -5151,7 +5155,7 @@ export class ClaimRequestManagementService { ) { return currentUserId; } - } else { + } else if (actorRole === RoleEnum.REGISTRAR) { if ( !blameRequest.registrarInitiated || !blameRequest.initiatedByRegistrarId || @@ -5160,6 +5164,8 @@ export class ClaimRequestManagementService { return currentUserId; } } + // FILE_REVIEWER: no initiator-id check — they pick up any IN_PERSON expert + // file after the FileMaker seals it, so we resolve the owner unconditionally. return ( resolveDamagedPartyUserId(blameRequest) ?? (claimCase.owner?.userId ? String(claimCase.owner.userId) : currentUserId) @@ -8051,8 +8057,14 @@ export class ClaimRequestManagementService { return !!party?.confirmation; } - private assertV3ClaimDocumentsPhase(blame: any): void { - if (!(blame.expert?.decision as any)?.fields?.accidentWay) { + private assertV3ClaimDocumentsPhase( + blame: any, + options?: { skipAccidentFieldsCheck?: boolean }, + ): void { + if ( + !options?.skipAccidentFieldsCheck && + !(blame.expert?.decision as any)?.fields?.accidentWay + ) { throw new BadRequestException( "Submit accident fields before uploading required documents.", ); @@ -8336,7 +8348,9 @@ export class ClaimRequestManagementService { ); } } else { - this.assertV3ClaimDocumentsPhase(blame); + this.assertV3ClaimDocumentsPhase(blame, { + skipAccidentFieldsCheck: actor?.role === "file_maker", + }); if (!this.isV3InitialDocumentsPhase(claimCase)) { throw new BadRequestException( `Upload initial required documents during ${ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS} before part selection. Current step: ${claimCase.workflow?.currentStep}`, @@ -8368,7 +8382,9 @@ export class ClaimRequestManagementService { const blame = await this.assertV3InPersonClaim(claimCase); if (this.isV3InitialDocumentsPhase(claimCase)) { - this.assertV3ClaimDocumentsPhase(blame); + this.assertV3ClaimDocumentsPhase(blame, { + skipAccidentFieldsCheck: actor?.role === "file_maker", + }); } else if ( claimCase.workflow?.currentStep === ClaimWorkflowStep.CAPTURE_PART_DAMAGES ) {