Merge pull request 'feat: implement PolicyApplicabilityService to evaluate policy eligibility based on jurisdiction and cohort matches' (#28) from azeem into development
Reviewed-on: https://gitea.maskantech.in/gitea_admin/aeroresolve_backend/pulls/28
This commit is contained in:
@@ -56,6 +56,12 @@ export class PolicyApplicabilityService {
|
|||||||
const policyJurisdictions = policy.jurisdictions || [];
|
const policyJurisdictions = policy.jurisdictions || [];
|
||||||
|
|
||||||
if (policyJurisdictions.length > 0) {
|
if (policyJurisdictions.length > 0) {
|
||||||
|
const isGlobal = policyJurisdictions.some((pj) => {
|
||||||
|
const pJVal = (pj.jurisdiction?.value || pj.jurisdiction?.label || '').trim().toUpperCase();
|
||||||
|
return pJVal === 'GLOBAL';
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isGlobal) {
|
||||||
if (!incidentJurisdiction) {
|
if (!incidentJurisdiction) {
|
||||||
this.logger.warn(
|
this.logger.warn(
|
||||||
`[POLICY REJECTED ❌] Policy "${policy.policyName}" (ID: ${policy.id}) requires a jurisdiction, but incident context has no jurisdiction.`,
|
`[POLICY REJECTED ❌] Policy "${policy.policyName}" (ID: ${policy.id}) requires a jurisdiction, but incident context has no jurisdiction.`,
|
||||||
@@ -68,6 +74,7 @@ export class PolicyApplicabilityService {
|
|||||||
const hasMatch = policyJurisdictions.some((pj) => {
|
const hasMatch = policyJurisdictions.some((pj) => {
|
||||||
const pJId = pj.jurisdictionId;
|
const pJId = pj.jurisdictionId;
|
||||||
const pJVal = (pj.jurisdiction?.value || pj.jurisdiction?.label || '').trim().toUpperCase();
|
const pJVal = (pj.jurisdiction?.value || pj.jurisdiction?.label || '').trim().toUpperCase();
|
||||||
|
|
||||||
const matchesId = Boolean(pJId) && pJId === incidentJurisdiction;
|
const matchesId = Boolean(pJId) && pJId === incidentJurisdiction;
|
||||||
const matchesVal =
|
const matchesVal =
|
||||||
Boolean(pJVal) &&
|
Boolean(pJVal) &&
|
||||||
@@ -82,6 +89,7 @@ export class PolicyApplicabilityService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Audience / Cohort Match
|
// 2. Audience / Cohort Match
|
||||||
if (policy.audienceType === AudienceType.ALL) {
|
if (policy.audienceType === AudienceType.ALL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user