forked from Yara724/api
Merge pull request 'FIxed file reviewer bugs' (#167) from s.yahyaee/yara724-api:main into main
Reviewed-on: Yara724/api#167
This commit is contained in:
@@ -6812,10 +6812,14 @@ export class ClaimRequestManagementService {
|
||||
currentUserId: string,
|
||||
actorRole?: string,
|
||||
): Promise<string> {
|
||||
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(
|
||||
@@ -6823,7 +6827,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 ||
|
||||
@@ -6831,7 +6835,7 @@ export class ClaimRequestManagementService {
|
||||
) {
|
||||
return currentUserId;
|
||||
}
|
||||
} else {
|
||||
} else if (actorRole === RoleEnum.REGISTRAR) {
|
||||
if (
|
||||
!blameRequest.registrarInitiated ||
|
||||
!blameRequest.initiatedByRegistrarId ||
|
||||
@@ -6840,6 +6844,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)
|
||||
@@ -9794,8 +9800,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.",
|
||||
);
|
||||
@@ -10079,7 +10091,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}`,
|
||||
@@ -10111,7 +10125,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
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user