dynamic locations

This commit is contained in:
2026-11-11 14:10:01 +03:30
parent 5e3bd02243
commit 658a8a74cc
18 changed files with 454 additions and 111 deletions
@@ -3365,17 +3365,15 @@ export class ClaimRequestManagementService {
}
/**
* Parsian + V4/V5 FileMaker flows: Location from file-maker.locations[].id,
* else file-reviewer.locations[].id, else tenant auth.location.
* Fanavaran HTTP Location from assigned staff `locations[].id`
* (file-maker / file-reviewer / field / blame / damage expert), for every
* tenant. Falls back to tenant auth.location only when no staff location is set.
*/
private async resolveFanavaranLocationForClaim(
claimCaseId: string,
clientKey: FanavaranClientKey,
): Promise<string> {
const defaultLocation = getFanavaranClientProfile(clientKey).auth.location;
if (clientKey !== "parsian") {
return defaultLocation;
}
try {
const claimCase = await this.claimCaseDbService.findById(claimCaseId);
@@ -3386,19 +3384,21 @@ export class ClaimRequestManagementService {
const blame = await this.blameRequestDbService.findById(
String(claimCase.blameRequestId),
);
if (!(blame as any)?.isMadeByFileMaker) {
if (!blame) {
return defaultLocation;
}
return this.fanavaranLocationService.resolveBusinessLocation({
clientKey,
isMadeByFileMaker: true,
fileMakerId: (blame as any)?.initiatedByFieldExpertId
? String((blame as any).initiatedByFieldExpertId)
: null,
fileReviewerId: (blame as any)?.assignedFileReviewerId
? String((blame as any).assignedFileReviewerId)
: null,
staffCandidateIds: [
(blame as any)?.initiatedByFieldExpertId,
(blame as any)?.expert?.assignedExpertId,
(blame as any)?.expert?.decision?.decidedByExpertId,
(claimCase as any)?.initiatedByFieldExpertId,
this.fanavaranDamageReplyActorId(claimCase),
(claimCase as any)?.workflow?.assignedForReviewBy?.actorId,
(blame as any)?.assignedFileReviewerId,
],
});
} catch (error) {
this.logger.warn(