fixed branch being mandatory

This commit is contained in:
SepehrYahyaee
2026-09-12 10:18:17 +03:30
parent 55da8188a9
commit ebe45646c1
7 changed files with 209 additions and 1 deletions

View File

@@ -230,4 +230,38 @@ describe("buildInsurerFileReport", () => {
"نیاز به تعویض سپر جلو", "نیاز به تعویض سپر جلو",
); );
}); });
it("uses the stored V4 licence type for a driver who differs from the policyholder", () => {
const report = buildInsurerFileReport({
overview: { publicId: "A00011" },
blame: {
type: "THIRD_PARTY",
parties: [
{
role: "FIRST",
person: { userId: "guilty", fullName: "مقصر" },
},
{
role: "SECOND",
person: {
userId: "damaged",
fullName: "بیمه‌گذار زیان‌دیده",
driverIsInsurer: false,
nationalCodeOfDriver: "0123456789",
driverLicense: "L-123",
licenseType: "پایه یک",
},
},
],
expert: { decision: { guiltyPartyId: "guilty" } },
},
});
expect(getFieldValue(report, PR.driverSection, PR.nationalCode)).toBe(
"0123456789",
);
expect(getFieldValue(report, PR.driverSection, PR.licenseType)).toBe(
"پایه یک",
);
});
}); });

View File

