forked from Yara724/api
fanavaran expert codes
This commit is contained in:
@@ -355,6 +355,12 @@ interface FanavaranAttachmentCandidate {
|
||||
submittedFileId?: unknown;
|
||||
}
|
||||
|
||||
interface FanavaranClaimExpertContext {
|
||||
initiatedByFieldExpertId?: unknown;
|
||||
evaluation?: object;
|
||||
workflow?: { assignedForReviewBy?: { actorId?: unknown } };
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns today's Jalali date as a packed integer YYYYMMDD for cheap comparison.
|
||||
* Uses the browser/Node `fa-IR` locale which is available everywhere Node runs.
|
||||
@@ -3457,7 +3463,7 @@ export class ClaimRequestManagementService {
|
||||
decision?: { decidedByExpertId?: unknown };
|
||||
};
|
||||
},
|
||||
claimCase?: { initiatedByFieldExpertId?: unknown } | null,
|
||||
claimCase?: FanavaranClaimExpertContext | null,
|
||||
): Promise<{
|
||||
claimExpertId: number | null;
|
||||
code: string | null;
|
||||
@@ -3507,14 +3513,22 @@ export class ClaimRequestManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
// User-created claims may have no blame expert. Their damage reviewer is
|
||||
// still staff attached to this file and can supply the stage-1 product code.
|
||||
const candidateIds = [
|
||||
blame.initiatedByFieldExpertId,
|
||||
blame.expert?.assignedExpertId,
|
||||
blame.expert?.decision?.decidedByExpertId,
|
||||
claimCase?.initiatedByFieldExpertId,
|
||||
]
|
||||
.filter((value) => value != null && String(value).trim() !== "")
|
||||
.map((value) => String(value));
|
||||
...new Set(
|
||||
[
|
||||
blame.initiatedByFieldExpertId,
|
||||
blame.expert?.assignedExpertId,
|
||||
blame.expert?.decision?.decidedByExpertId,
|
||||
claimCase?.initiatedByFieldExpertId,
|
||||
this.fanavaranDamageReplyActorId(claimCase),
|
||||
claimCase?.workflow?.assignedForReviewBy?.actorId,
|
||||
]
|
||||
.filter((value) => value != null && String(value).trim() !== "")
|
||||
.map((value) => String(value)),
|
||||
),
|
||||
];
|
||||
|
||||
const missingOnStaff: string[] = [];
|
||||
for (const staffId of candidateIds) {
|
||||
@@ -3543,7 +3557,7 @@ export class ClaimRequestManagementService {
|
||||
code: "FANAVARAN_CLAIM_EXPERT_ID_MISSING",
|
||||
message:
|
||||
candidateIds.length === 0
|
||||
? `ClaimExpertId unresolved: this claim/blame has no assigned staff id (checked initiatedByFieldExpertId, expert.assignedExpertId, expert.decision.decidedByExpertId). Codes like ThirdPartyClaimExpertId=5507 on some other staff profile are ignored until that staff is assigned to this file.`
|
||||
? `ClaimExpertId unresolved: this claim/blame has no assigned staff id (checked initiatedByFieldExpertId, expert.assignedExpertId, expert.decision.decidedByExpertId, evaluation.damageExpertReplyFinal/damageExpertReply.actorDetail.actorId, workflow.assignedForReviewBy.actorId). Assign staff with ${fieldName} to this file.`
|
||||
: `ClaimExpertId unresolved: checked assigned staff [${missingOnStaff.join("; ")}]. Your ${fieldName} must be on THAT assigned staff document, not a different user.`,
|
||||
candidatesTried: candidateIds,
|
||||
};
|
||||
@@ -3564,7 +3578,7 @@ export class ClaimRequestManagementService {
|
||||
decision?: { decidedByExpertId?: unknown };
|
||||
};
|
||||
},
|
||||
claimCase?: { initiatedByFieldExpertId?: unknown } | null,
|
||||
claimCase?: FanavaranClaimExpertContext | null,
|
||||
options?: { required?: boolean },
|
||||
): Promise<number | null> {
|
||||
const resolved = await this.tryResolveFanavaranBaseClaimExpertId(
|
||||
@@ -3581,6 +3595,26 @@ export class ClaimRequestManagementService {
|
||||
});
|
||||
}
|
||||
|
||||
private fanavaranDamageReplyActorId(
|
||||
claimCase?: { evaluation?: object } | null,
|
||||
): unknown {
|
||||
const evaluation = claimCase?.evaluation as
|
||||
| {
|
||||
damageExpertReplyFinal?: { actorDetail?: { actorId?: unknown } };
|
||||
damageExpertReply?: { actorDetail?: { actorId?: unknown } };
|
||||
}
|
||||
| undefined;
|
||||
const active = getActiveV2ExpertReply({
|
||||
evaluation: claimCase?.evaluation as Record<string, unknown> | undefined,
|
||||
});
|
||||
return (
|
||||
(active?.reply as { actorDetail?: { actorId?: unknown } } | undefined)
|
||||
?.actorDetail?.actorId ??
|
||||
evaluation?.damageExpertReplyFinal?.actorDetail?.actorId ??
|
||||
evaluation?.damageExpertReply?.actorDetail?.actorId
|
||||
);
|
||||
}
|
||||
|
||||
private async tryResolveFanavaranExpertiseClaimExpertId(
|
||||
blame: {
|
||||
isMadeByFileMaker?: boolean;
|
||||
@@ -3647,20 +3681,7 @@ export class ClaimRequestManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
const evaluation = claimCase?.evaluation as
|
||||
| {
|
||||
damageExpertReplyFinal?: { actorDetail?: { actorId?: unknown } };
|
||||
damageExpertReply?: { actorDetail?: { actorId?: unknown } };
|
||||
}
|
||||
| undefined;
|
||||
const active = getActiveV2ExpertReply(
|
||||
claimCase as unknown as { evaluation?: Record<string, unknown> },
|
||||
);
|
||||
const actorId =
|
||||
(active?.reply as { actorDetail?: { actorId?: unknown } } | undefined)
|
||||
?.actorDetail?.actorId ??
|
||||
evaluation?.damageExpertReplyFinal?.actorDetail?.actorId ??
|
||||
evaluation?.damageExpertReply?.actorDetail?.actorId;
|
||||
const actorId = this.fanavaranDamageReplyActorId(claimCase);
|
||||
if (actorId == null || String(actorId).trim() === "") {
|
||||
return {
|
||||
claimExpertId: null,
|
||||
|
||||
Reference in New Issue
Block a user