Add TejaratNo notifier review and submission validation

This commit is contained in:
SepehrYahyaee
2026-10-10 12:51:11 +03:30
parent a410655faa
commit 8f568f379c
14 changed files with 588 additions and 34 deletions
+43
View File
@@ -0,0 +1,43 @@
import type { FanavaranClientKey } from "src/core/config/fanavaran-client.config";
/** Tenant-supplied codebooks. No unverified remote lookup paths or inferred IDs. */
export const TEJARAT_NOTIFIER_LOOKUPS = {
"notifier-type": [
{ Caption: "آسيب ديده", Id: 5516, IsActive: 1 },
{ Caption: "مقصر حادثه", Id: 5517, IsActive: 1 },
],
"notifier-relation": [
{ Caption: "آسيب ديده", Id: 5519, IsActive: 1 },
{ Caption: "نماينده آسيب ديده", Id: 5520, IsActive: 1 },
{ Caption: "مالک", Id: 5521, IsActive: 1 },
{ Caption: "بيمه گذار", Id: 5522, IsActive: 1 },
{ Caption: "راننده", Id: 5523, IsActive: 1 },
{ Caption: "نماينده راننده", Id: 5524, IsActive: 1 },
{ Caption: "نماينده بيمه گذار", Id: 5525, IsActive: 1 },
{ Caption: "نماينده مالک", Id: 5526, IsActive: 1 },
],
} as const;
export const TEJARAT_NOTIFIER_FIELDS = {
NotifierTypeId: "notifier-type",
NotifierRelationId: "notifier-relation",
} as const;
export function tejaratNotifierLookup(name: string) {
if (!Object.prototype.hasOwnProperty.call(TEJARAT_NOTIFIER_LOOKUPS, name))
return undefined;
return TEJARAT_NOTIFIER_LOOKUPS[
name as keyof typeof TEJARAT_NOTIFIER_LOOKUPS
].map((row) => ({ ...row }));
}
/** Both selections must be explicit, canonical numeric IDs; 5518 is excluded. */
export function hasReviewedTejaratNotifier(
values: Record<string, unknown> | null | undefined,
clientKey: FanavaranClientKey,
): boolean {
if (clientKey !== "tejaratno") return true;
return Object.entries(TEJARAT_NOTIFIER_FIELDS).every(([key, lookup]) =>
TEJARAT_NOTIFIER_LOOKUPS[lookup].some((row) => row.Id === values?.[key]),
);
}