@@ -565,7 +565,10 @@ function buildDriverSection(
{ label: PR.name, value: asString(person.fullName) }, { label: PR.name, value: asString(person.fullName) },
{ {
label: PR.licenseType, label: PR.licenseType,
value: licenseType ?? (person.driverLicense ? PR.driverLicense : undefined), value:
licenseType ??
asString(person.licenseType) ??
(person.driverLicense ? PR.driverLicense : undefined),
}, },
{ {
label: PR.licenseDate, label: PR.licenseDate,

View File

@@ -19,6 +19,41 @@ describe("fanavaranClaimReferences", () => {
}); });
}); });
it("exposes the persisted Fanavaran reference codes to expert detail APIs", () => {
expect(
fanavaranClaimReferences({
status: ClaimCaseStatus.COMPLETED,
claimId: 100,
claimNo: 101,
dmgCaseId: 102,
expertiseId: 103,
fanavaranSync: {
baseClaim: { policyId: 104 },
damageCase: {
driverId: 105,
vehicleKindId: 106,
plaqueKindId: 107,
plaqueSampleId: 108,
accidentVehicleUsedId: 109,
insuranceCorpId: 110,
},
},
}),
).toEqual({
claimId: 100,
claimNo: 101,
dmgCaseId: 102,
expertiseId: 103,
policyId: 104,
driverId: 105,
vehicleKindId: 106,
plaqueKindId: 107,
plaqueSampleId: 108,
accidentVehicleUsedId: 109,
insuranceCorpId: 110,
});
});
it("omits missing ids", () => { it("omits missing ids", () => {
expect( expect(
fanavaranClaimReferences({ fanavaranClaimReferences({

View File

@@ -5,6 +5,13 @@ export type FanavaranClaimReferences = {
claimNo?: number; claimNo?: number;
dmgCaseId?: number; dmgCaseId?: number;
expertiseId?: number; expertiseId?: number;
policyId?: number;
driverId?: number;
vehicleKindId?: number;
plaqueKindId?: number;
plaqueSampleId?: number;
accidentVehicleUsedId?: number;
insuranceCorpId?: number;
}; };
/** /**
@@ -16,6 +23,10 @@ export function fanavaranClaimReferences(claim: {
claimNo?: number | null; claimNo?: number | null;
dmgCaseId?: number | null; dmgCaseId?: number | null;
expertiseId?: number | null; expertiseId?: number | null;
fanavaranSync?: {
baseClaim?: FanavaranReferenceStage | null;
damageCase?: FanavaranReferenceStage | null;
} | null;
}): FanavaranClaimReferences | undefined { }): FanavaranClaimReferences | undefined {
if (claim.status !== ClaimCaseStatus.COMPLETED) { if (claim.status !== ClaimCaseStatus.COMPLETED) {
return undefined; return undefined;
@@ -27,5 +38,43 @@ export function fanavaranClaimReferences(claim: {
if (claim.dmgCaseId != null) refs.dmgCaseId = claim.dmgCaseId; if (claim.dmgCaseId != null) refs.dmgCaseId = claim.dmgCaseId;
if (claim.expertiseId != null) refs.expertiseId = claim.expertiseId; if (claim.expertiseId != null) refs.expertiseId = claim.expertiseId;
const baseClaim = claim.fanavaranSync?.baseClaim;
const damageCase = claim.fanavaranSync?.damageCase;
if (baseClaim?.policyId != null) refs.policyId = baseClaim.policyId;
if ((damageCase?.driverId ?? baseClaim?.driverId) != null) {
refs.driverId = damageCase?.driverId ?? baseClaim?.driverId;
}
if ((damageCase?.vehicleKindId ?? baseClaim?.vehicleKindId) != null) {
refs.vehicleKindId =
damageCase?.vehicleKindId ?? baseClaim?.vehicleKindId;
}
if (damageCase?.plaqueKindId != null) {
refs.plaqueKindId = damageCase.plaqueKindId;
}
if (damageCase?.plaqueSampleId != null) {
refs.plaqueSampleId = damageCase.plaqueSampleId;
}
if (
(damageCase?.accidentVehicleUsedId ?? baseClaim?.accidentVehicleUsedId) !=
null
) {
refs.accidentVehicleUsedId =
damageCase?.accidentVehicleUsedId ?? baseClaim?.accidentVehicleUsedId;
}
if ((damageCase?.insuranceCorpId ?? baseClaim?.insuranceCorpId) != null) {
refs.insuranceCorpId =
damageCase?.insuranceCorpId ?? baseClaim?.insuranceCorpId;
}
return Object.keys(refs).length > 0 ? refs : undefined; return Object.keys(refs).length > 0 ? refs : undefined;
} }
type FanavaranReferenceStage = {
policyId?: number | null;
driverId?: number | null;
vehicleKindId?: number | null;
plaqueKindId?: number | null;
plaqueSampleId?: number | null;
accidentVehicleUsedId?: number | null;
insuranceCorpId?: number | null;
};

View File

@@ -178,6 +178,13 @@ export class ClaimDetailV2ResponseDto {
claimNo?: number; claimNo?: number;
dmgCaseId?: number; dmgCaseId?: number;
expertiseId?: number; expertiseId?: number;
policyId?: number;
driverId?: number;
vehicleKindId?: number;
plaqueKindId?: number;
plaqueSampleId?: number;
accidentVehicleUsedId?: number;
insuranceCorpId?: number;
}; };
@ApiPropertyOptional({ @ApiPropertyOptional({

View File

@@ -104,6 +104,69 @@ describe("RequestManagementService FileReviewer inbox", () => {
).rejects.toThrow("does not belong to your organization"); ).rejects.toThrow("does not belong to your organization");
}); });
it("returns party identity, VIN plate and claim payment/reference data to the V4 reviewer", async () => {
const { service } = createService([]);
const request = {
...sealedFile,
parties: [
{
role: "FIRST",
person: {
clientId,
fullName: "راننده و بیمه‌گذار نمونه",
nationalCodeOfInsurer: "1111111111",
nationalCodeOfDriver: "2222222222",
driverIsInsurer: false,
licenseType: "پایه یک",
driverLicense: "L-123",
},
vehicle: { plateId: "11-22-ب-333", vin: "VIN-123" },
},
],
};
(service as any).blameRequestDbService.findById = jest
.fn()
.mockResolvedValue(request);
(service as any).claimCaseDbService = {
findOne: jest.fn().mockResolvedValue({
_id: new Types.ObjectId(),
status: "COMPLETED",
workflow: {},
money: { sheba: "IR123" },
claimId: 101,
fanavaranSync: { baseClaim: { policyId: 202 } },
}),
};
const result = await service.getMyFileReviewerFileDetail(
{
sub: String(reviewerId),
role: RoleEnum.FILE_REVIEWER,
clientKey: String(clientId),
},
String(sealedFile._id),
);
expect(result.parties[0]).toEqual(
expect.objectContaining({
person: expect.objectContaining({
fullName: "راننده و بیمه‌گذار نمونه",
nationalCodeOfInsurer: "1111111111",
nationalCodeOfDriver: "2222222222",
licenseType: "پایه یک",
}),
vehicle: expect.objectContaining({
plateId: "11-22-ب-333",
vin: "VIN-123",
}),
}),
);
expect(result.money).toEqual({ sheba: "IR123" });
expect(result.fanavaran).toEqual(
expect.objectContaining({ claimId: 101, policyId: 202 }),
);
});
it("does not let a reviewer claim another tenant's file through its linked claim ID", async () => { it("does not let a reviewer claim another tenant's file through its linked claim ID", async () => {
const blameRequestDbService = { const blameRequestDbService = {
findById: jest.fn().mockResolvedValue({ findById: jest.fn().mockResolvedValue({

View File

@@ -116,6 +116,7 @@ import {
} from "src/helpers/tenant-scope"; } from "src/helpers/tenant-scope";
import { resolveLinkedUserIdStrings } from "src/helpers/user-access-resolver"; import { resolveLinkedUserIdStrings } from "src/helpers/user-access-resolver";
import { normalizePlateText } from "src/utils/plate-normalizer/plate-normalizer.service"; import { normalizePlateText } from "src/utils/plate-normalizer/plate-normalizer.service";
import { fanavaranClaimReferences } from "src/claim-request-management/fanavaran-claim-references";
/** /**
* Formats a compact Jalali date (number or string like 13780624) as YYYY/MM/DD. * Formats a compact Jalali date (number or string like 13780624) as YYYY/MM/DD.
@@ -11530,10 +11531,15 @@ export class RequestManagementService {
parties: (plain.parties ?? []).map((p: any) => ({ parties: (plain.parties ?? []).map((p: any) => ({
role: p.role, role: p.role,
person: { person: {
fullName: p.person?.fullName,
phoneNumber: p.person?.phoneNumber, phoneNumber: p.person?.phoneNumber,
nationalCodeOfInsurer: p.person?.nationalCodeOfInsurer, nationalCodeOfInsurer: p.person?.nationalCodeOfInsurer,
nationalCodeOfDriver: p.person?.nationalCodeOfDriver, nationalCodeOfDriver: p.person?.nationalCodeOfDriver,
driverIsInsurer: p.person?.driverIsInsurer, driverIsInsurer: p.person?.driverIsInsurer,
insurerBirthday: p.person?.insurerBirthday,
driverBirthday: p.person?.driverBirthday,
insurerLicense: p.person?.insurerLicense,
driverLicense: p.person?.driverLicense,
userId: p.person?.userId ? String(p.person.userId) : undefined, userId: p.person?.userId ? String(p.person.userId) : undefined,
clientId: p.person?.clientId ? String(p.person.clientId) : undefined, clientId: p.person?.clientId ? String(p.person.clientId) : undefined,
licenseType: p.person?.licenseType ?? undefined, licenseType: p.person?.licenseType ?? undefined,
@@ -11547,6 +11553,7 @@ export class RequestManagementService {
} : undefined, } : undefined,
vehicle: p.vehicle ? { vehicle: p.vehicle ? {
plateId: p.vehicle.plateId, plateId: p.vehicle.plateId,
vin: p.vehicle.vin,
name: p.vehicle.name, name: p.vehicle.name,
type: p.vehicle.type, type: p.vehicle.type,
} : undefined, } : undefined,
@@ -11557,6 +11564,8 @@ export class RequestManagementService {
...(claimPlain ? { ...(claimPlain ? {
claimStatus: claimPlain.status, claimStatus: claimPlain.status,
claimWorkflow: claimPlain.workflow, claimWorkflow: claimPlain.workflow,
money: claimPlain.money ?? null,
fanavaran: fanavaranClaimReferences(claimPlain),
fileMakerRejectionCount: claimPlain.fileMakerRejectionCount ?? 0, fileMakerRejectionCount: claimPlain.fileMakerRejectionCount ?? 0,
fileMakerRejectionReason: claimPlain.fileMakerRejectionReason ?? null, fileMakerRejectionReason: claimPlain.fileMakerRejectionReason ?? null,
evaluation: claimPlain.evaluation evaluation: claimPlain.evaluation
@@ -11682,10 +11691,15 @@ export class RequestManagementService {
parties: (plain.parties ?? []).map((p: any) => ({ parties: (plain.parties ?? []).map((p: any) => ({
role: p.role, role: p.role,
person: { person: {
fullName: p.person?.fullName,
phoneNumber: p.person?.phoneNumber, phoneNumber: p.person?.phoneNumber,
nationalCodeOfInsurer: p.person?.nationalCodeOfInsurer, nationalCodeOfInsurer: p.person?.nationalCodeOfInsurer,
nationalCodeOfDriver: p.person?.nationalCodeOfDriver, nationalCodeOfDriver: p.person?.nationalCodeOfDriver,
driverIsInsurer: p.person?.driverIsInsurer, driverIsInsurer: p.person?.driverIsInsurer,
insurerBirthday: p.person?.insurerBirthday,
driverBirthday: p.person?.driverBirthday,
insurerLicense: p.person?.insurerLicense,
driverLicense: p.person?.driverLicense,
userId: p.person?.userId ? String(p.person.userId) : undefined, userId: p.person?.userId ? String(p.person.userId) : undefined,
clientId: p.person?.clientId ? String(p.person.clientId) : undefined, clientId: p.person?.clientId ? String(p.person.clientId) : undefined,
licenseType: p.person?.licenseType ?? undefined, licenseType: p.person?.licenseType ?? undefined,
@@ -11699,6 +11713,7 @@ export class RequestManagementService {
} : undefined, } : undefined,
vehicle: p.vehicle ? { vehicle: p.vehicle ? {
plateId: p.vehicle.plateId, plateId: p.vehicle.plateId,
vin: p.vehicle.vin,
name: p.vehicle.name, name: p.vehicle.name,
type: p.vehicle.type, type: p.vehicle.type,
} : undefined, } : undefined,
@@ -11719,6 +11734,8 @@ export class RequestManagementService {
...(claimPlain ? { ...(claimPlain ? {
claimStatus: claimPlain.status, claimStatus: claimPlain.status,
claimWorkflow: claimPlain.workflow, claimWorkflow: claimPlain.workflow,
money: claimPlain.money ?? null,
fanavaran: fanavaranClaimReferences(claimPlain),
fileMakerRejectionCount: claimPlain.fileMakerRejectionCount ?? 0, fileMakerRejectionCount: claimPlain.fileMakerRejectionCount ?? 0,
fileMakerRejectionReason: claimPlain.fileMakerRejectionReason ?? null, fileMakerRejectionReason: claimPlain.fileMakerRejectionReason ?? null,
evaluation: claimPlain.evaluation evaluation: claimPlain.evaluation