forked from Yara724/api
Fixed accident-details bug
This commit is contained in:
@@ -5132,10 +5132,14 @@ export class ClaimRequestManagementService {
|
|||||||
currentUserId: string,
|
currentUserId: string,
|
||||||
actorRole?: string,
|
actorRole?: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
if (
|
const isFieldLikeRole = [
|
||||||
![RoleEnum.FIELD_EXPERT, RoleEnum.REGISTRAR].includes(actorRole as any) ||
|
RoleEnum.FIELD_EXPERT,
|
||||||
!claimCase?.blameRequestId
|
RoleEnum.REGISTRAR,
|
||||||
) {
|
RoleEnum.FILE_MAKER,
|
||||||
|
RoleEnum.FILE_REVIEWER,
|
||||||
|
].includes(actorRole as any);
|
||||||
|
|
||||||
|
if (!isFieldLikeRole || !claimCase?.blameRequestId) {
|
||||||
return currentUserId;
|
return currentUserId;
|
||||||
}
|
}
|
||||||
const blameRequest = await this.blameRequestDbService.findById(
|
const blameRequest = await this.blameRequestDbService.findById(
|
||||||
@@ -5143,7 +5147,7 @@ export class ClaimRequestManagementService {
|
|||||||
);
|
);
|
||||||
if (!blameRequest || blameRequest.creationMethod !== "IN_PERSON")
|
if (!blameRequest || blameRequest.creationMethod !== "IN_PERSON")
|
||||||
return currentUserId;
|
return currentUserId;
|
||||||
if (actorRole === RoleEnum.FIELD_EXPERT) {
|
if (actorRole === RoleEnum.FIELD_EXPERT || actorRole === RoleEnum.FILE_MAKER) {
|
||||||
if (
|
if (
|
||||||
!blameRequest.expertInitiated ||
|
!blameRequest.expertInitiated ||
|
||||||
!blameRequest.initiatedByFieldExpertId ||
|
!blameRequest.initiatedByFieldExpertId ||
|
||||||
@@ -5151,7 +5155,7 @@ export class ClaimRequestManagementService {
|
|||||||
) {
|
) {
|
||||||
return currentUserId;
|
return currentUserId;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (actorRole === RoleEnum.REGISTRAR) {
|
||||||
if (
|
if (
|
||||||
!blameRequest.registrarInitiated ||
|
!blameRequest.registrarInitiated ||
|
||||||
!blameRequest.initiatedByRegistrarId ||
|
!blameRequest.initiatedByRegistrarId ||
|
||||||
@@ -5160,6 +5164,8 @@ export class ClaimRequestManagementService {
|
|||||||
return currentUserId;
|
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 (
|
return (
|
||||||
resolveDamagedPartyUserId(blameRequest) ??
|
resolveDamagedPartyUserId(blameRequest) ??
|
||||||
(claimCase.owner?.userId ? String(claimCase.owner.userId) : currentUserId)
|
(claimCase.owner?.userId ? String(claimCase.owner.userId) : currentUserId)
|
||||||
@@ -8051,8 +8057,14 @@ export class ClaimRequestManagementService {
|
|||||||
return !!party?.confirmation;
|
return !!party?.confirmation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private assertV3ClaimDocumentsPhase(blame: any): void {
|
private assertV3ClaimDocumentsPhase(
|
||||||
if (!(blame.expert?.decision as any)?.fields?.accidentWay) {
|
blame: any,
|
||||||
|
options?: { skipAccidentFieldsCheck?: boolean },
|
||||||
|
): void {
|
||||||
|
if (
|
||||||
|
!options?.skipAccidentFieldsCheck &&
|
||||||
|
!(blame.expert?.decision as any)?.fields?.accidentWay
|
||||||
|
) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"Submit accident fields before uploading required documents.",
|
"Submit accident fields before uploading required documents.",
|
||||||
);
|
);
|
||||||
@@ -8336,7 +8348,9 @@ export class ClaimRequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.assertV3ClaimDocumentsPhase(blame);
|
this.assertV3ClaimDocumentsPhase(blame, {
|
||||||
|
skipAccidentFieldsCheck: actor?.role === "file_maker",
|
||||||
|
});
|
||||||
if (!this.isV3InitialDocumentsPhase(claimCase)) {
|
if (!this.isV3InitialDocumentsPhase(claimCase)) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
`Upload initial required documents during ${ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS} before part selection. Current step: ${claimCase.workflow?.currentStep}`,
|
`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);
|
const blame = await this.assertV3InPersonClaim(claimCase);
|
||||||
|
|
||||||
if (this.isV3InitialDocumentsPhase(claimCase)) {
|
if (this.isV3InitialDocumentsPhase(claimCase)) {
|
||||||
this.assertV3ClaimDocumentsPhase(blame);
|
this.assertV3ClaimDocumentsPhase(blame, {
|
||||||
|
skipAccidentFieldsCheck: actor?.role === "file_maker",
|
||||||
|
});
|
||||||
} else if (
|
} else if (
|
||||||
claimCase.workflow?.currentStep === ClaimWorkflowStep.CAPTURE_PART_DAMAGES
|
claimCase.workflow?.currentStep === ClaimWorkflowStep.CAPTURE_PART_DAMAGES
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user