forked from Yara724/api
location dynamicallllllly finally or not ?
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { ForbiddenException, Injectable, Logger } from "@nestjs/common";
|
||||
import {
|
||||
BadRequestException,
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
Logger,
|
||||
} from "@nestjs/common";
|
||||
import {
|
||||
FanavaranClientKey,
|
||||
getFanavaranClientProfile,
|
||||
@@ -45,11 +50,13 @@ export class FanavaranLocationService {
|
||||
|
||||
/**
|
||||
* First staff candidate with a stored `locations[].id` wins.
|
||||
* Fallback: tenant auth.location (lookups / cases with no staff locations).
|
||||
* Tenant auth.location is allowed only when requireStaffLocation is false.
|
||||
*/
|
||||
async resolveBusinessLocation(input: {
|
||||
clientKey: FanavaranClientKey;
|
||||
staffCandidateIds?: Array<string | null | undefined>;
|
||||
/** Claim submissions must never silently use a tenant-wide branch. */
|
||||
requireStaffLocation?: boolean;
|
||||
/** @deprecated Prefer staffCandidateIds — kept for older call sites. */
|
||||
isMadeByFileMaker?: boolean;
|
||||
fileMakerId?: string | null;
|
||||
@@ -79,8 +86,17 @@ export class FanavaranLocationService {
|
||||
}
|
||||
}
|
||||
|
||||
this.logger.debug(
|
||||
`Fanavaran Location fallback to tenant default → ${defaultLocation}`,
|
||||
if (input.requireStaffLocation) {
|
||||
throw new BadRequestException({
|
||||
code: "FANAVARAN_STAFF_LOCATION_MISSING",
|
||||
message:
|
||||
"Cannot submit this claim to Fanavaran: no attached expert has a configured locations[].id (OpBUId). Configure the responsible staff member's location and retry.",
|
||||
staffCandidateIds: [...seen],
|
||||
});
|
||||
}
|
||||
|
||||
this.logger.warn(
|
||||
`[${input.clientKey}] Fanavaran Location fallback to tenant default=${defaultLocation}; no stored locations[].id found for staff candidates=${[...seen].join(",") || "none"}`,
|
||||
);
|
||||
return defaultLocation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user