forked from Yara724/api
Compare commits
9 Commits
401ad6a143
...
0eaf55e73c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eaf55e73c | ||
|
|
5b77241f28 | ||
|
|
cc8a96c875 | ||
|
|
5812637a1e | ||
|
|
287978a555 | ||
|
|
fe22e69351 | ||
|
|
b5b18114d8 | ||
|
|
d060b6d9e2 | ||
|
|
c64f23091a |
219
docs/inquiry-participants-frontend-guide.fa.md
Normal file
219
docs/inquiry-participants-frontend-guide.fa.md
Normal file
@@ -0,0 +1,219 @@
|
||||
# راهنمای فرانتاند برای ارسال اطلاعات استعلام
|
||||
|
||||
این سند قرارداد نهایی فرانتاند برای مرحله استعلام است. از این به بعد اطلاعات اشخاص و خودرو باید با ساختار نقشمحور زیر ارسال شود. فیلدهای تخت قدیمی مانند `nationalCodeOfDriver` و `nationalCodeOfInsurer` دیگر ورودی معتبر نیستند.
|
||||
|
||||
## پاسخ کوتاه درباره `unknown`
|
||||
|
||||
`unknown` فقط برای یک حالت استثنایی لازم است: وقتی در مرحله طرف زیاندیده یک پرونده `THIRD_PARTY`، هویت بیمهگذار شخص ثالث واقعاً مشخص نیست.
|
||||
|
||||
```json
|
||||
{
|
||||
"thirdPartyPolicyholder": { "unknown": true }
|
||||
}
|
||||
```
|
||||
|
||||
قواعد آن:
|
||||
|
||||
- فقط برای طرف زیاندیده (`SECOND`) مجاز است؛ برای طرف مقصر (`FIRST`) خطا برمیگردد.
|
||||
- فقط برای `thirdPartyPolicyholder` مجاز است؛ برای راننده، مالک یا بیمهگذار بدنه مجاز نیست.
|
||||
- وقتی `unknown: true` ارسال میشود، هیچ فیلد هویتی دیگری در همان آبجکت نفرستید.
|
||||
- در استعلام پلاکی شخص ثالث، استعلام بیمهگذار عمداً skip میشود و سیستم نباید شخصی را حدس بزند.
|
||||
- استعلامهای راننده، مالکیت خودرو و اطلاعات افراد شناختهشده همچنان اجرا میشوند.
|
||||
- اگر هویت بیمهگذار مشخص است، اصلاً از `unknown` استفاده نکنید و اطلاعات واقعی یا `sameAs` را بفرستید.
|
||||
|
||||
## ساختار کلی درخواست
|
||||
|
||||
برای پرونده `THIRD_PARTY`:
|
||||
|
||||
```json
|
||||
{
|
||||
"driver": {
|
||||
"nationalCode": "0012345678",
|
||||
"birthday": "1370/01/01",
|
||||
"hasDrivingLicense": true,
|
||||
"licenseNumber": "123456789",
|
||||
"licenseType": "1"
|
||||
},
|
||||
"vehicleOwner": { "sameAs": "DRIVER" },
|
||||
"thirdPartyPolicyholder": { "sameAs": "VEHICLE_OWNER" },
|
||||
"vehicle": {
|
||||
"registrationState": "CURRENT",
|
||||
"currentPlate": {
|
||||
"leftDigits": "44",
|
||||
"centerAlphabet": "ب",
|
||||
"centerDigits": "111",
|
||||
"ir": "22"
|
||||
},
|
||||
"isNewCar": false
|
||||
},
|
||||
"sheba": "IR123456789012345678901234"
|
||||
}
|
||||
```
|
||||
|
||||
برای پرونده `CAR_BODY`، نقش بیمهگذار بدنه هم الزامی است:
|
||||
|
||||
```json
|
||||
{
|
||||
"driver": {
|
||||
"nationalCode": "0012345678",
|
||||
"birthday": "1370/01/01",
|
||||
"hasDrivingLicense": false
|
||||
},
|
||||
"vehicleOwner": { "sameAs": "DRIVER" },
|
||||
"thirdPartyPolicyholder": {
|
||||
"nationalCode": "0023456789",
|
||||
"birthday": "1360/02/02"
|
||||
},
|
||||
"carBodyPolicyholder": {
|
||||
"nationalCode": "0034567890",
|
||||
"birthday": "1350/03/03"
|
||||
},
|
||||
"vehicle": {
|
||||
"currentPlate": {
|
||||
"leftDigits": "44",
|
||||
"centerAlphabet": "ب",
|
||||
"centerDigits": "111",
|
||||
"ir": "22"
|
||||
},
|
||||
"isNewCar": false
|
||||
},
|
||||
"sheba": "IR123456789012345678901234"
|
||||
}
|
||||
```
|
||||
|
||||
`sheba` فقط در routeهایی که قبلاً اطلاعات بانکی را در مرحله استعلام دریافت میکردند ارسال میشود؛ در V6 مرکز تماس، شماره شبا در این body نیست و بعداً توسط کاربر دریافت میشود.
|
||||
|
||||
## نقشها و فیلدهای هر شخص
|
||||
|
||||
هر نقش باید یکی از این دو حالت را داشته باشد، نه هر دو را:
|
||||
|
||||
1. اطلاعات یک شخص جدید؛ یا
|
||||
2. ارجاع با `sameAs` به شخصی که قبلاً در همین درخواست معرفی شده است.
|
||||
|
||||
| فیلد | کاربرد | وضعیت |
|
||||
| --- | --- | --- |
|
||||
| `nationalCode` | کد ملی شخص | برای شخص جدید الزامی |
|
||||
| `birthday` | تاریخ تولد جلالی | برای شخص جدید الزامی |
|
||||
| `fullName` | نام نمایشی شخص | اختیاری |
|
||||
| `sameAs` | اتصال این نقش به نقش دیگر | بهجای اطلاعات شخص جدید |
|
||||
| `unknown` | نامشخص بودن بیمهگذار ثالث | فقط `SECOND` در `THIRD_PARTY` |
|
||||
| `hasDrivingLicense` | داشتن گواهینامه راننده | برای نقش راننده الزامی |
|
||||
| `licenseNumber` | شماره گواهینامه | اگر `hasDrivingLicense=true` الزامی |
|
||||
| `licenseType` | نوع گواهینامه | اگر `hasDrivingLicense=true` الزامی |
|
||||
|
||||
مقادیر مجاز `sameAs` عبارتاند از:
|
||||
|
||||
- `DRIVER`
|
||||
- `VEHICLE_OWNER`
|
||||
- `THIRD_PARTY_POLICYHOLDER`
|
||||
- `CAR_BODY_POLICYHOLDER`
|
||||
|
||||
برای `sameAs` هیچکدام از `nationalCode`، `birthday`، `fullName`، اطلاعات گواهینامه یا `phoneNumber` را در همان آبجکت نفرستید.
|
||||
|
||||
شماره تلفن بخشی از هویت استعلام نیست و در این DTOها وجود ندارد. احراز هویت پیامکی و شماره تماس طرفین از این مرحله جداست.
|
||||
|
||||
## اطلاعات خودرو و پلاک
|
||||
|
||||
| فیلد | کاربرد | وضعیت |
|
||||
| --- | --- | --- |
|
||||
| `vehicle.registrationState` | وضعیت ثبت رسمی خودرو | `CURRENT` یا `RECENTLY_TRANSFERRED`؛ پیشفرض `CURRENT` |
|
||||
| `vehicle.currentPlate` | پلاک رسمی فعلی و شناسه اصلی خودرو | الزامی |
|
||||
| `vehicle.previousPlate` | پلاک قبلی در انتقال اخیر | فقط در `RECENTLY_TRANSFERRED` |
|
||||
| `vehicle.vin` | شماره شاسی/VIN | در انتقال اخیر الزامی؛ حداکثر ۱۷ کاراکتر |
|
||||
| `vehicle.isNewCar` | نو بودن خودرو | اختیاری |
|
||||
|
||||
اجزای پلاک:
|
||||
|
||||
```json
|
||||
{
|
||||
"leftDigits": "44",
|
||||
"centerAlphabet": "ب",
|
||||
"centerDigits": "111",
|
||||
"ir": "22"
|
||||
}
|
||||
```
|
||||
|
||||
`leftDigits`، `centerDigits` و `ir` را میتوان بهصورت string یا number فرستاد؛ ارسال string پیشنهاد میشود تا صفرهای ابتدایی از بین نروند. `centerAlphabet` باید حرف فارسی پلاک باشد.
|
||||
|
||||
### انتقال اخیر
|
||||
|
||||
```json
|
||||
{
|
||||
"vehicle": {
|
||||
"registrationState": "RECENTLY_TRANSFERRED",
|
||||
"currentPlate": {
|
||||
"leftDigits": "44",
|
||||
"centerAlphabet": "ب",
|
||||
"centerDigits": "111",
|
||||
"ir": "22"
|
||||
},
|
||||
"previousPlate": {
|
||||
"leftDigits": "55",
|
||||
"centerAlphabet": "ج",
|
||||
"centerDigits": "222",
|
||||
"ir": "33"
|
||||
},
|
||||
"vin": "NAAM01E15HK123456"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
سیستم ابتدا پلاک فعلی را استعلام میکند. اگر نتیجه ناموجود، منقضی یا فاقد بیمهنامه مرتبط باشد، پلاک قبلی را امتحان میکند. نتیجه پلاک قبلی فقط در صورت تطبیق VIN پذیرفته میشود؛ پلاک قبلی هرگز جایگزین پلاک فعلی نمیشود.
|
||||
|
||||
حتی در route مربوط به VIN، آبجکت `vehicle` از قرارداد مشترک استفاده میکند و `currentPlate` در قرارداد فعلی الزامی است. مقدار VIN در `vehicle.vin` قرار میگیرد، نه در فیلد سطح بالای `vin`.
|
||||
|
||||
## ترتیب پیشنهادی نمایش فرم
|
||||
|
||||
1. پلاک فعلی و وضعیت انتقال خودرو را بگیرید.
|
||||
2. اگر انتقال اخیر بود، پلاک قبلی و VIN را بگیرید.
|
||||
3. اطلاعات راننده و وضعیت گواهینامه را بگیرید.
|
||||
4. بپرسید مالک خودرو همان راننده است یا شخص دیگری؛ در حالت یکسان از `sameAs` استفاده کنید.
|
||||
5. بیمهگذار شخص ثالث را از بین راننده، مالک یا شخص دیگر انتخاب کنید.
|
||||
6. در `CAR_BODY` همین کار را برای بیمهگذار بدنه انجام دهید.
|
||||
7. خلاصه اطلاعات را به کاربر نشان دهید و سپس درخواست استعلام را ارسال کنید.
|
||||
|
||||
## مسیرهای اصلی
|
||||
|
||||
بدنه درخواست در همه این مسیرها همین ساختار را دارد:
|
||||
|
||||
| جریان | مسیر پلاک | مسیر VIN |
|
||||
| --- | --- | --- |
|
||||
| کاربر V2 | `/v2/blame-request-management/initial-form/:requestId` | `/v2/blame-request-management/initial-form-vin/:requestId` |
|
||||
| کارشناس/پروندهساز V3 تا V5 | `.../run-inquiries/:requestId` | `.../run-inquiries-vin/:requestId` |
|
||||
| مرکز تماس V6 | `/v6/call-center-blame/run-inquiry/:requestId` | `/v6/call-center-blame/run-inquiry-vin/:requestId` |
|
||||
|
||||
در جریانهای V3 تا V5، فراخوان اول برای طرف مقصر (`FIRST`) و فراخوان دوم، فقط در `THIRD_PARTY`، برای طرف زیاندیده (`SECOND`) است. همین تفاوت تعیین میکند که `unknown` مجاز است یا نه.
|
||||
|
||||
## فیلدهایی که نباید ارسال شوند
|
||||
|
||||
این فیلدها دیگر بخشی از قرارداد ورودی نیستند و ارسال آنها باعث خطای اعتبارسنجی میشود:
|
||||
|
||||
```text
|
||||
nationalCodeOfDriver
|
||||
driverBirthday
|
||||
driverLicense
|
||||
licenseType // در سطح بالا؛ مقدار صحیح داخل driver است
|
||||
nationalCodeOfInsurer
|
||||
insurerBirthday
|
||||
insurerLicense
|
||||
driverIsInsurer
|
||||
userNoCertificate
|
||||
plate // در سطح بالا؛ مقدار صحیح داخل vehicle.currentPlate است
|
||||
plateId
|
||||
vin // در سطح بالا؛ مقدار صحیح داخل vehicle.vin است
|
||||
isNewCar // در سطح بالا؛ مقدار صحیح داخل vehicle.isNewCar است
|
||||
phoneNumber // در participantها
|
||||
```
|
||||
|
||||
## خطاهای رایج فرانتاند
|
||||
|
||||
- ارسال `vehicleOwner` بهصورت خالی؛ باید شخص جدید یا `sameAs` باشد.
|
||||
- استفاده از `sameAs` همراه با `nationalCode` یا `birthday`.
|
||||
- ارسال `carBodyPolicyholder` برای `THIRD_PARTY`.
|
||||
- ارسال `unknown` برای طرف مقصر یا برای نقشی غیر از بیمهگذار ثالث.
|
||||
- فرستادن `previousPlate` بدون `registrationState=RECENTLY_TRANSFERRED`.
|
||||
- فرستادن `RECENTLY_TRANSFERRED` بدون `previousPlate` یا `vin`.
|
||||
- قرار دادن VIN یا پلاک در سطح بالای body.
|
||||
- ارسال شماره تلفن در آبجکت شخص.
|
||||
|
||||
مستند مدل دامنه و جزئیات تصمیم معماری در [inquiry-participants-proposal.fa.md](./inquiry-participants-proposal.fa.md) قرار دارد.
|
||||
@@ -1,19 +1,25 @@
|
||||
# پیشنهاد مدل اشخاص در مرحله استعلام
|
||||
|
||||
وضعیت: پیشنهادی
|
||||
وضعیت: پیادهسازیشده در ۱۴۰۵/۰۶/۲۲
|
||||
دامنه: تمام جریانهای استعلام کاربر، کارشناس، پروندهساز و مرکز تماس
|
||||
نسخه انگلیسی: [inquiry-participants-proposal.md](./inquiry-participants-proposal.md)
|
||||
|
||||
## interface پیادهسازیشده
|
||||
|
||||
فیلدهای نقشها و آبجکت الزامی `vehicle` که در ادامه آمدهاند، مستقیماً در body تمام درخواستهای استعلام فعلی پذیرفته میشوند. این تغییر شامل فرم اولیه کاربر و mirror کارشناس/ثبتکننده در V2، جریان کارشناس V3، جریانهای پروندهساز V4/V5، مرکز تماس V6 و مسیرهای تکدرخواستی حضوری است. routeهای پلاک و VIN از قوانین مشترک اشخاص استفاده میکنند. فیلدهای تخت راننده/بیمهگذار و شماره تلفن، ورودی استعلام نیستند.
|
||||
|
||||
پاسخها و جزئیات پرونده برای نقشهای عملیاتی، در صورت وجود داده، فیلدهای نرمالشده `participants`، `participantRoles`، `vehicle.registrationState` و `vehicle.previousPlateId` را نمایش میدهند.
|
||||
|
||||
## مسئله
|
||||
|
||||
قرارداد فعلی استعلام عمدتاً فقط راننده و شخصی با عنوان `insurer` را نگه میدارد. این مدل کامل نیست و نامگذاری نیز دقیق نیست: شخص، **بیمهگذار** است و **بیمهگر** شرکت بیمه است.
|
||||
|
||||
برای هر وسیله نقلیه در یک `Party` نقشهای هویتی زیر وجود دارد:
|
||||
|
||||
| نوع پرونده | نقشهای الزامی |
|
||||
| --- | --- |
|
||||
| `THIRD_PARTY` | راننده، مالک وسیله نقلیه، بیمهگذار شخص ثالث |
|
||||
| `CAR_BODY` | راننده، مالک وسیله نقلیه، بیمهگذار شخص ثالث، بیمهگذار بدنه |
|
||||
| نوع پرونده | نقشهای الزامی |
|
||||
| ------------- | ------------------------------------------------------------ |
|
||||
| `THIRD_PARTY` | راننده، مالک وسیله نقلیه، بیمهگذار شخص ثالث |
|
||||
| `CAR_BODY` | راننده، مالک وسیله نقلیه، بیمهگذار شخص ثالث، بیمهگذار بدنه |
|
||||
|
||||
ممکن است یک شخص چند نقش را داشته باشد، اما سیستم نباید یکسان بودن آنها را فرض کند.
|
||||
|
||||
@@ -28,6 +34,7 @@
|
||||
"driver": {
|
||||
"nationalCode": "0012345678",
|
||||
"birthday": "1370/01/01",
|
||||
"hasDrivingLicense": true,
|
||||
"licenseNumber": "123456789",
|
||||
"licenseType": "1"
|
||||
},
|
||||
@@ -42,6 +49,10 @@
|
||||
|
||||
فیلد `carBodyPolicyholder` برای `THIRD_PARTY` مجاز نیست و برای `CAR_BODY` الزامی است. هر نقش باید فقط یکی از دو حالت «اطلاعات شخص» یا `sameAs` را داشته باشد. بکاند این ورودی را به فهرست اشخاص یکتا و اتصال نقشها به آنها تبدیل میکند.
|
||||
|
||||
فقط برای طرف زیاندیده در پرونده `THIRD_PARTY` میتوان نامشخص بودن بیمهگذار را بهصورت صریح با `"thirdPartyPolicyholder": { "unknown": true }` ارسال کرد. این حالت برای طرف مقصر پذیرفته نمیشود. در مسیر پلاک، استعلام بیمه شخص ثالث ــ چون به هویت بیمهگذار نیاز دارد ــ بهشکل قابلممیزی «عمداً اجرا نشد» ثبت میشود؛ استعلام مبتنی بر VIN همچنان بدون حدسزدن هویت قابل اجرا است. اعتبارسنجی راننده و مالک و استعلامهای هویت، مالکیت و گواهینامه همچنان انجام میشوند.
|
||||
|
||||
برای راننده، `hasDrivingLicense` الزامی است. اگر مقدار آن `true` باشد، هر دو فیلد `licenseNumber` و `licenseType` نیز الزامی هستند؛ اگر مقدار آن `false` باشد، استعلام گواهینامه عمداً اجرا نمیشود.
|
||||
|
||||
## انتقال مالکیت اخیر و پلاک قبلی
|
||||
|
||||
نقش اشخاص و شناسههای خودرو دو موضوع جدا هستند. اگر خودرو بهتازگی فروخته یا خریداری شده باشد، ممکن است اطلاعات رسمی یا بیمهنامه هنوز به پلاک قبلی متصل باشد. این وضعیت باید صریح ثبت شود و پلاک قبلی نباید جایگزین پلاک فعلی شود:
|
||||
@@ -95,14 +106,9 @@
|
||||
|
||||
جریانهای V2 کاربر/کارشناس، V3، V4، V5 و V6 باید adapter همین قوانین مشترک باشند و منطق نسبت اشخاص را جداگانه پیادهسازی نکنند.
|
||||
|
||||
## سازگاری و انتشار تدریجی
|
||||
## مرز قرارداد
|
||||
|
||||
1. در دوره گذار، ساختار جدید در کنار فیلدهای قدیمی پذیرفته شود.
|
||||
2. `nationalCodeOfDriver` به راننده و `nationalCodeOfInsurer` به بیمهگذار شخص ثالث نگاشت شود. اگر `driverIsInsurer=true` است، هر دو نقش به یک شخص متصل شوند.
|
||||
3. `plate` یا `plateId` قدیمی به پلاک فعلی نگاشت شود؛ پلاک قبلی فقط وقتی ثبت شود که صریحاً از کاربر دریافت شده باشد.
|
||||
4. برای دادههای قدیمی، مالک خودرو یا بیمهگذار بدنه حدس زده نشود؛ مگر اینکه نتیجه استعلام ذخیرهشده آن را قطعی کند، نقش «نامشخص» باقی بماند.
|
||||
5. پاسخ جزئیات و گزارش، اشخاص را بر اساس نقش نمایش دهد و در زمان مهاجرت فیلدهای قدیمی را نیز حفظ کند.
|
||||
6. پس از مهاجرت همه فرانتاندها، قرارداد جدید برای پروندههای تازه الزامی و فیلدهای قدیمی deprecated شوند.
|
||||
ورودی استعلام فقط شامل آبجکتهای ساختاریافته اشخاص و خودرو است. بکاند فیلدهای تختی مانند `nationalCodeOfDriver`، `nationalCodeOfInsurer`، `driverIsInsurer`، `plate`/`vin` سطح بالا و `phoneNumber` را با خطای اعتبارسنجی رد میکند. احراز هویت تلفنی و جریانهای تماس با طرفین از جمعآوری هویت برای استعلام جدا هستند.
|
||||
|
||||
## تصمیم پیشنهادی
|
||||
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
# Inquiry participant identity proposal
|
||||
|
||||
Status: proposed
|
||||
Status: implemented on 2026-09-13
|
||||
Scope: every user, expert, FileMaker, and call-center inquiry flow
|
||||
Persian version: [inquiry-participants-proposal.fa.md](./inquiry-participants-proposal.fa.md)
|
||||
|
||||
## Implemented interface
|
||||
|
||||
The role fields and required `vehicle` object shown below are accepted directly in every existing inquiry request body. This covers V2 user and expert/registrar mirror initial forms, V3 expert flow, V4/V5 FileMaker flows, V6 call-center flow, and the one-shot in-person completion paths. Plate and VIN routes share the same participant rules. Flat driver/insurer fields and phone numbers are not inquiry inputs.
|
||||
|
||||
Responses and file-detail views for operational actors expose normalized `participants`, `participantRoles`, `vehicle.registrationState`, and `vehicle.previousPlateId` where available.
|
||||
|
||||
## Problem
|
||||
|
||||
The current inquiry contract mainly models a driver and a value named `insurer`. That is incomplete and the name is misleading: a person is the **policyholder**; the **insurer** is the insurance company.
|
||||
|
||||
Each vehicle-side `Party` can have these identity roles:
|
||||
|
||||
| Case type | Required roles |
|
||||
| --- | --- |
|
||||
| `THIRD_PARTY` | Driver, vehicle owner, third-party policyholder |
|
||||
| `CAR_BODY` | Driver, vehicle owner, third-party policyholder, car-body policyholder |
|
||||
| Case type | Required roles |
|
||||
| ------------- | ---------------------------------------------------------------------- |
|
||||
| `THIRD_PARTY` | Driver, vehicle owner, third-party policyholder |
|
||||
| `CAR_BODY` | Driver, vehicle owner, third-party policyholder, car-body policyholder |
|
||||
|
||||
One person may hold several roles, but the system must not assume that they do.
|
||||
|
||||
@@ -28,6 +34,7 @@ Use explicit role references instead:
|
||||
"driver": {
|
||||
"nationalCode": "0012345678",
|
||||
"birthday": "1370/01/01",
|
||||
"hasDrivingLicense": true,
|
||||
"licenseNumber": "123456789",
|
||||
"licenseType": "1"
|
||||
},
|
||||
@@ -42,6 +49,10 @@ Use explicit role references instead:
|
||||
|
||||
`carBodyPolicyholder` is forbidden for `THIRD_PARTY` and required for `CAR_BODY`. A role is either a new person's identity or a `sameAs` reference, never both. The backend should normalize this input into unique participants plus role assignments.
|
||||
|
||||
For the damaged party of a `THIRD_PARTY` case only, the policyholder can be explicitly unresolved with `"thirdPartyPolicyholder": { "unknown": true }`. This is not accepted for the guilty party. Plate-based third-party-policy inquiry is recorded as intentionally skipped because it requires that identity; VIN-based lookup can still run without guessing a person. The driver, owner, personal, ownership, and licence rules remain enforced.
|
||||
|
||||
For Driver, `hasDrivingLicense` is required. When it is `true`, both `licenseNumber` and `licenseType` are required; when it is `false`, the licence inquiry is intentionally skipped.
|
||||
|
||||
## Recent ownership transfer and previous plate
|
||||
|
||||
Participant roles and vehicle identifiers are separate concerns. When a vehicle has recently been sold or purchased, the current official record or policy may still be connected to its previous plate. Model this explicitly instead of replacing the current plate:
|
||||
@@ -95,14 +106,9 @@ Create one shared participant resolver used by every inquiry route. Its interfac
|
||||
|
||||
V2 user/expert routes, V3, V4, V5, and V6 should be adapters over this shared rule set rather than implementing their own relationship logic.
|
||||
|
||||
## Compatibility and rollout
|
||||
## Contract boundary
|
||||
|
||||
1. Accept the new participant object alongside the legacy fields temporarily.
|
||||
2. Map legacy `nationalCodeOfDriver` to Driver and `nationalCodeOfInsurer` to Third-party Policyholder. When `driverIsInsurer=true`, bind both roles to the same participant.
|
||||
3. Map the legacy `plate`/`plateId` to Current Plate; leave Previous Plate absent unless it was explicitly collected.
|
||||
4. Do not guess Vehicle Owner or Car-body Policyholder for old records. Mark unresolved roles as unknown unless stored inquiry evidence identifies them.
|
||||
5. Update report/detail responses to expose people by role while retaining legacy fields during migration.
|
||||
6. After all frontends use the new step, require the new contract for newly created cases and deprecate the legacy fields.
|
||||
The structured participant and vehicle objects are the only accepted inquiry input. The backend rejects flat fields such as `nationalCodeOfDriver`, `nationalCodeOfInsurer`, `driverIsInsurer`, top-level `plate`/`vin`, and `phoneNumber` with a validation error. Phone-based authentication and party contact flows remain separate from inquiry identity collection.
|
||||
|
||||
## Decision
|
||||
|
||||
|
||||
@@ -70,6 +70,26 @@ describe("buildInsurerFileReport", () => {
|
||||
},
|
||||
{
|
||||
role: "SECOND",
|
||||
participants: [
|
||||
{
|
||||
participantId: "DRIVER",
|
||||
fullName: "راننده نمونه",
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
licenseNumber: "LIC-1",
|
||||
},
|
||||
{
|
||||
participantId: "VEHICLE_OWNER",
|
||||
fullName: "زیان دیده نمونه",
|
||||
nationalCode: "1234567890",
|
||||
birthday: "1370/01/01",
|
||||
},
|
||||
],
|
||||
participantRoles: {
|
||||
driver: "DRIVER",
|
||||
vehicleOwner: "VEHICLE_OWNER",
|
||||
thirdPartyPolicyholder: "VEHICLE_OWNER",
|
||||
},
|
||||
person: {
|
||||
userId: "damaged-user-id",
|
||||
fullName: "زیان دیده نمونه",
|
||||
@@ -165,61 +185,89 @@ describe("buildInsurerFileReport", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(getFieldValue(report, PR.ownerSection, PR.name)).toBe("زیان دیده نمونه");
|
||||
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.name)).toBe("مقصر نمونه");
|
||||
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.phone)).toBe("09120000000");
|
||||
expect(getFieldValue(report, PR.ownerSection, PR.name)).toBe(
|
||||
"زیان دیده نمونه",
|
||||
);
|
||||
expect(
|
||||
getFieldValue(report, PR.damagedParticipantsSection, PR.driverRole),
|
||||
).toContain("راننده نمونه");
|
||||
expect(
|
||||
getFieldValue(
|
||||
report,
|
||||
PR.damagedParticipantsSection,
|
||||
PR.thirdPartyPolicyholderRole,
|
||||
),
|
||||
).toContain("1234567890");
|
||||
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.name)).toBe(
|
||||
"مقصر نمونه",
|
||||
);
|
||||
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.phone)).toBe(
|
||||
"09120000000",
|
||||
);
|
||||
expect(getFieldValue(report, PR.guiltyOwnerSection, PR.nationalCode)).toBe(
|
||||
"0987654321",
|
||||
);
|
||||
|
||||
expect(getFieldValue(report, PR.damagedThirdPartyInsuranceSection, PR.policyNumber)).toBe(
|
||||
"TP-DAMAGED-001",
|
||||
);
|
||||
expect(getFieldValue(report, PR.guiltyThirdPartyInsuranceSection, PR.policyNumber)).toBe(
|
||||
"TP-GUILTY-001",
|
||||
);
|
||||
expect(getFieldValue(report, PR.damagedCarBodyInsuranceSection, PR.policyNumber)).toBe(
|
||||
"CB-DAMAGED-001",
|
||||
);
|
||||
expect(getFieldValue(report, PR.guiltyCarBodyInsuranceSection, PR.policyNumber)).toBe(
|
||||
"CB-GUILTY-001",
|
||||
);
|
||||
|
||||
expect(getFieldValue(report, PR.damagedVehicleSection, "خودرو / نام خودرو")).toBe(
|
||||
"207",
|
||||
);
|
||||
expect(getFieldValue(report, PR.guiltyVehicleSection, "خودرو / نام خودرو")).toBe(
|
||||
"206",
|
||||
);
|
||||
|
||||
expect(getFieldValue(report, PR.damagedStatementSection, PR.partyDescription)).toBe(
|
||||
"توضیحات زیاندیده",
|
||||
);
|
||||
expect(getFieldValue(report, PR.damagedStatementSection, PR.claimsDamage)).toBe(
|
||||
"بله",
|
||||
);
|
||||
expect(
|
||||
getFieldValue(report, PR.damagedStatementSection, PR.acceptsExpertOpinion),
|
||||
getFieldValue(
|
||||
report,
|
||||
PR.damagedThirdPartyInsuranceSection,
|
||||
PR.policyNumber,
|
||||
),
|
||||
).toBe("TP-DAMAGED-001");
|
||||
expect(
|
||||
getFieldValue(
|
||||
report,
|
||||
PR.guiltyThirdPartyInsuranceSection,
|
||||
PR.policyNumber,
|
||||
),
|
||||
).toBe("TP-GUILTY-001");
|
||||
expect(
|
||||
getFieldValue(report, PR.damagedCarBodyInsuranceSection, PR.policyNumber),
|
||||
).toBe("CB-DAMAGED-001");
|
||||
expect(
|
||||
getFieldValue(report, PR.guiltyCarBodyInsuranceSection, PR.policyNumber),
|
||||
).toBe("CB-GUILTY-001");
|
||||
|
||||
expect(
|
||||
getFieldValue(report, PR.damagedVehicleSection, "خودرو / نام خودرو"),
|
||||
).toBe("207");
|
||||
expect(
|
||||
getFieldValue(report, PR.guiltyVehicleSection, "خودرو / نام خودرو"),
|
||||
).toBe("206");
|
||||
|
||||
expect(
|
||||
getFieldValue(report, PR.damagedStatementSection, PR.partyDescription),
|
||||
).toBe("توضیحات زیاندیده");
|
||||
expect(
|
||||
getFieldValue(report, PR.damagedStatementSection, PR.claimsDamage),
|
||||
).toBe("بله");
|
||||
expect(
|
||||
getFieldValue(
|
||||
report,
|
||||
PR.damagedStatementSection,
|
||||
PR.acceptsExpertOpinion,
|
||||
),
|
||||
).toBe("خیر");
|
||||
expect(getFieldValue(report, PR.guiltyStatementSection, PR.partyDescription)).toBe(
|
||||
"توضیحات مقصر",
|
||||
);
|
||||
expect(getFieldValue(report, PR.guiltyStatementSection, PR.admitsGuilt)).toBe(
|
||||
"بله",
|
||||
);
|
||||
expect(
|
||||
getFieldValue(report, PR.guiltyStatementSection, PR.partyDescription),
|
||||
).toBe("توضیحات مقصر");
|
||||
expect(
|
||||
getFieldValue(report, PR.guiltyStatementSection, PR.admitsGuilt),
|
||||
).toBe("بله");
|
||||
expect(
|
||||
getFieldValue(report, PR.guiltyStatementSection, PR.acceptsExpertOpinion),
|
||||
).toBe("بله");
|
||||
|
||||
expect(getFieldValue(report, PR.fanavaranSection, PR.fanavaranClaimNo)).toBe(
|
||||
"111",
|
||||
);
|
||||
expect(
|
||||
getFieldValue(report, PR.fanavaranSection, PR.fanavaranClaimNo),
|
||||
).toBe("111");
|
||||
expect(
|
||||
getFieldValue(report, PR.fanavaranSection, PR.fanavaranExpertiseId),
|
||||
).toBe("444");
|
||||
expect(getFieldValue(report, PR.fanavaranSection, PR.fanavaranPolicyId)).toBe(
|
||||
"555",
|
||||
);
|
||||
expect(
|
||||
getFieldValue(report, PR.fanavaranSection, PR.fanavaranPolicyId),
|
||||
).toBe("555");
|
||||
|
||||
expect(getFieldValue(report, PR.timelineSection, PR.fileRegisteredAt)).toBe(
|
||||
"1405/05/19 13:23",
|
||||
@@ -228,15 +276,15 @@ describe("buildInsurerFileReport", () => {
|
||||
getFieldValue(report, PR.timelineSection, PR.evaluationRegisteredAt),
|
||||
).toBe("1405/05/19 16:00");
|
||||
|
||||
expect(getFieldValue(report, PR.evaluationSection, PR.evaluationResult)).toBe(
|
||||
"تأیید شده",
|
||||
);
|
||||
expect(getFieldValue(report, PR.evaluationSection, PR.evaluationExpert)).toBe(
|
||||
"کارشناس خسارت نمونه",
|
||||
);
|
||||
expect(getFieldValue(report, PR.evaluationSection, PR.evaluationResponse)).toBe(
|
||||
"نیاز به تعویض سپر جلو",
|
||||
);
|
||||
expect(
|
||||
getFieldValue(report, PR.evaluationSection, PR.evaluationResult),
|
||||
).toBe("تأیید شده");
|
||||
expect(
|
||||
getFieldValue(report, PR.evaluationSection, PR.evaluationExpert),
|
||||
).toBe("کارشناس خسارت نمونه");
|
||||
expect(
|
||||
getFieldValue(report, PR.evaluationSection, PR.evaluationResponse),
|
||||
).toBe("نیاز به تعویض سپر جلو");
|
||||
expect(getFieldValue(report, "قیمت قطعات", "قطعه ۱ / نام قطعه")).toBe(
|
||||
"سپر جلو",
|
||||
);
|
||||
@@ -345,9 +393,9 @@ describe("buildInsurerFileReport", () => {
|
||||
});
|
||||
|
||||
const fields = report.sections.flatMap((section) => section.fields);
|
||||
expect(fields.find((field) => field.label === "خودرو / خودرو نو")?.value).toBe(
|
||||
"بله",
|
||||
);
|
||||
expect(
|
||||
fields.find((field) => field.label === "خودرو / خودرو نو")?.value,
|
||||
).toBe("بله");
|
||||
expect(fields.some((field) => field.value === "خیر")).toBe(true);
|
||||
expect(fields.some((field) => field.value === "true")).toBe(false);
|
||||
expect(fields.some((field) => field.value === "false")).toBe(false);
|
||||
@@ -372,10 +420,12 @@ describe("buildInsurerFileReport", () => {
|
||||
});
|
||||
|
||||
const fields = report.sections.flatMap((section) => section.fields);
|
||||
expect(fields.some((field) => String(field.value).includes("ESG"))).toBe(false);
|
||||
expect(fields.some((field) => String(field.value).includes("TEJARAT"))).toBe(
|
||||
expect(fields.some((field) => String(field.value).includes("ESG"))).toBe(
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
fields.some((field) => String(field.value).includes("TEJARAT")),
|
||||
).toBe(false);
|
||||
expect(fields.some((field) => field.label.includes("منبع"))).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ type ReportParty = ReportRecord & {
|
||||
vehicle?: ReportRecord;
|
||||
statement?: ReportRecord;
|
||||
location?: { lat?: number; lon?: number };
|
||||
participants?: ReportRecord[];
|
||||
participantRoles?: ReportRecord;
|
||||
};
|
||||
|
||||
function asString(value: unknown): string | undefined {
|
||||
@@ -66,7 +68,8 @@ function formatBirthDate(value: unknown): string | undefined {
|
||||
|
||||
function formatDateTime(value: unknown): string | undefined {
|
||||
if (value === undefined || value === null || value === "") return undefined;
|
||||
const date = value instanceof Date ? value : new Date(value as string | number);
|
||||
const date =
|
||||
value instanceof Date ? value : new Date(value as string | number);
|
||||
if (Number.isNaN(date.getTime())) return asString(value);
|
||||
const [d, t] = toJalaliDateAndTime(date);
|
||||
return `${d} ${t}`;
|
||||
@@ -126,13 +129,13 @@ function flattenObject(
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
const value = normalizeListValue(obj);
|
||||
return value
|
||||
? [{ label: persianFieldPath(prefix || "items"), value }]
|
||||
: [];
|
||||
return value ? [{ label: persianFieldPath(prefix || "items"), value }] : [];
|
||||
}
|
||||
|
||||
if (typeof obj !== "object") {
|
||||
return [{ label: persianFieldPath(prefix || "value"), value: asString(obj) }];
|
||||
return [
|
||||
{ label: persianFieldPath(prefix || "value"), value: asString(obj) },
|
||||
];
|
||||
}
|
||||
|
||||
const rows: InsurerFileReportField[] = [];
|
||||
@@ -160,7 +163,9 @@ function flattenObject(
|
||||
return rows;
|
||||
}
|
||||
|
||||
function dedupeFields(fields: InsurerFileReportField[]): InsurerFileReportField[] {
|
||||
function dedupeFields(
|
||||
fields: InsurerFileReportField[],
|
||||
): InsurerFileReportField[] {
|
||||
const seen = new Set<string>();
|
||||
const out: InsurerFileReportField[] = [];
|
||||
|
||||
@@ -180,7 +185,8 @@ function filterEmptySections(
|
||||
sections: Array<InsurerFileReportSection | undefined>,
|
||||
): InsurerFileReportSection[] {
|
||||
return sections.filter(
|
||||
(section): section is InsurerFileReportSection => !!section && section.fields.length > 0,
|
||||
(section): section is InsurerFileReportSection =>
|
||||
!!section && section.fields.length > 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +210,9 @@ function expertNameFromSnapshot(snapshot?: {
|
||||
lastName?: string;
|
||||
}): string | undefined {
|
||||
if (!snapshot) return undefined;
|
||||
const name = [snapshot.firstName, snapshot.lastName].filter(Boolean).join(" ");
|
||||
const name = [snapshot.firstName, snapshot.lastName]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
return name || undefined;
|
||||
}
|
||||
|
||||
@@ -214,9 +222,8 @@ function collectExpertNames(
|
||||
): string | undefined {
|
||||
const names = new Set<string>();
|
||||
|
||||
const blameDecision = (
|
||||
blame?.expert as Record<string, unknown> | undefined
|
||||
)?.decision as Record<string, unknown> | undefined;
|
||||
const blameDecision = (blame?.expert as Record<string, unknown> | undefined)
|
||||
?.decision as Record<string, unknown> | undefined;
|
||||
const blameExpert = expertNameFromSnapshot(
|
||||
blameDecision?.expertProfileSnapshot as
|
||||
| { firstName?: string; lastName?: string }
|
||||
@@ -280,13 +287,16 @@ function resolveReportBlameContext(
|
||||
(claim?.blameFileContext as Record<string, unknown> | undefined)
|
||||
?.blameRequestType ??
|
||||
(snapshot.accident as Record<string, unknown> | undefined)?.type,
|
||||
blameStatus: (claim?.blameFileContext as Record<string, unknown> | undefined)
|
||||
?.blameStatus,
|
||||
blameStatus: (
|
||||
claim?.blameFileContext as Record<string, unknown> | undefined
|
||||
)?.blameStatus,
|
||||
parties: snapshot.parties,
|
||||
};
|
||||
}
|
||||
|
||||
function getPartyRole(party: ReportParty | null | undefined): string | undefined {
|
||||
function getPartyRole(
|
||||
party: ReportParty | null | undefined,
|
||||
): string | undefined {
|
||||
const role = party?.role;
|
||||
return typeof role === "string" ? role : undefined;
|
||||
}
|
||||
@@ -318,7 +328,8 @@ function sameParty(
|
||||
second: ReportParty | null | undefined,
|
||||
): boolean {
|
||||
if (!first || !second) return false;
|
||||
const firstUserId = first.person?.userId != null ? String(first.person.userId) : "";
|
||||
const firstUserId =
|
||||
first.person?.userId != null ? String(first.person.userId) : "";
|
||||
const secondUserId =
|
||||
second.person?.userId != null ? String(second.person.userId) : "";
|
||||
if (firstUserId && secondUserId) return firstUserId === secondUserId;
|
||||
@@ -330,7 +341,9 @@ function resolveEvaluationReply(
|
||||
): Record<string, unknown> | undefined {
|
||||
const evaluation = claim?.evaluation as Record<string, unknown> | undefined;
|
||||
return (
|
||||
(evaluation?.damageExpertReplyFinal as Record<string, unknown> | undefined) ??
|
||||
(evaluation?.damageExpertReplyFinal as
|
||||
| Record<string, unknown>
|
||||
| undefined) ??
|
||||
(evaluation?.damageExpertReply as Record<string, unknown> | undefined)
|
||||
);
|
||||
}
|
||||
@@ -375,10 +388,18 @@ function buildThirdPartyInsuranceFields(
|
||||
const role = getPartyRole(party);
|
||||
const direct = (party?.insurance ?? {}) as Record<string, unknown>;
|
||||
const blameInquiry = pickInquiryReportPayload(
|
||||
inquiryRoleData(blame?.inquiries as Record<string, unknown> | undefined, "thirdParty", role),
|
||||
inquiryRoleData(
|
||||
blame?.inquiries as Record<string, unknown> | undefined,
|
||||
"thirdParty",
|
||||
role,
|
||||
),
|
||||
);
|
||||
const claimInquiry = pickInquiryReportPayload(
|
||||
inquiryRoleData(claim?.inquiries as Record<string, unknown> | undefined, "thirdParty", role),
|
||||
inquiryRoleData(
|
||||
claim?.inquiries as Record<string, unknown> | undefined,
|
||||
"thirdParty",
|
||||
role,
|
||||
),
|
||||
);
|
||||
|
||||
return [
|
||||
@@ -462,12 +483,23 @@ function buildCarBodyInsuranceFields(
|
||||
party?.insurance?.carBody ??
|
||||
{}) as Record<string, unknown>;
|
||||
const blameInquiry = pickInquiryReportPayload(
|
||||
inquiryRoleData(blame?.inquiries as Record<string, unknown> | undefined, "carBody", role),
|
||||
inquiryRoleData(
|
||||
blame?.inquiries as Record<string, unknown> | undefined,
|
||||
"carBody",
|
||||
role,
|
||||
),
|
||||
);
|
||||
const claimInquiry = pickInquiryReportPayload(
|
||||
inquiryRoleData(claim?.inquiries as Record<string, unknown> | undefined, "carBody", role),
|
||||
inquiryRoleData(
|
||||
claim?.inquiries as Record<string, unknown> | undefined,
|
||||
"carBody",
|
||||
role,
|
||||
),
|
||||
);
|
||||
const legacy = (blame?.carBodyInsuranceDetail ?? {}) as Record<string, unknown>;
|
||||
const legacy = (blame?.carBodyInsuranceDetail ?? {}) as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
|
||||
return [
|
||||
{
|
||||
@@ -556,7 +588,10 @@ function buildPartyOwnerSection(
|
||||
{
|
||||
label: PR.nationalCode,
|
||||
value: options?.useClaimOwnerFallback
|
||||
? firstDefined(person?.nationalCodeOfInsurer, money?.nationalCodeOfInsurer)
|
||||
? firstDefined(
|
||||
person?.nationalCodeOfInsurer,
|
||||
money?.nationalCodeOfInsurer,
|
||||
)
|
||||
: firstDefined(person?.nationalCodeOfInsurer, person?.nationalCode),
|
||||
},
|
||||
{
|
||||
@@ -572,9 +607,55 @@ function buildPartyOwnerSection(
|
||||
]);
|
||||
}
|
||||
|
||||
function licenseFieldsFromInquiry(
|
||||
inquiry?: Record<string, unknown>,
|
||||
): { licenseType?: string; licenseDate?: string } {
|
||||
function buildParticipantRolesSection(
|
||||
title: string,
|
||||
party: ReportParty | null | undefined,
|
||||
): InsurerFileReportSection | undefined {
|
||||
const participants = Array.isArray(party?.participants)
|
||||
? party.participants
|
||||
: [];
|
||||
const assignments = party?.participantRoles;
|
||||
if (!assignments || participants.length === 0) return undefined;
|
||||
|
||||
const roleLabels: Record<string, string> = {
|
||||
driver: PR.driverRole,
|
||||
vehicleOwner: PR.vehicleOwnerRole,
|
||||
thirdPartyPolicyholder: PR.thirdPartyPolicyholderRole,
|
||||
carBodyPolicyholder: PR.carBodyPolicyholderRole,
|
||||
};
|
||||
const fields = Object.entries(assignments).map(([role, participantId]) => {
|
||||
const participant = participants.find(
|
||||
(candidate) => String(candidate.participantId) === String(participantId),
|
||||
);
|
||||
const value = participant?.unknown
|
||||
? PR.unknown
|
||||
: [
|
||||
asString(participant?.fullName),
|
||||
participant?.nationalCode
|
||||
? `${PR.nationalCode}: ${asString(participant.nationalCode)}`
|
||||
: undefined,
|
||||
participant?.birthday
|
||||
? `${PR.birthDate}: ${formatBirthDate(participant.birthday)}`
|
||||
: undefined,
|
||||
participant?.licenseNumber
|
||||
? `${PR.licenseNumber}: ${asString(participant.licenseNumber)}`
|
||||
: undefined,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("، ");
|
||||
return {
|
||||
label: roleLabels[role] ?? persianFieldPath(role),
|
||||
value: value || PR.empty,
|
||||
};
|
||||
});
|
||||
|
||||
return buildSection(title, fields, false);
|
||||
}
|
||||
|
||||
function licenseFieldsFromInquiry(inquiry?: Record<string, unknown>): {
|
||||
licenseType?: string;
|
||||
licenseDate?: string;
|
||||
} {
|
||||
if (!inquiry) return {};
|
||||
return {
|
||||
licenseType: firstDefined(
|
||||
@@ -700,7 +781,9 @@ function buildCaseTimelineSection(
|
||||
},
|
||||
{
|
||||
label: PR.evaluationRegisteredAt,
|
||||
value: formatDateTime(resolveEvaluationSubmittedAt(claim, evaluationReply)),
|
||||
value: formatDateTime(
|
||||
resolveEvaluationSubmittedAt(claim, evaluationReply),
|
||||
),
|
||||
},
|
||||
]);
|
||||
}
|
||||
@@ -709,10 +792,14 @@ function buildFanavaranCodesSection(
|
||||
claim?: Record<string, unknown> | null,
|
||||
): InsurerFileReportSection | undefined {
|
||||
if (!claim) return undefined;
|
||||
const sync = (claim.fanavaranSync as Record<string, unknown> | undefined) ?? {};
|
||||
const baseClaim = (sync.baseClaim as Record<string, unknown> | undefined) ?? {};
|
||||
const damageCase = (sync.damageCase as Record<string, unknown> | undefined) ?? {};
|
||||
const expertise = (sync.expertise as Record<string, unknown> | undefined) ?? {};
|
||||
const sync =
|
||||
(claim.fanavaranSync as Record<string, unknown> | undefined) ?? {};
|
||||
const baseClaim =
|
||||
(sync.baseClaim as Record<string, unknown> | undefined) ?? {};
|
||||
const damageCase =
|
||||
(sync.damageCase as Record<string, unknown> | undefined) ?? {};
|
||||
const expertise =
|
||||
(sync.expertise as Record<string, unknown> | undefined) ?? {};
|
||||
|
||||
return buildSection(PR.fanavaranSection, [
|
||||
{
|
||||
@@ -725,7 +812,11 @@ function buildFanavaranCodesSection(
|
||||
},
|
||||
{
|
||||
label: PR.fanavaranDamageCaseId,
|
||||
value: firstDefined(claim.dmgCaseId, damageCase.dmgCaseId, expertise.dmgCaseId),
|
||||
value: firstDefined(
|
||||
claim.dmgCaseId,
|
||||
damageCase.dmgCaseId,
|
||||
expertise.dmgCaseId,
|
||||
),
|
||||
},
|
||||
{
|
||||
label: PR.fanavaranExpertiseId,
|
||||
@@ -824,10 +915,19 @@ function buildEvaluationPartsSection(
|
||||
const prefix = `${PR.part} ${PERSIAN_NUMBER_FORMATTER.format(index + 1)}`;
|
||||
return [
|
||||
{ label: `${prefix} / ${PR.partName}`, value: evaluationPartName(part) },
|
||||
{ label: `${prefix} / ${PR.damageType}`, value: asString(part.typeOfDamage) },
|
||||
{
|
||||
label: `${prefix} / ${PR.damageType}`,
|
||||
value: asString(part.typeOfDamage),
|
||||
},
|
||||
{ label: `${prefix} / ${PR.partPrice}`, value: formatToman(part.price) },
|
||||
{ label: `${prefix} / ${PR.repairSalary}`, value: formatToman(part.salary) },
|
||||
{ label: `${prefix} / ${PR.totalPayment}`, value: formatToman(part.totalPayment) },
|
||||
{
|
||||
label: `${prefix} / ${PR.repairSalary}`,
|
||||
value: formatToman(part.salary),
|
||||
},
|
||||
{
|
||||
label: `${prefix} / ${PR.totalPayment}`,
|
||||
value: formatToman(part.totalPayment),
|
||||
},
|
||||
{
|
||||
label: `${prefix} / ${PR.factorNeeded}`,
|
||||
value:
|
||||
@@ -835,7 +935,10 @@ function buildEvaluationPartsSection(
|
||||
? persianStatus(part.factorNeeded)
|
||||
: undefined,
|
||||
},
|
||||
{ label: `${prefix} / ${PR.daghi}`, value: evaluationDaghiValue(part.daghi) },
|
||||
{
|
||||
label: `${prefix} / ${PR.daghi}`,
|
||||
value: evaluationDaghiValue(part.daghi),
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
@@ -852,10 +955,11 @@ function buildAccidentReportSection(
|
||||
const snapshotAccident = (
|
||||
claim?.snapshot as { accident?: Record<string, unknown> } | undefined
|
||||
)?.accident;
|
||||
const blameDecision = (
|
||||
blame?.expert as Record<string, unknown> | undefined
|
||||
)?.decision as Record<string, unknown> | undefined;
|
||||
const decisionFields = blameDecision?.fields as Record<string, unknown> | undefined;
|
||||
const blameDecision = (blame?.expert as Record<string, unknown> | undefined)
|
||||
?.decision as Record<string, unknown> | undefined;
|
||||
const decisionFields = blameDecision?.fields as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
|
||||
return buildSection(PR.accidentSection, [
|
||||
{
|
||||
@@ -868,7 +972,8 @@ function buildAccidentReportSection(
|
||||
},
|
||||
{
|
||||
label: PR.accidentTime,
|
||||
value: asString(statement?.accidentTime) ?? asString(snapshotAccident?.time),
|
||||
value:
|
||||
asString(statement?.accidentTime) ?? asString(snapshotAccident?.time),
|
||||
},
|
||||
{
|
||||
label: PR.experts,
|
||||
@@ -914,7 +1019,8 @@ function buildAccidentReportSection(
|
||||
{
|
||||
label: PR.accidentWay,
|
||||
value: asString(
|
||||
(decisionFields?.accidentWay as { label?: string } | undefined)?.label ??
|
||||
(decisionFields?.accidentWay as { label?: string } | undefined)
|
||||
?.label ??
|
||||
(
|
||||
snapshotAccident?.classification as {
|
||||
accidentWay?: { label?: string };
|
||||
@@ -925,7 +1031,8 @@ function buildAccidentReportSection(
|
||||
{
|
||||
label: PR.accidentReason,
|
||||
value: asString(
|
||||
(decisionFields?.accidentReason as { label?: string } | undefined)?.label ??
|
||||
(decisionFields?.accidentReason as { label?: string } | undefined)
|
||||
?.label ??
|
||||
(
|
||||
snapshotAccident?.classification as {
|
||||
accidentReason?: { label?: string };
|
||||
@@ -936,7 +1043,8 @@ function buildAccidentReportSection(
|
||||
{
|
||||
label: PR.accidentType,
|
||||
value: asString(
|
||||
(decisionFields?.accidentType as { label?: string } | undefined)?.label ??
|
||||
(decisionFields?.accidentType as { label?: string } | undefined)
|
||||
?.label ??
|
||||
(
|
||||
snapshotAccident?.classification as {
|
||||
accidentType?: { label?: string };
|
||||
@@ -968,12 +1076,17 @@ export function buildInsurerFileReport(file: {
|
||||
: null;
|
||||
const isCarBody =
|
||||
String((blameContext?.type as string | undefined) ?? "") === "CAR_BODY";
|
||||
const includeGuiltySections = !!guiltyParty && !(isCarBody && sameParty(damagedParty, guiltyParty));
|
||||
const includeGuiltySections =
|
||||
!!guiltyParty && !(isCarBody && sameParty(damagedParty, guiltyParty));
|
||||
|
||||
const claimVehicle = claim?.vehicle as Record<string, unknown> | undefined;
|
||||
|
||||
const sections = filterEmptySections([
|
||||
buildCaseTimelineSection(overview, claim),
|
||||
buildParticipantRolesSection(PR.damagedParticipantsSection, damagedParty),
|
||||
includeGuiltySections
|
||||
? buildParticipantRolesSection(PR.guiltyParticipantsSection, guiltyParty)
|
||||
: undefined,
|
||||
buildPartyOwnerSection(PR.ownerSection, damagedParty, {
|
||||
claim,
|
||||
useClaimOwnerFallback: true,
|
||||
@@ -1003,7 +1116,11 @@ export function buildInsurerFileReport(file: {
|
||||
buildCarBodyInsuranceFields(guiltyParty, blameContext, claim),
|
||||
)
|
||||
: undefined,
|
||||
buildPartyVehicleSection(PR.damagedVehicleSection, damagedParty, claimVehicle),
|
||||
buildPartyVehicleSection(
|
||||
PR.damagedVehicleSection,
|
||||
damagedParty,
|
||||
claimVehicle,
|
||||
),
|
||||
includeGuiltySections
|
||||
? buildPartyVehicleSection(PR.guiltyVehicleSection, guiltyParty)
|
||||
: undefined,
|
||||
|
||||
@@ -5,6 +5,8 @@ export const PR = {
|
||||
empty: "-",
|
||||
ownerSection: "مالک خودروی زیان دیده",
|
||||
guiltyOwnerSection: "مالک خودروی مقصر",
|
||||
damagedParticipantsSection: "اشخاص و نقشهای خودروی زیاندیده",
|
||||
guiltyParticipantsSection: "اشخاص و نقشهای خودروی مقصر",
|
||||
driverSection: "راننده خودروی زیان دیده",
|
||||
damagedThirdPartyInsuranceSection: "بیمه شخص ثالث زیاندیده",
|
||||
damagedCarBodyInsuranceSection: "بیمه بدنه زیاندیده",
|
||||
@@ -61,6 +63,11 @@ export const PR = {
|
||||
claimsDamage: "ادعای خسارت",
|
||||
acceptsExpertOpinion: "پذیرش نظر کارشناس",
|
||||
partyRole: "نقش طرف",
|
||||
driverRole: "راننده",
|
||||
vehicleOwnerRole: "مالک وسیله نقلیه",
|
||||
thirdPartyPolicyholderRole: "بیمهگذار شخص ثالث",
|
||||
carBodyPolicyholderRole: "بیمهگذار بدنه",
|
||||
unknown: "نامشخص",
|
||||
data: "اطلاعات",
|
||||
date: "تاریخ",
|
||||
time: "زمان",
|
||||
|
||||
195
src/common/dto/inquiry-participants.dto.ts
Normal file
195
src/common/dto/inquiry-participants.dto.ts
Normal file
@@ -0,0 +1,195 @@
|
||||
import {
|
||||
ApiHideProperty,
|
||||
ApiProperty,
|
||||
ApiPropertyOptional,
|
||||
} from "@nestjs/swagger";
|
||||
import { Type } from "class-transformer";
|
||||
import {
|
||||
IsBoolean,
|
||||
IsEnum,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
|
||||
export enum InquiryParticipantRole {
|
||||
DRIVER = "DRIVER",
|
||||
VEHICLE_OWNER = "VEHICLE_OWNER",
|
||||
THIRD_PARTY_POLICYHOLDER = "THIRD_PARTY_POLICYHOLDER",
|
||||
CAR_BODY_POLICYHOLDER = "CAR_BODY_POLICYHOLDER",
|
||||
}
|
||||
|
||||
export enum VehicleRegistrationState {
|
||||
CURRENT = "CURRENT",
|
||||
RECENTLY_TRANSFERRED = "RECENTLY_TRANSFERRED",
|
||||
}
|
||||
|
||||
export class InquiryPlateDto {
|
||||
@ApiProperty({ example: "44" })
|
||||
@IsNotEmpty()
|
||||
leftDigits: string | number;
|
||||
|
||||
@ApiProperty({ example: "ب" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerAlphabet: string;
|
||||
|
||||
@ApiProperty({ example: "111" })
|
||||
@IsNotEmpty()
|
||||
centerDigits: string | number;
|
||||
|
||||
@ApiProperty({ example: "22" })
|
||||
@IsNotEmpty()
|
||||
ir: string | number;
|
||||
}
|
||||
|
||||
export class InquiryParticipantInputDto {
|
||||
@ApiPropertyOptional({ enum: InquiryParticipantRole })
|
||||
@IsOptional()
|
||||
@IsEnum(InquiryParticipantRole)
|
||||
sameAs?: InquiryParticipantRole;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Only for the damaged party's third-party policyholder when the identity is genuinely unknown.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
unknown?: boolean;
|
||||
|
||||
@ApiPropertyOptional({ example: "0012345678" })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
nationalCode?: string;
|
||||
|
||||
@ApiPropertyOptional({ example: "1370/01/01" })
|
||||
@IsOptional()
|
||||
birthday?: string | number;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
fullName?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: "Required for a driver who has a licence.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
hasDrivingLicense?: boolean;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
licenseNumber?: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
licenseType?: string;
|
||||
}
|
||||
|
||||
export class InquiryVehicleInputDto {
|
||||
@ApiPropertyOptional({
|
||||
enum: VehicleRegistrationState,
|
||||
default: VehicleRegistrationState.CURRENT,
|
||||
})
|
||||
@IsOptional()
|
||||
@IsEnum(VehicleRegistrationState)
|
||||
registrationState?: VehicleRegistrationState;
|
||||
|
||||
@ApiProperty({ type: InquiryPlateDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryPlateDto)
|
||||
currentPlate: InquiryPlateDto;
|
||||
|
||||
@ApiPropertyOptional({ type: InquiryPlateDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryPlateDto)
|
||||
previousPlate?: InquiryPlateDto;
|
||||
|
||||
@ApiPropertyOptional({ maxLength: 17, example: "NAAM01E15HK123456" })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(17)
|
||||
vin?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: "Whether the vehicle is newly purchased/registered.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isNewCar?: boolean;
|
||||
}
|
||||
|
||||
/** Structured role-complete contract mixed into every inquiry DTO. */
|
||||
export class InquiryParticipantFieldsDto {
|
||||
@ApiProperty({ type: InquiryParticipantInputDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
driver: InquiryParticipantInputDto;
|
||||
|
||||
@ApiProperty({ type: InquiryParticipantInputDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
vehicleOwner: InquiryParticipantInputDto;
|
||||
|
||||
@ApiProperty({ type: InquiryParticipantInputDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
thirdPartyPolicyholder: InquiryParticipantInputDto;
|
||||
|
||||
@ApiPropertyOptional({ type: InquiryParticipantInputDto })
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryParticipantInputDto)
|
||||
carBodyPolicyholder?: InquiryParticipantInputDto;
|
||||
|
||||
@ApiProperty({ type: InquiryVehicleInputDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InquiryVehicleInputDto)
|
||||
vehicle: InquiryVehicleInputDto;
|
||||
|
||||
/** Internal normalized projections; rejected as request input by the resolver. */
|
||||
@ApiHideProperty()
|
||||
nationalCodeOfDriver?: string;
|
||||
|
||||
@ApiHideProperty()
|
||||
driverBirthday?: any;
|
||||
|
||||
@ApiHideProperty()
|
||||
driverLicense?: string;
|
||||
|
||||
@ApiHideProperty()
|
||||
licenseType?: string;
|
||||
|
||||
@ApiHideProperty()
|
||||
nationalCodeOfInsurer?: string;
|
||||
|
||||
@ApiHideProperty()
|
||||
insurerBirthday?: any;
|
||||
|
||||
@ApiHideProperty()
|
||||
insurerLicense?: string;
|
||||
|
||||
@ApiHideProperty()
|
||||
driverIsInsurer?: boolean;
|
||||
|
||||
@ApiHideProperty()
|
||||
userNoCertificate?: boolean;
|
||||
|
||||
@ApiHideProperty()
|
||||
plate?: any;
|
||||
|
||||
@ApiHideProperty()
|
||||
plateId?: string;
|
||||
|
||||
@ApiHideProperty()
|
||||
vin?: string;
|
||||
|
||||
@ApiHideProperty()
|
||||
isNewCar?: boolean;
|
||||
}
|
||||
@@ -30,5 +30,8 @@ export class CaseInquiries {
|
||||
|
||||
@Prop({ type: InquiryStatusSchema })
|
||||
drivingLicence?: InquiryStatus;
|
||||
|
||||
@Prop({ type: InquiryStatusSchema })
|
||||
ownership?: InquiryStatus;
|
||||
}
|
||||
export const CaseInquiriesSchema = SchemaFactory.createForClass(CaseInquiries);
|
||||
|
||||
@@ -1,44 +1,9 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { PlatesDto } from "src/plates/dto/plate.dto";
|
||||
import { Plates } from "src/Types&Enums/plate.interface";
|
||||
import { InquiryParticipantFieldsDto } from "src/common/dto/inquiry-participants.dto";
|
||||
|
||||
export class AddPlateDto {
|
||||
plateId: string;
|
||||
@ApiProperty({ type: String, required: true })
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
insurerLicense: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
driverLicense: string;
|
||||
|
||||
@ApiProperty({ type: PlatesDto, required: true })
|
||||
plate: Plates;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true })
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true, default: false })
|
||||
isNewCar: boolean;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true })
|
||||
userNoCertificate: boolean;
|
||||
|
||||
@ApiProperty({
|
||||
type: Number,
|
||||
required: true,
|
||||
})
|
||||
insurerBirthday: number;
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: false,
|
||||
})
|
||||
driverBirthday: string | null;
|
||||
}
|
||||
export class AddPlateDto extends InquiryParticipantFieldsDto {}
|
||||
|
||||
export class AddPlateProfileDto {
|
||||
plateId: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator";
|
||||
import { IsNotEmpty, IsOptional, IsString } from "class-validator";
|
||||
import { Types } from "mongoose";
|
||||
import { AddPlateDto } from "src/profile/dto/user/AddPlateDto";
|
||||
import { StepsEnum } from "src/Types&Enums/blame-request-management/steps.enum";
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "src/Types&Enums/blame-request-management/accident-conditions.enum";
|
||||
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
|
||||
import { IsEnum } from "class-validator";
|
||||
import { InquiryParticipantFieldsDto } from "src/common/dto/inquiry-participants.dto";
|
||||
|
||||
export class InitialFormDto {
|
||||
@ApiProperty({ required: false, default: false })
|
||||
@@ -222,51 +223,8 @@ export class BlameConfessionDtoV2 {
|
||||
imGuilty?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* V2 initial-form step submitted with a VIN/chassis number instead of a plate.
|
||||
* All identity and license fields from {@link AddPlateDto} are preserved; only
|
||||
* `plate` is replaced by `vin` (the 17-character chassis / VIN string).
|
||||
*/
|
||||
export class InitialFormVinDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
required: true,
|
||||
description: "17-character VIN / chassis number (شماره شاسی)",
|
||||
example: "NAAM01E15HK123456",
|
||||
maxLength: 17,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(17)
|
||||
vin: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
insurerLicense: string;
|
||||
|
||||
@ApiProperty({ type: String, required: true })
|
||||
driverLicense: string;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true })
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true, default: false })
|
||||
isNewCar: boolean;
|
||||
|
||||
@ApiProperty({ type: Boolean, required: true })
|
||||
userNoCertificate: boolean;
|
||||
|
||||
@ApiProperty({ type: Number, required: true })
|
||||
insurerBirthday: number;
|
||||
|
||||
@ApiPropertyOptional({ type: String, required: false })
|
||||
driverBirthday: string | null;
|
||||
}
|
||||
/** V2 initial-form step submitted with the shared structured vehicle contract. */
|
||||
export class InitialFormVinDto extends InquiryParticipantFieldsDto {}
|
||||
|
||||
// export class DocsOfThisFile {
|
||||
// @ApiProperty()
|
||||
|
||||
@@ -1,143 +1,14 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import {
|
||||
IsBoolean,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
|
||||
class PlateV6Dto {
|
||||
@ApiProperty({ example: "44", description: "Left two digits" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
leftDigits: string;
|
||||
|
||||
@ApiProperty({ example: "ب", description: "Center alphabet letter" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerAlphabet: string;
|
||||
|
||||
@ApiProperty({ example: "111", description: "Center three digits" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerDigits: string;
|
||||
|
||||
@ApiProperty({ example: "22", description: "Right two digits (Iran region code)" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
ir: string;
|
||||
}
|
||||
import { InquiryParticipantFieldsDto } from "src/common/dto/inquiry-participants.dto";
|
||||
|
||||
/**
|
||||
* Inquiry body for the V6 call-center flow.
|
||||
* Same as V3 but without `sheba` — the user adds their own IBAN later via the link.
|
||||
*/
|
||||
export class RunCallCenterInquiryV6Dto {
|
||||
@ApiProperty({
|
||||
type: PlateV6Dto,
|
||||
description: "Plate segments — Tejarat block / third-party inquiry.",
|
||||
})
|
||||
@ValidateNested()
|
||||
@Type(() => PlateV6Dto)
|
||||
plate: PlateV6Dto;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@IsBoolean()
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
insurerBirthday: number | string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description: "Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Driver license (required when driverIsInsurer is false).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
driverLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Insurer license (required when driverIsInsurer is true).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
insurerLicense?: string;
|
||||
}
|
||||
export class RunCallCenterInquiryV6Dto extends InquiryParticipantFieldsDto {}
|
||||
|
||||
/**
|
||||
* VIN / chassis variant of the V6 call-center inquiry.
|
||||
* Identical to `RunCallCenterInquiryV6Dto` but replaces `plate` with `vin`.
|
||||
* Sheba (IBAN) is intentionally absent — the user provides it themselves via the link.
|
||||
*/
|
||||
export class RunCallCenterInquiryVinV6Dto {
|
||||
@ApiProperty({
|
||||
example: "NAAM01E15HK123456",
|
||||
description: "17-character VIN / chassis number (شماره شاسی)",
|
||||
maxLength: 17,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(17)
|
||||
vin: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@IsBoolean()
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
insurerBirthday: number | string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 13780624,
|
||||
description: "Driver birth date (Jalali). Required when driverIsInsurer is false.",
|
||||
})
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Driver license (required when driverIsInsurer is false).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
driverLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Insurer license (required when driverIsInsurer is true).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
insurerLicense?: string;
|
||||
}
|
||||
export class RunCallCenterInquiryVinV6Dto extends InquiryParticipantFieldsDto {}
|
||||
|
||||
@@ -1,70 +1,12 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import {
|
||||
IsBoolean,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
ValidateNested,
|
||||
} from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
|
||||
class PlateV3Dto {
|
||||
@ApiProperty({ example: "44", description: "Left two digits" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
leftDigits: string;
|
||||
|
||||
@ApiProperty({ example: "ب", description: "Center alphabet letter" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerAlphabet: string;
|
||||
|
||||
@ApiProperty({ example: "111", description: "Center three digits" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
centerDigits: string;
|
||||
|
||||
@ApiProperty({ example: "22", description: "Right two digits (Iran region code)" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
ir: string;
|
||||
}
|
||||
import { ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { IsOptional, IsString } from "class-validator";
|
||||
import { InquiryParticipantFieldsDto } from "src/common/dto/inquiry-participants.dto";
|
||||
|
||||
/**
|
||||
* Body for `POST run-inquiries/:requestId`.
|
||||
* First call = guilty party (+ auto claim). Second call = damaged party (THIRD_PARTY only).
|
||||
*/
|
||||
export class RunInquiriesV3Dto {
|
||||
@ApiProperty({
|
||||
type: PlateV3Dto,
|
||||
description: "Plate segments — Tejarat block / third-party inquiry.",
|
||||
})
|
||||
@ValidateNested()
|
||||
@Type(() => PlateV3Dto)
|
||||
plate: PlateV3Dto;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@IsBoolean()
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
insurerBirthday: number | string;
|
||||
|
||||
@ApiPropertyOptional({ example: 13780624, description: "Driver birth date (Jalali). Required when driverIsInsurer is false." })
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
export class RunInquiriesV3Dto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
example: "IR123456789012345678901234",
|
||||
description:
|
||||
@@ -73,32 +15,6 @@ export class RunInquiriesV3Dto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
sheba?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Driver license (required when driverIsInsurer is false).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
driverLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Insurer license (required when driverIsInsurer is true).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
insurerLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "1",
|
||||
description:
|
||||
"Driving licence type code from GET /lookups/driving-licence-types. " +
|
||||
"Optional — used in V4 FileMaker flow.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
licenseType?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,38 +22,7 @@ export class RunInquiriesV3Dto {
|
||||
* Identical to RunInquiriesV3Dto but uses `vin` (17-char chassis number) instead of `plate`.
|
||||
* First call = guilty party (+ auto claim). Second call = damaged party (THIRD_PARTY only).
|
||||
*/
|
||||
export class RunInquiriesVinV3Dto {
|
||||
@ApiProperty({
|
||||
example: "NAAM01E15HK123456",
|
||||
description: "17-character VIN / chassis number (شماره شاسی)",
|
||||
maxLength: 17,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(17)
|
||||
vin: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the policyholder (insurer)" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfInsurer: string;
|
||||
|
||||
@ApiProperty({ example: "1234567890", description: "National code of the driver" })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nationalCodeOfDriver: string;
|
||||
|
||||
@ApiProperty({ example: true, description: "Whether the driver is the same person as the insurer" })
|
||||
@IsBoolean()
|
||||
driverIsInsurer: boolean;
|
||||
|
||||
@ApiProperty({ example: 13780624, description: "Insurer birth date (Jalali)" })
|
||||
insurerBirthday: number | string;
|
||||
|
||||
@ApiPropertyOptional({ example: 13780624, description: "Driver birth date (Jalali). Required when driverIsInsurer is false." })
|
||||
@IsOptional()
|
||||
driverBirthday?: number | string | null;
|
||||
|
||||
export class RunInquiriesVinV3Dto extends InquiryParticipantFieldsDto {
|
||||
@ApiPropertyOptional({
|
||||
example: "IR123456789012345678901234",
|
||||
description:
|
||||
@@ -146,30 +31,4 @@ export class RunInquiriesVinV3Dto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
sheba?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Driver license (required when driverIsInsurer is false).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
driverLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "123456789",
|
||||
description: "Insurer license (required when driverIsInsurer is true).",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
insurerLicense?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: "1",
|
||||
description:
|
||||
"Driving licence type code from GET /lookups/driving-licence-types. " +
|
||||
"Optional — used in V4 FileMaker flow.",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
licenseType?: string;
|
||||
}
|
||||
|
||||
@@ -4,213 +4,254 @@ import { Schema as MongooseSchema, Types } from "mongoose";
|
||||
import { Location, LocationSchema } from "./accidentInformation.type";
|
||||
|
||||
export enum PartyRole {
|
||||
FIRST = "FIRST",
|
||||
SECOND = "SECOND",
|
||||
}
|
||||
FIRST = "FIRST",
|
||||
SECOND = "SECOND",
|
||||
}
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Person {
|
||||
@Prop({ type: Types.ObjectId })
|
||||
userId?: Types.ObjectId;
|
||||
@Prop({ type: Types.ObjectId })
|
||||
userId?: Types.ObjectId;
|
||||
|
||||
@Prop() fullName?: string;
|
||||
@Prop() phoneNumber?: string;
|
||||
@Prop({ type: Types.ObjectId }) clientId?: Types.ObjectId;
|
||||
@Prop() birthday?: string;
|
||||
@Prop() fullName?: string;
|
||||
@Prop() phoneNumber?: string;
|
||||
@Prop({ type: Types.ObjectId }) clientId?: Types.ObjectId;
|
||||
@Prop() birthday?: string;
|
||||
|
||||
// ---- FIRST_INITIAL_FORM (step-manager driven) ----
|
||||
@Prop() nationalCodeOfInsurer?: string;
|
||||
@Prop() nationalCodeOfDriver?: string;
|
||||
@Prop() insurerLicense?: string;
|
||||
@Prop() driverLicense?: string;
|
||||
/** Driving licence type code from the Fanavaran lookup (GET /lookups/driving-licence-types). */
|
||||
@Prop() licenseType?: string;
|
||||
// ---- FIRST_INITIAL_FORM (step-manager driven) ----
|
||||
@Prop() nationalCodeOfInsurer?: string;
|
||||
@Prop() nationalCodeOfDriver?: string;
|
||||
@Prop() insurerLicense?: string;
|
||||
@Prop() driverLicense?: string;
|
||||
/** Driving licence type code from the Fanavaran lookup (GET /lookups/driving-licence-types). */
|
||||
@Prop() licenseType?: string;
|
||||
|
||||
@Prop({ type: Boolean })
|
||||
driverIsInsurer?: boolean;
|
||||
@Prop({ type: Boolean })
|
||||
driverIsInsurer?: boolean;
|
||||
|
||||
@Prop({ type: Boolean })
|
||||
isNewCar?: boolean;
|
||||
@Prop({ type: Boolean })
|
||||
isNewCar?: boolean;
|
||||
|
||||
/**
|
||||
* Mirrors existing DTO `userNoCertificate` (true means user has NO certificate).
|
||||
*/
|
||||
@Prop({ type: Boolean })
|
||||
userNoCertificate?: boolean;
|
||||
/**
|
||||
* Mirrors existing DTO `userNoCertificate` (true means user has NO certificate).
|
||||
*/
|
||||
@Prop({ type: Boolean })
|
||||
userNoCertificate?: boolean;
|
||||
|
||||
@Prop({ type: Number })
|
||||
insurerBirthday?: number;
|
||||
@Prop({ type: Number })
|
||||
insurerBirthday?: number;
|
||||
|
||||
@Prop({ type: String })
|
||||
driverBirthday?: string | null;
|
||||
@Prop({ type: String })
|
||||
driverBirthday?: string | null;
|
||||
|
||||
/** Cached Fanavaran party ID resolved from nationalCodeOfDriver + driverBirthday + driverIsInsurer */
|
||||
@Prop({ type: Number })
|
||||
fanavaranDriverId?: number;
|
||||
/** Cached Fanavaran party ID resolved from nationalCodeOfDriver + driverBirthday + driverIsInsurer */
|
||||
@Prop({ type: Number })
|
||||
fanavaranDriverId?: number;
|
||||
}
|
||||
export const PersonSchema = SchemaFactory.createForClass(Person);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Vehicle {
|
||||
@Prop() plateId?: string;
|
||||
/** VIN / chassis number — populated only when the inquiry was performed via VIN lookup. */
|
||||
@Prop() vin?: string;
|
||||
@Prop() name?: string;
|
||||
@Prop() model?: string;
|
||||
@Prop() type?: string;
|
||||
@Prop() isNew?: boolean;
|
||||
export class InquiryParticipant {
|
||||
@Prop({ required: true })
|
||||
participantId: string;
|
||||
|
||||
/**
|
||||
* Full external inquiry payload (Tejarat/SandHub) stored as-is
|
||||
* so we never lose fields that are not mapped yet.
|
||||
*/
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
inquiry?: any;
|
||||
@Prop()
|
||||
nationalCode: string;
|
||||
|
||||
@Prop()
|
||||
birthday: string;
|
||||
|
||||
@Prop() fullName?: string;
|
||||
@Prop() phoneNumber?: string;
|
||||
@Prop({ type: Boolean }) hasDrivingLicense?: boolean;
|
||||
@Prop() licenseNumber?: string;
|
||||
@Prop() licenseType?: string;
|
||||
@Prop({ type: Boolean }) unknown?: boolean;
|
||||
}
|
||||
export const InquiryParticipantSchema =
|
||||
SchemaFactory.createForClass(InquiryParticipant);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class InquiryParticipantRoles {
|
||||
@Prop() driver?: string;
|
||||
@Prop() vehicleOwner?: string;
|
||||
@Prop() thirdPartyPolicyholder?: string;
|
||||
@Prop() carBodyPolicyholder?: string;
|
||||
}
|
||||
export const InquiryParticipantRolesSchema = SchemaFactory.createForClass(
|
||||
InquiryParticipantRoles,
|
||||
);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Vehicle {
|
||||
@Prop() plateId?: string;
|
||||
/** VIN / chassis number — populated only when the inquiry was performed via VIN lookup. */
|
||||
@Prop() vin?: string;
|
||||
@Prop() name?: string;
|
||||
@Prop() model?: string;
|
||||
@Prop() type?: string;
|
||||
@Prop() isNew?: boolean;
|
||||
@Prop({ enum: ["CURRENT", "RECENTLY_TRANSFERRED"] })
|
||||
registrationState?: "CURRENT" | "RECENTLY_TRANSFERRED";
|
||||
@Prop() previousPlateId?: string;
|
||||
|
||||
/**
|
||||
* Full external inquiry payload (Tejarat/SandHub) stored as-is
|
||||
* so we never lose fields that are not mapped yet.
|
||||
*/
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
inquiry?: any;
|
||||
}
|
||||
export const VehicleSchema = SchemaFactory.createForClass(Vehicle);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Insurance {
|
||||
@Prop() policyNumber?: string;
|
||||
@Prop() company?: string;
|
||||
@Prop() startDate?: string;
|
||||
@Prop() endDate?: string;
|
||||
@Prop() financialCeiling?: string;
|
||||
@Prop({ type: [String] })
|
||||
coverages?: string[];
|
||||
@Prop() policyNumber?: string;
|
||||
@Prop() company?: string;
|
||||
@Prop() startDate?: string;
|
||||
@Prop() endDate?: string;
|
||||
@Prop() financialCeiling?: string;
|
||||
@Prop({ type: [String] })
|
||||
coverages?: string[];
|
||||
|
||||
/** CAR_BODY inquiry result; raw provider data is retained in vehicle.inquiry.carBody.raw. */
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
carBodyInsurance?: {
|
||||
policyNumber?: string;
|
||||
policyId?: number;
|
||||
contractId?: number;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
insurerCompany?: string;
|
||||
coverages?: string[];
|
||||
companyId?: number | string;
|
||||
companyName?: string;
|
||||
insurerName?: string;
|
||||
insurerNationalCode?: string;
|
||||
ownerNationalCode?: string;
|
||||
ownerName?: string;
|
||||
customerName?: string;
|
||||
customerLastName?: string;
|
||||
customerFatherName?: string;
|
||||
customerMobile?: string;
|
||||
customerAddress?: string;
|
||||
customerPostalCode?: string;
|
||||
chassisNumber?: string;
|
||||
vin?: string;
|
||||
motorNumber?: string;
|
||||
vehicleGroup?: string;
|
||||
vehicleSystem?: string;
|
||||
vehicleKind?: string;
|
||||
builtYear?: number;
|
||||
cylinderCount?: number;
|
||||
passengerCount?: number;
|
||||
usage?: string;
|
||||
issueDate?: string;
|
||||
vehicleValue?: number;
|
||||
totalPremium?: number;
|
||||
noLossYearsCount?: number;
|
||||
lossDocuments?: unknown[];
|
||||
hasEndorsement?: boolean;
|
||||
};
|
||||
/** CAR_BODY inquiry result; raw provider data is retained in vehicle.inquiry.carBody.raw. */
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
carBodyInsurance?: {
|
||||
policyNumber?: string;
|
||||
policyId?: number;
|
||||
contractId?: number;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
insurerCompany?: string;
|
||||
coverages?: string[];
|
||||
companyId?: number | string;
|
||||
companyName?: string;
|
||||
insurerName?: string;
|
||||
insurerNationalCode?: string;
|
||||
ownerNationalCode?: string;
|
||||
ownerName?: string;
|
||||
customerName?: string;
|
||||
customerLastName?: string;
|
||||
customerFatherName?: string;
|
||||
customerMobile?: string;
|
||||
customerAddress?: string;
|
||||
customerPostalCode?: string;
|
||||
chassisNumber?: string;
|
||||
vin?: string;
|
||||
motorNumber?: string;
|
||||
vehicleGroup?: string;
|
||||
vehicleSystem?: string;
|
||||
vehicleKind?: string;
|
||||
builtYear?: number;
|
||||
cylinderCount?: number;
|
||||
passengerCount?: number;
|
||||
usage?: string;
|
||||
issueDate?: string;
|
||||
vehicleValue?: number;
|
||||
totalPremium?: number;
|
||||
noLossYearsCount?: number;
|
||||
lossDocuments?: unknown[];
|
||||
hasEndorsement?: boolean;
|
||||
};
|
||||
}
|
||||
export const InsuranceSchema = SchemaFactory.createForClass(Insurance);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class PartyStatement {
|
||||
@Prop({ default: false })
|
||||
acceptsExpertOpinion?: boolean;
|
||||
|
||||
@Prop({ default: false })
|
||||
acceptsExpertOpinion?: boolean;
|
||||
|
||||
@Prop({ default: false })
|
||||
claimsDamage?: boolean;
|
||||
|
||||
@Prop({ default: false })
|
||||
admitsGuilt?: boolean;
|
||||
|
||||
@Prop({ type: String })
|
||||
description?: string;
|
||||
@Prop({ default: false })
|
||||
claimsDamage?: boolean;
|
||||
|
||||
/** CAR_BODY: accident conditions from description step */
|
||||
@Prop() accidentDate?: Date;
|
||||
@Prop() accidentTime?: string;
|
||||
@Prop() weatherCondition?: string;
|
||||
@Prop() roadCondition?: string;
|
||||
@Prop() lightCondition?: string;
|
||||
@Prop({ default: false })
|
||||
admitsGuilt?: boolean;
|
||||
|
||||
@Prop({ type: String })
|
||||
description?: string;
|
||||
|
||||
/** CAR_BODY: accident conditions from description step */
|
||||
@Prop() accidentDate?: Date;
|
||||
@Prop() accidentTime?: string;
|
||||
@Prop() weatherCondition?: string;
|
||||
@Prop() roadCondition?: string;
|
||||
@Prop() lightCondition?: string;
|
||||
}
|
||||
export const PartyStatementSchema = SchemaFactory.createForClass(PartyStatement);
|
||||
export const PartyStatementSchema =
|
||||
SchemaFactory.createForClass(PartyStatement);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class EvidenceBundle {
|
||||
@Prop({ type: [String] })
|
||||
images?: string[];
|
||||
|
||||
@Prop({ type: [String] })
|
||||
images?: string[];
|
||||
|
||||
@Prop({ type: [String] })
|
||||
voices?: string[];
|
||||
|
||||
@Prop() videoId?: string;
|
||||
@Prop({ type: [String] })
|
||||
voices?: string[];
|
||||
|
||||
@Prop() videoId?: string;
|
||||
}
|
||||
export const EvidenceBundleSchema = SchemaFactory.createForClass(EvidenceBundle);
|
||||
export const EvidenceBundleSchema =
|
||||
SchemaFactory.createForClass(EvidenceBundle);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Signature {
|
||||
@Prop() fileId: string;
|
||||
@Prop() fileName: string;
|
||||
@Prop() fileUrl: string;
|
||||
@Prop() fileId: string;
|
||||
@Prop() fileName: string;
|
||||
@Prop() fileUrl: string;
|
||||
}
|
||||
export const SignatureSchema = SchemaFactory.createForClass(Signature);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class PartyConfirmation {
|
||||
@Prop() partyRole: PartyRole;
|
||||
@Prop() accepted: boolean;
|
||||
@Prop({ type: SignatureSchema })
|
||||
signature?: Signature;
|
||||
@Prop() partyRole: PartyRole;
|
||||
@Prop() accepted: boolean;
|
||||
@Prop({ type: SignatureSchema })
|
||||
signature?: Signature;
|
||||
}
|
||||
export const PartyConfirmationSchema =
|
||||
SchemaFactory.createForClass(PartyConfirmation);
|
||||
|
||||
@Schema({ _id: false })
|
||||
export class Party {
|
||||
@Prop({ enum: PartyRole })
|
||||
role: PartyRole;
|
||||
|
||||
@Prop({ enum: PartyRole })
|
||||
role: PartyRole;
|
||||
|
||||
@Prop({ type: PersonSchema })
|
||||
person: Person;
|
||||
@Prop({ type: PersonSchema })
|
||||
person: Person;
|
||||
|
||||
/**
|
||||
* CAR_BODY only: first form – accident with car vs object.
|
||||
* Second form (guilty/damaged) may be added later as carBodySecondForm.
|
||||
*/
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
carBodyFirstForm?: { car?: boolean; object?: boolean };
|
||||
/** Distinct people involved with this vehicle; roles below reference participantId. */
|
||||
@Prop({ type: [InquiryParticipantSchema], default: undefined })
|
||||
participants?: InquiryParticipant[];
|
||||
|
||||
/**
|
||||
* Party-submitted location (step-driven: FIRST_LOCATION / SECOND_LOCATION).
|
||||
*/
|
||||
@Prop({ type: LocationSchema })
|
||||
location?: Location;
|
||||
|
||||
@Prop({ type: VehicleSchema })
|
||||
vehicle?: Vehicle;
|
||||
|
||||
@Prop({ type: InsuranceSchema })
|
||||
insurance?: Insurance;
|
||||
|
||||
@Prop({ type: PartyStatementSchema })
|
||||
statement?: PartyStatement;
|
||||
|
||||
@Prop({ type: EvidenceBundleSchema })
|
||||
evidence?: EvidenceBundle;
|
||||
|
||||
@Prop({ type: PartyConfirmationSchema })
|
||||
confirmation?: PartyConfirmation;
|
||||
@Prop({ type: InquiryParticipantRolesSchema })
|
||||
participantRoles?: InquiryParticipantRoles;
|
||||
|
||||
/**
|
||||
* CAR_BODY only: first form – accident with car vs object.
|
||||
* Second form (guilty/damaged) may be added later as carBodySecondForm.
|
||||
*/
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
carBodyFirstForm?: { car?: boolean; object?: boolean };
|
||||
|
||||
/**
|
||||
* Party-submitted location (step-driven: FIRST_LOCATION / SECOND_LOCATION).
|
||||
*/
|
||||
@Prop({ type: LocationSchema })
|
||||
location?: Location;
|
||||
|
||||
@Prop({ type: VehicleSchema })
|
||||
vehicle?: Vehicle;
|
||||
|
||||
@Prop({ type: InsuranceSchema })
|
||||
insurance?: Insurance;
|
||||
|
||||
@Prop({ type: PartyStatementSchema })
|
||||
statement?: PartyStatement;
|
||||
|
||||
@Prop({ type: EvidenceBundleSchema })
|
||||
evidence?: EvidenceBundle;
|
||||
|
||||
@Prop({ type: PartyConfirmationSchema })
|
||||
confirmation?: PartyConfirmation;
|
||||
}
|
||||
export const PartySchema = SchemaFactory.createForClass(Party);
|
||||
|
||||
@@ -146,6 +146,22 @@ export class FirstPartyDetail {
|
||||
|
||||
@Prop({ type: Boolean })
|
||||
firstPartyCertificate: boolean | null;
|
||||
|
||||
@Prop({ type: [MongooseSchema.Types.Mixed] })
|
||||
participants?: Record<string, unknown>[];
|
||||
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
participantRoles?: Record<string, string>;
|
||||
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
participantInquiries?: Record<string, unknown>;
|
||||
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
policyInquiry?: Record<string, unknown>;
|
||||
|
||||
@Prop() registrationState?: string;
|
||||
@Prop() previousPlateId?: string;
|
||||
@Prop() vehicleVin?: string;
|
||||
}
|
||||
|
||||
export class SecondPartyDetail {
|
||||
@@ -178,6 +194,22 @@ export class SecondPartyDetail {
|
||||
|
||||
@Prop({ type: SecondPartyFile })
|
||||
secondPartyFiles?: SecondPartyFile;
|
||||
|
||||
@Prop({ type: [MongooseSchema.Types.Mixed] })
|
||||
participants?: Record<string, unknown>[];
|
||||
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
participantRoles?: Record<string, string>;
|
||||
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
participantInquiries?: Record<string, unknown>;
|
||||
|
||||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||||
policyInquiry?: Record<string, unknown>;
|
||||
|
||||
@Prop() registrationState?: string;
|
||||
@Prop() previousPlateId?: string;
|
||||
@Prop() vehicleVin?: string;
|
||||
}
|
||||
|
||||
export class LocationDto {
|
||||
|
||||
508
src/request-management/inquiry-participant-resolver.spec.ts
Normal file
508
src/request-management/inquiry-participant-resolver.spec.ts
Normal file
@@ -0,0 +1,508 @@
|
||||
import { BadRequestException } from "@nestjs/common";
|
||||
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
|
||||
import {
|
||||
InquiryParticipantRole,
|
||||
VehicleRegistrationState,
|
||||
} from "src/common/dto/inquiry-participants.dto";
|
||||
import {
|
||||
assertPreviousPlateInquiryMatchesVin,
|
||||
isMappedPolicyCurrent,
|
||||
normalizeInquirySubmission,
|
||||
participantForRole,
|
||||
resolveInquiryParticipants,
|
||||
resolveInquiryVehicle,
|
||||
runPlateInquiryWithFallback,
|
||||
vehiclePlateCandidates,
|
||||
} from "./inquiry-participant-resolver";
|
||||
|
||||
describe("inquiry participant resolver", () => {
|
||||
it("links several roles to one explicitly shared person", () => {
|
||||
const resolved = resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: true,
|
||||
licenseNumber: "123456789",
|
||||
licenseType: "1",
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: {
|
||||
sameAs: InquiryParticipantRole.VEHICLE_OWNER,
|
||||
},
|
||||
});
|
||||
|
||||
expect(resolved.participants).toHaveLength(1);
|
||||
expect(resolved.roles).toEqual({
|
||||
driver: "DRIVER",
|
||||
vehicleOwner: "DRIVER",
|
||||
thirdPartyPolicyholder: "DRIVER",
|
||||
});
|
||||
});
|
||||
|
||||
it("requires both previous plate and VIN for a recent transfer", () => {
|
||||
expect(() =>
|
||||
resolveInquiryVehicle({
|
||||
registrationState: VehicleRegistrationState.RECENTLY_TRANSFERRED,
|
||||
currentPlate: {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
},
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("defaults an omitted registration state to CURRENT", () => {
|
||||
expect(
|
||||
resolveInquiryVehicle({
|
||||
currentPlate: {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
},
|
||||
}).registrationState,
|
||||
).toBe(VehicleRegistrationState.CURRENT);
|
||||
});
|
||||
|
||||
it("rejects the removed flat inquiry contract", () => {
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
nationalCodeOfDriver: "0012345678",
|
||||
driverBirthday: "1370/01/01",
|
||||
driverLicense: "123456789",
|
||||
nationalCodeOfInsurer: "0098765432",
|
||||
insurerBirthday: "1360/02/02",
|
||||
driverIsInsurer: false,
|
||||
} as any),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("rejects phone numbers in participant inquiry identity", () => {
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
phoneNumber: "09120000000",
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: {
|
||||
sameAs: InquiryParticipantRole.DRIVER,
|
||||
},
|
||||
} as any),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("keeps third-party and car-body policyholders distinct", () => {
|
||||
const resolved = resolveInquiryParticipants(BlameRequestType.CAR_BODY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: {
|
||||
nationalCode: "0023456789",
|
||||
birthday: "1360/02/02",
|
||||
},
|
||||
carBodyPolicyholder: {
|
||||
nationalCode: "0034567890",
|
||||
birthday: "1350/03/03",
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
participantForRole(
|
||||
resolved,
|
||||
InquiryParticipantRole.THIRD_PARTY_POLICYHOLDER,
|
||||
)?.nationalCode,
|
||||
).toBe("0023456789");
|
||||
expect(
|
||||
participantForRole(resolved, InquiryParticipantRole.CAR_BODY_POLICYHOLDER)
|
||||
?.nationalCode,
|
||||
).toBe("0034567890");
|
||||
});
|
||||
|
||||
it("projects role-complete input onto the existing inquiry fields", () => {
|
||||
const normalized = normalizeInquirySubmission(BlameRequestType.CAR_BODY, {
|
||||
vehicle: {
|
||||
currentPlate: {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
},
|
||||
},
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: true,
|
||||
licenseNumber: "D-1",
|
||||
licenseType: "1",
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: {
|
||||
nationalCode: "0023456789",
|
||||
birthday: "1360/02/02",
|
||||
},
|
||||
carBodyPolicyholder: {
|
||||
nationalCode: "0034567890",
|
||||
birthday: "1350/03/03",
|
||||
},
|
||||
});
|
||||
|
||||
expect(normalized.dto.nationalCodeOfInsurer).toBe("0023456789");
|
||||
expect(normalized.dto.nationalCodeOfDriver).toBe("0012345678");
|
||||
expect(normalized.carBodyPolicyholder?.nationalCode).toBe("0034567890");
|
||||
expect(normalized.vehicleOwner?.nationalCode).toBe("0012345678");
|
||||
});
|
||||
|
||||
it("orders the current plate before the previous-plate fallback", () => {
|
||||
const currentPlate = {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
};
|
||||
const previousPlate = {
|
||||
leftDigits: "55",
|
||||
centerAlphabet: "ج",
|
||||
centerDigits: "222",
|
||||
ir: "33",
|
||||
};
|
||||
|
||||
expect(
|
||||
vehiclePlateCandidates({
|
||||
registrationState: VehicleRegistrationState.RECENTLY_TRANSFERRED,
|
||||
currentPlate,
|
||||
previousPlate,
|
||||
vin: "NAAM01E15HK123456",
|
||||
}),
|
||||
).toEqual([
|
||||
{ kind: "CURRENT", plate: currentPlate },
|
||||
{ kind: "PREVIOUS", plate: previousPlate },
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects a previous-plate result for another chassis", () => {
|
||||
expect(() =>
|
||||
assertPreviousPlateInquiryMatchesVin("NAAM01E15HK123456", {
|
||||
VinNumberField: "DIFFERENTVIN00001",
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("requires the driver's licence status in the new contract", () => {
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: { nationalCode: "0012345678", birthday: "1370/01/01" },
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: {
|
||||
sameAs: InquiryParticipantRole.VEHICLE_OWNER,
|
||||
},
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("falls back to the previous plate and accepts only a matching VIN", async () => {
|
||||
const currentPlate = {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
};
|
||||
const previousPlate = {
|
||||
leftDigits: "55",
|
||||
centerAlphabet: "ج",
|
||||
centerDigits: "222",
|
||||
ir: "33",
|
||||
};
|
||||
const query = jest
|
||||
.fn()
|
||||
.mockRejectedValueOnce(new Error("not found"))
|
||||
.mockResolvedValueOnce({
|
||||
mapped: { VinNumberField: "NAAM01E15HK123456", CompanyName: "پارسیان" },
|
||||
});
|
||||
|
||||
const result = await runPlateInquiryWithFallback<{
|
||||
mapped: { VinNumberField?: string; CompanyName?: string };
|
||||
}>({
|
||||
vehicle: {
|
||||
registrationState: VehicleRegistrationState.RECENTLY_TRANSFERRED,
|
||||
currentPlate,
|
||||
previousPlate,
|
||||
vin: "NAAM01E15HK123456",
|
||||
},
|
||||
fallbackCurrentPlate: currentPlate,
|
||||
query,
|
||||
isUsable: (value) => !!value.mapped.CompanyName,
|
||||
mappedValue: (value) => value.mapped,
|
||||
});
|
||||
|
||||
expect(query).toHaveBeenCalledTimes(2);
|
||||
expect(result.plateKind).toBe("PREVIOUS");
|
||||
expect(result.attempts).toMatchObject([
|
||||
{ plateKind: "CURRENT", succeeded: false, error: "not found" },
|
||||
{ plateKind: "PREVIOUS", succeeded: true, usable: true },
|
||||
]);
|
||||
expect(result.attempts[0]).toMatchObject({
|
||||
plate: currentPlate,
|
||||
vin: "NAAM01E15HK123456",
|
||||
});
|
||||
expect(result.attempts[1]).toMatchObject({
|
||||
plate: previousPlate,
|
||||
vin: "NAAM01E15HK123456",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects a car-body policyholder on a third-party case", () => {
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: {
|
||||
sameAs: InquiryParticipantRole.VEHICLE_OWNER,
|
||||
},
|
||||
carBodyPolicyholder: {
|
||||
nationalCode: "0034567890",
|
||||
birthday: "1350/03/03",
|
||||
},
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("does not accept a previous plate unless recent transfer is declared", () => {
|
||||
expect(() =>
|
||||
resolveInquiryVehicle({
|
||||
registrationState: VehicleRegistrationState.CURRENT,
|
||||
currentPlate: {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
},
|
||||
previousPlate: {
|
||||
leftDigits: "55",
|
||||
centerAlphabet: "ج",
|
||||
centerDigits: "222",
|
||||
ir: "33",
|
||||
},
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("rejects sameAs together with any person-specific fields", () => {
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
},
|
||||
vehicleOwner: {
|
||||
sameAs: InquiryParticipantRole.DRIVER,
|
||||
fullName: "Duplicate details must not be silently discarded",
|
||||
},
|
||||
thirdPartyPolicyholder: {
|
||||
sameAs: InquiryParticipantRole.DRIVER,
|
||||
},
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("rejects conflicting legacy and structured current plates", () => {
|
||||
expect(() =>
|
||||
normalizeInquirySubmission(BlameRequestType.THIRD_PARTY, {
|
||||
plate: {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
},
|
||||
vehicle: {
|
||||
registrationState: VehicleRegistrationState.CURRENT,
|
||||
currentPlate: {
|
||||
leftDigits: "55",
|
||||
centerAlphabet: "ج",
|
||||
centerDigits: "222",
|
||||
ir: "33",
|
||||
},
|
||||
},
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: {
|
||||
sameAs: InquiryParticipantRole.DRIVER,
|
||||
},
|
||||
}),
|
||||
).toThrow(BadRequestException);
|
||||
});
|
||||
|
||||
it("treats an expired policy result as stale", () => {
|
||||
expect(isMappedPolicyCurrent({ EndDate: "1404/01/01" }, "2026-09-13")).toBe(
|
||||
false,
|
||||
);
|
||||
expect(isMappedPolicyCurrent({ EndDate: "1406/01/01" }, "2026-09-13")).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back from a stale current policy to a current previous-plate policy", async () => {
|
||||
const currentPlate = {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
};
|
||||
const previousPlate = {
|
||||
leftDigits: "55",
|
||||
centerAlphabet: "ج",
|
||||
centerDigits: "222",
|
||||
ir: "33",
|
||||
};
|
||||
const query = jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
mapped: { CompanyName: "پارسیان", EndDate: "1404/01/01" },
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
mapped: {
|
||||
CompanyName: "پارسیان",
|
||||
EndDate: "1406/01/01",
|
||||
VinNumberField: "NAAM01E15HK123456",
|
||||
},
|
||||
});
|
||||
|
||||
const result = await runPlateInquiryWithFallback<{
|
||||
mapped: Record<string, any>;
|
||||
}>({
|
||||
vehicle: resolveInquiryVehicle({
|
||||
registrationState: VehicleRegistrationState.RECENTLY_TRANSFERRED,
|
||||
currentPlate,
|
||||
previousPlate,
|
||||
vin: "NAAM01E15HK123456",
|
||||
}),
|
||||
fallbackCurrentPlate: currentPlate,
|
||||
query,
|
||||
isUsable: (value) =>
|
||||
!!value.mapped.CompanyName &&
|
||||
isMappedPolicyCurrent(value.mapped, "2026-09-13"),
|
||||
mappedValue: (value) => value.mapped,
|
||||
});
|
||||
|
||||
expect(result.plateKind).toBe("PREVIOUS");
|
||||
expect(result.attempts[0]).toMatchObject({
|
||||
plateKind: "CURRENT",
|
||||
succeeded: true,
|
||||
usable: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects the result and retains audit attempts when every plate is unusable", async () => {
|
||||
const currentPlate = {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
};
|
||||
const previousPlate = {
|
||||
leftDigits: "55",
|
||||
centerAlphabet: "ج",
|
||||
centerDigits: "222",
|
||||
ir: "33",
|
||||
};
|
||||
|
||||
await expect(
|
||||
runPlateInquiryWithFallback({
|
||||
vehicle: resolveInquiryVehicle({
|
||||
registrationState: VehicleRegistrationState.RECENTLY_TRANSFERRED,
|
||||
currentPlate,
|
||||
previousPlate,
|
||||
vin: "NAAM01E15HK123456",
|
||||
}),
|
||||
fallbackCurrentPlate: currentPlate,
|
||||
query: async () => ({ mapped: { CompanyName: "پارسیان" } }),
|
||||
isUsable: () => false,
|
||||
mappedValue: (value) => value.mapped,
|
||||
}),
|
||||
).rejects.toMatchObject({
|
||||
attempts: [
|
||||
{ plateKind: "CURRENT", succeeded: true, usable: false },
|
||||
{ plateKind: "PREVIOUS", succeeded: true, usable: false },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("does not use the previous plate after a transport or provider outage", async () => {
|
||||
const currentPlate = {
|
||||
leftDigits: "44",
|
||||
centerAlphabet: "ب",
|
||||
centerDigits: "111",
|
||||
ir: "22",
|
||||
};
|
||||
const query = jest.fn().mockRejectedValue(
|
||||
Object.assign(new Error("upstream timeout"), {
|
||||
code: "ETIMEDOUT",
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(
|
||||
runPlateInquiryWithFallback({
|
||||
vehicle: resolveInquiryVehicle({
|
||||
registrationState: VehicleRegistrationState.RECENTLY_TRANSFERRED,
|
||||
currentPlate,
|
||||
previousPlate: {
|
||||
leftDigits: "55",
|
||||
centerAlphabet: "ج",
|
||||
centerDigits: "222",
|
||||
ir: "33",
|
||||
},
|
||||
vin: "NAAM01E15HK123456",
|
||||
}),
|
||||
fallbackCurrentPlate: currentPlate,
|
||||
query,
|
||||
isUsable: () => false,
|
||||
mappedValue: () => ({}),
|
||||
}),
|
||||
).rejects.toThrow("upstream timeout");
|
||||
expect(query).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("allows an explicitly unknown policyholder only for a damaged-party submission", () => {
|
||||
const input = {
|
||||
driver: {
|
||||
nationalCode: "0012345678",
|
||||
birthday: "1370/01/01",
|
||||
hasDrivingLicense: false,
|
||||
},
|
||||
vehicleOwner: { sameAs: InquiryParticipantRole.DRIVER },
|
||||
thirdPartyPolicyholder: { unknown: true },
|
||||
};
|
||||
|
||||
expect(() =>
|
||||
resolveInquiryParticipants(BlameRequestType.THIRD_PARTY, input),
|
||||
).toThrow(BadRequestException);
|
||||
|
||||
const resolved = resolveInquiryParticipants(
|
||||
BlameRequestType.THIRD_PARTY,
|
||||
input,
|
||||
{ allowUnknownThirdPartyPolicyholder: true },
|
||||
);
|
||||
expect(
|
||||
participantForRole(
|
||||
resolved,
|
||||
InquiryParticipantRole.THIRD_PARTY_POLICYHOLDER,
|
||||
),
|
||||
).toMatchObject({ unknown: true });
|
||||
});
|
||||
});
|
||||
575
src/request-management/inquiry-participant-resolver.ts
Normal file
575
src/request-management/inquiry-participant-resolver.ts
Normal file
@@ -0,0 +1,575 @@
|
||||
import { BadRequestException } from "@nestjs/common";
|
||||
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
|
||||
import { jalaliToGregorianDate } from "src/helpers/date-jalali";
|
||||
import { gregorianDateInIran } from "src/helpers/iran-datetime";
|
||||
import {
|
||||
InquiryParticipantFieldsDto,
|
||||
InquiryParticipantInputDto,
|
||||
InquiryParticipantRole,
|
||||
InquiryVehicleInputDto,
|
||||
VehicleRegistrationState,
|
||||
} from "src/common/dto/inquiry-participants.dto";
|
||||
|
||||
export interface ResolvedInquiryParticipant {
|
||||
participantId: string;
|
||||
nationalCode: string;
|
||||
birthday: string;
|
||||
fullName?: string;
|
||||
hasDrivingLicense?: boolean;
|
||||
licenseNumber?: string;
|
||||
licenseType?: string;
|
||||
unknown?: boolean;
|
||||
}
|
||||
|
||||
export interface InquiryParticipantResolutionOptions {
|
||||
allowUnknownThirdPartyPolicyholder?: boolean;
|
||||
}
|
||||
|
||||
export interface InquiryParticipantRoleAssignments {
|
||||
driver: string;
|
||||
vehicleOwner?: string;
|
||||
thirdPartyPolicyholder: string;
|
||||
carBodyPolicyholder?: string;
|
||||
}
|
||||
|
||||
export interface ResolvedInquiryParticipants {
|
||||
participants: ResolvedInquiryParticipant[];
|
||||
roles: InquiryParticipantRoleAssignments;
|
||||
legacy: boolean;
|
||||
}
|
||||
|
||||
export interface NormalizedInquirySubmission<T extends Record<string, any>> {
|
||||
dto: T & {
|
||||
nationalCodeOfDriver: string;
|
||||
driverBirthday: string;
|
||||
driverLicense?: string;
|
||||
licenseType?: string;
|
||||
userNoCertificate?: boolean;
|
||||
nationalCodeOfInsurer: string;
|
||||
insurerBirthday: string;
|
||||
driverIsInsurer: boolean;
|
||||
insurerLicense?: string;
|
||||
};
|
||||
participants: ResolvedInquiryParticipants;
|
||||
driver: ResolvedInquiryParticipant;
|
||||
vehicleOwner?: ResolvedInquiryParticipant;
|
||||
thirdPartyPolicyholder: ResolvedInquiryParticipant;
|
||||
carBodyPolicyholder?: ResolvedInquiryParticipant;
|
||||
vehicle?: ResolvedInquiryVehicle;
|
||||
}
|
||||
|
||||
export type ResolvedInquiryVehicle = InquiryVehicleInputDto & {
|
||||
registrationState: VehicleRegistrationState;
|
||||
};
|
||||
|
||||
export function participantForRole(
|
||||
resolved: ResolvedInquiryParticipants,
|
||||
role: InquiryParticipantRole,
|
||||
): ResolvedInquiryParticipant | undefined {
|
||||
const roleField = ROLE_FIELDS[
|
||||
role
|
||||
] as keyof InquiryParticipantRoleAssignments;
|
||||
const participantId = resolved.roles[roleField];
|
||||
return resolved.participants.find(
|
||||
(participant) => participant.participantId === participantId,
|
||||
);
|
||||
}
|
||||
|
||||
const ROLE_FIELDS: Record<
|
||||
InquiryParticipantRole,
|
||||
keyof InquiryParticipantFieldsDto
|
||||
> = {
|
||||
[InquiryParticipantRole.DRIVER]: "driver",
|
||||
[InquiryParticipantRole.VEHICLE_OWNER]: "vehicleOwner",
|
||||
[InquiryParticipantRole.THIRD_PARTY_POLICYHOLDER]: "thirdPartyPolicyholder",
|
||||
[InquiryParticipantRole.CAR_BODY_POLICYHOLDER]: "carBodyPolicyholder",
|
||||
};
|
||||
|
||||
function requiredIdentity(
|
||||
role: InquiryParticipantRole,
|
||||
input: InquiryParticipantInputDto,
|
||||
): ResolvedInquiryParticipant {
|
||||
if (Object.prototype.hasOwnProperty.call(input, "phoneNumber")) {
|
||||
throw new BadRequestException(
|
||||
`${role} does not accept phoneNumber; phone numbers are collected separately from inquiry identity.`,
|
||||
);
|
||||
}
|
||||
const nationalCode = String(input.nationalCode ?? "").trim();
|
||||
const birthday = String(input.birthday ?? "").trim();
|
||||
if (!nationalCode || !birthday) {
|
||||
throw new BadRequestException(
|
||||
`${role} requires nationalCode and birthday.`,
|
||||
);
|
||||
}
|
||||
if (
|
||||
role === InquiryParticipantRole.DRIVER &&
|
||||
typeof input.hasDrivingLicense !== "boolean"
|
||||
) {
|
||||
throw new BadRequestException("DRIVER requires hasDrivingLicense.");
|
||||
}
|
||||
if (
|
||||
role === InquiryParticipantRole.DRIVER &&
|
||||
input.hasDrivingLicense === true &&
|
||||
(!String(input.licenseNumber ?? "").trim() ||
|
||||
!String(input.licenseType ?? "").trim())
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"DRIVER requires licenseNumber and licenseType when hasDrivingLicense is true.",
|
||||
);
|
||||
}
|
||||
return {
|
||||
participantId: role,
|
||||
nationalCode,
|
||||
birthday,
|
||||
...(input.fullName ? { fullName: input.fullName } : {}),
|
||||
...(input.hasDrivingLicense != null
|
||||
? { hasDrivingLicense: input.hasDrivingLicense }
|
||||
: {}),
|
||||
...(input.licenseNumber ? { licenseNumber: input.licenseNumber } : {}),
|
||||
...(input.licenseType ? { licenseType: input.licenseType } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveInquiryParticipants(
|
||||
caseType: BlameRequestType,
|
||||
input: Partial<InquiryParticipantFieldsDto> & Record<string, any>,
|
||||
options: InquiryParticipantResolutionOptions = {},
|
||||
): ResolvedInquiryParticipants {
|
||||
assertStructuredInquiryInput(input);
|
||||
const hasRoleCompleteInput = Object.values(ROLE_FIELDS).some(
|
||||
(field) => input[field] != null,
|
||||
);
|
||||
if (!hasRoleCompleteInput) {
|
||||
throw new BadRequestException(
|
||||
"driver, vehicleOwner, and thirdPartyPolicyholder are required in the structured inquiry format.",
|
||||
);
|
||||
}
|
||||
if (
|
||||
caseType === BlameRequestType.THIRD_PARTY &&
|
||||
input.carBodyPolicyholder != null
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"CAR_BODY_POLICYHOLDER is not allowed for a THIRD_PARTY case.",
|
||||
);
|
||||
}
|
||||
|
||||
const requiredRoles = [
|
||||
InquiryParticipantRole.DRIVER,
|
||||
InquiryParticipantRole.VEHICLE_OWNER,
|
||||
InquiryParticipantRole.THIRD_PARTY_POLICYHOLDER,
|
||||
...(caseType === BlameRequestType.CAR_BODY
|
||||
? [InquiryParticipantRole.CAR_BODY_POLICYHOLDER]
|
||||
: []),
|
||||
];
|
||||
const participants = new Map<string, ResolvedInquiryParticipant>();
|
||||
const resolvedRoleIds = new Map<InquiryParticipantRole, string>();
|
||||
const resolving = new Set<InquiryParticipantRole>();
|
||||
|
||||
const resolveRole = (role: InquiryParticipantRole): string => {
|
||||
const existing = resolvedRoleIds.get(role);
|
||||
if (existing) return existing;
|
||||
if (resolving.has(role)) {
|
||||
throw new BadRequestException(
|
||||
"Participant sameAs references cannot be circular.",
|
||||
);
|
||||
}
|
||||
const value = input[ROLE_FIELDS[role]] as
|
||||
| InquiryParticipantInputDto
|
||||
| undefined;
|
||||
if (!value) throw new BadRequestException(`${role} is required.`);
|
||||
|
||||
resolving.add(role);
|
||||
let participantId: string;
|
||||
if (
|
||||
role === InquiryParticipantRole.THIRD_PARTY_POLICYHOLDER &&
|
||||
value.unknown === true
|
||||
) {
|
||||
if (!options.allowUnknownThirdPartyPolicyholder) {
|
||||
throw new BadRequestException(
|
||||
"An unknown third-party policyholder is allowed only for the damaged party.",
|
||||
);
|
||||
}
|
||||
const hasIdentityFields = Object.entries(value).some(
|
||||
([field, fieldValue]) => field !== "unknown" && fieldValue != null,
|
||||
);
|
||||
if (hasIdentityFields) {
|
||||
throw new BadRequestException(
|
||||
`${role} must contain either unknown=true or person fields, not both.`,
|
||||
);
|
||||
}
|
||||
const participant: ResolvedInquiryParticipant = {
|
||||
participantId: role,
|
||||
nationalCode: "",
|
||||
birthday: "",
|
||||
unknown: true,
|
||||
};
|
||||
participants.set(participant.participantId, participant);
|
||||
participantId = participant.participantId;
|
||||
} else if (value.unknown != null) {
|
||||
throw new BadRequestException(
|
||||
`${role} does not support the unknown option.`,
|
||||
);
|
||||
} else if (value.sameAs) {
|
||||
const hasPersonSpecificFields = Object.entries(value).some(
|
||||
([field, fieldValue]) => field !== "sameAs" && fieldValue != null,
|
||||
);
|
||||
if (hasPersonSpecificFields) {
|
||||
throw new BadRequestException(
|
||||
`${role} must contain either sameAs or identity fields, not both.`,
|
||||
);
|
||||
}
|
||||
participantId = resolveRole(value.sameAs);
|
||||
} else {
|
||||
const participant = requiredIdentity(role, value);
|
||||
const duplicate = [...participants.values()].find(
|
||||
(item) => item.nationalCode === participant.nationalCode,
|
||||
);
|
||||
if (duplicate) {
|
||||
throw new BadRequestException(
|
||||
`${role} duplicates an existing nationalCode; use sameAs instead.`,
|
||||
);
|
||||
}
|
||||
participants.set(participant.participantId, participant);
|
||||
participantId = participant.participantId;
|
||||
}
|
||||
resolving.delete(role);
|
||||
resolvedRoleIds.set(role, participantId);
|
||||
return participantId;
|
||||
};
|
||||
|
||||
for (const role of requiredRoles) resolveRole(role);
|
||||
|
||||
return {
|
||||
participants: [...participants.values()],
|
||||
roles: {
|
||||
driver: resolvedRoleIds.get(InquiryParticipantRole.DRIVER)!,
|
||||
vehicleOwner: resolvedRoleIds.get(InquiryParticipantRole.VEHICLE_OWNER)!,
|
||||
thirdPartyPolicyholder: resolvedRoleIds.get(
|
||||
InquiryParticipantRole.THIRD_PARTY_POLICYHOLDER,
|
||||
)!,
|
||||
...(caseType === BlameRequestType.CAR_BODY
|
||||
? {
|
||||
carBodyPolicyholder: resolvedRoleIds.get(
|
||||
InquiryParticipantRole.CAR_BODY_POLICYHOLDER,
|
||||
)!,
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
legacy: false,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveInquiryVehicle(
|
||||
input: InquiryVehicleInputDto,
|
||||
): ResolvedInquiryVehicle {
|
||||
const registrationState =
|
||||
input.registrationState ?? VehicleRegistrationState.CURRENT;
|
||||
if (!input.currentPlate) {
|
||||
throw new BadRequestException("vehicle.currentPlate is required.");
|
||||
}
|
||||
if (
|
||||
registrationState === VehicleRegistrationState.RECENTLY_TRANSFERRED &&
|
||||
(!input.previousPlate || !String(input.vin ?? "").trim())
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"RECENTLY_TRANSFERRED requires previousPlate and vin.",
|
||||
);
|
||||
}
|
||||
if (
|
||||
registrationState !== VehicleRegistrationState.RECENTLY_TRANSFERRED &&
|
||||
input.previousPlate
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"previousPlate is only allowed for RECENTLY_TRANSFERRED vehicles.",
|
||||
);
|
||||
}
|
||||
return { ...input, registrationState };
|
||||
}
|
||||
|
||||
export function vehiclePlateCandidates(input?: ResolvedInquiryVehicle): Array<{
|
||||
kind: "CURRENT" | "PREVIOUS";
|
||||
plate: InquiryVehicleInputDto["currentPlate"];
|
||||
}> {
|
||||
if (!input) return [];
|
||||
return [
|
||||
{ kind: "CURRENT" as const, plate: input.currentPlate },
|
||||
...(input.registrationState ===
|
||||
VehicleRegistrationState.RECENTLY_TRANSFERRED && input.previousPlate
|
||||
? [{ kind: "PREVIOUS" as const, plate: input.previousPlate }]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
function normalizeVehicleSerial(value: unknown): string {
|
||||
return String(value ?? "")
|
||||
.toUpperCase()
|
||||
.replace(/[^A-Z0-9]/g, "");
|
||||
}
|
||||
|
||||
/** A dated result is usable only while the returned policy has not expired. */
|
||||
export function isMappedPolicyCurrent(
|
||||
mapped: Record<string, any>,
|
||||
todayGregorian: string = gregorianDateInIran(new Date()),
|
||||
): boolean {
|
||||
const rawEndDate =
|
||||
mapped?.EndDate ??
|
||||
mapped?.HEndDte ??
|
||||
mapped?.persianEndDate ??
|
||||
mapped?.PolicyEndDate ??
|
||||
mapped?.endDate;
|
||||
if (rawEndDate == null || String(rawEndDate).trim() === "") return true;
|
||||
const endDate = jalaliToGregorianDate(rawEndDate);
|
||||
return endDate != null && endDate >= todayGregorian;
|
||||
}
|
||||
|
||||
function normalizePlateForComparison(
|
||||
plate: InquiryVehicleInputDto["currentPlate"],
|
||||
): string {
|
||||
return [
|
||||
plate?.ir,
|
||||
plate?.leftDigits,
|
||||
plate?.centerAlphabet,
|
||||
plate?.centerDigits,
|
||||
]
|
||||
.map((part) => String(part ?? "").trim())
|
||||
.join("|");
|
||||
}
|
||||
|
||||
const LEGACY_INQUIRY_FIELDS = [
|
||||
"nationalCodeOfDriver",
|
||||
"driverBirthday",
|
||||
"driverLicense",
|
||||
"licenseType",
|
||||
"nationalCodeOfInsurer",
|
||||
"insurerBirthday",
|
||||
"insurerLicense",
|
||||
"driverIsInsurer",
|
||||
"userNoCertificate",
|
||||
"plate",
|
||||
"plateId",
|
||||
"vin",
|
||||
"isNewCar",
|
||||
] as const;
|
||||
|
||||
function assertStructuredInquiryInput(input: Record<string, any>): void {
|
||||
const legacyFields = LEGACY_INQUIRY_FIELDS.filter((field) =>
|
||||
Object.prototype.hasOwnProperty.call(input, field),
|
||||
);
|
||||
if (legacyFields.length > 0) {
|
||||
throw new BadRequestException(
|
||||
`Legacy inquiry fields are not accepted: ${legacyFields.join(", ")}. Use driver, vehicleOwner, thirdPartyPolicyholder, carBodyPolicyholder, and vehicle.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function assertPreviousPlateInquiryMatchesVin(
|
||||
expectedVin: string,
|
||||
mapped: Record<string, any>,
|
||||
): void {
|
||||
const expected = normalizeVehicleSerial(expectedVin);
|
||||
const candidates = [
|
||||
mapped?.VinNumberField,
|
||||
mapped?.vin,
|
||||
mapped?.VIN,
|
||||
mapped?.ChassisNumberField,
|
||||
mapped?.chassisNumber,
|
||||
mapped?.ChassisNo,
|
||||
mapped?.vehicle?.VIN,
|
||||
mapped?.vehicle?.ChassisNo,
|
||||
]
|
||||
.map(normalizeVehicleSerial)
|
||||
.filter(Boolean);
|
||||
if (!expected || !candidates.includes(expected)) {
|
||||
throw new BadRequestException(
|
||||
"Previous-plate inquiry does not match the submitted VIN/chassis; manual review is required.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function isPolicyNotFoundError(error: unknown): boolean {
|
||||
const candidate = error as Record<string, any> | null;
|
||||
const status = candidate?.status ?? candidate?.response?.status;
|
||||
if (Number(status) === 404) return true;
|
||||
const code = String(
|
||||
candidate?.code ?? candidate?.response?.data?.code ?? "",
|
||||
).toUpperCase();
|
||||
if (["NOT_FOUND", "POLICY_NOT_FOUND", "NO_POLICY"].includes(code)) {
|
||||
return true;
|
||||
}
|
||||
const message = String(
|
||||
candidate?.message ?? candidate?.response?.data?.message ?? error ?? "",
|
||||
);
|
||||
return /\bnot[ -]?found\b|\bno (?:relevant )?policy\b|یافت نشد|فاقد بیمه(?:نامه)?/i.test(
|
||||
message,
|
||||
);
|
||||
}
|
||||
|
||||
export async function runPlateInquiryWithFallback<T>(options: {
|
||||
vehicle?: ResolvedInquiryVehicle;
|
||||
fallbackCurrentPlate: InquiryVehicleInputDto["currentPlate"];
|
||||
query: (plate: InquiryVehicleInputDto["currentPlate"]) => Promise<T>;
|
||||
isUsable: (value: T) => boolean;
|
||||
mappedValue: (value: T) => Record<string, any>;
|
||||
shouldFallbackOnError?: (error: unknown) => boolean;
|
||||
}): Promise<{
|
||||
value: T;
|
||||
plateKind: "CURRENT" | "PREVIOUS";
|
||||
attempts: Array<{
|
||||
plateKind: "CURRENT" | "PREVIOUS";
|
||||
plate: InquiryVehicleInputDto["currentPlate"];
|
||||
vin?: string;
|
||||
succeeded: boolean;
|
||||
usable?: boolean;
|
||||
error?: string;
|
||||
}>;
|
||||
}> {
|
||||
const candidates = options.vehicle
|
||||
? vehiclePlateCandidates(options.vehicle)
|
||||
: [{ kind: "CURRENT" as const, plate: options.fallbackCurrentPlate }];
|
||||
let lastError: unknown;
|
||||
const attempts: Array<{
|
||||
plateKind: "CURRENT" | "PREVIOUS";
|
||||
plate: InquiryVehicleInputDto["currentPlate"];
|
||||
vin?: string;
|
||||
succeeded: boolean;
|
||||
usable?: boolean;
|
||||
error?: string;
|
||||
}> = [];
|
||||
|
||||
for (let index = 0; index < candidates.length; index += 1) {
|
||||
const candidate = candidates[index];
|
||||
const isLast = index === candidates.length - 1;
|
||||
try {
|
||||
const value = await options.query(candidate.plate);
|
||||
const usable = options.isUsable(value);
|
||||
if (!usable) {
|
||||
attempts.push({
|
||||
plateKind: candidate.kind,
|
||||
plate: candidate.plate,
|
||||
...(options.vehicle?.vin ? { vin: options.vehicle.vin } : {}),
|
||||
succeeded: true,
|
||||
usable: false,
|
||||
});
|
||||
if (!isLast) continue;
|
||||
const error = new BadRequestException(
|
||||
"No current usable policy was found for the submitted vehicle identifiers.",
|
||||
) as BadRequestException & { attempts?: typeof attempts };
|
||||
error.attempts = attempts;
|
||||
throw error;
|
||||
}
|
||||
if (candidate.kind === "PREVIOUS" && usable) {
|
||||
assertPreviousPlateInquiryMatchesVin(
|
||||
options.vehicle!.vin!,
|
||||
options.mappedValue(value),
|
||||
);
|
||||
}
|
||||
attempts.push({
|
||||
plateKind: candidate.kind,
|
||||
plate: candidate.plate,
|
||||
...(options.vehicle?.vin ? { vin: options.vehicle.vin } : {}),
|
||||
succeeded: true,
|
||||
usable: true,
|
||||
});
|
||||
return { value, plateKind: candidate.kind, attempts };
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
const alreadyRecorded =
|
||||
typeof error === "object" &&
|
||||
error != null &&
|
||||
Array.isArray((error as { attempts?: unknown }).attempts);
|
||||
if (!alreadyRecorded) {
|
||||
attempts.push({
|
||||
plateKind: candidate.kind,
|
||||
plate: candidate.plate,
|
||||
...(options.vehicle?.vin ? { vin: options.vehicle.vin } : {}),
|
||||
succeeded: false,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
});
|
||||
}
|
||||
if (
|
||||
!isLast &&
|
||||
!(options.shouldFallbackOnError ?? isPolicyNotFoundError)(error)
|
||||
) {
|
||||
if (typeof error === "object" && error != null) {
|
||||
(error as { attempts?: typeof attempts }).attempts = attempts;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (isLast) {
|
||||
if (typeof error === "object" && error != null) {
|
||||
(error as { attempts?: typeof attempts }).attempts = attempts;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw lastError ?? new BadRequestException("Inquiry failed for all plates.");
|
||||
}
|
||||
|
||||
export function normalizeInquirySubmission<T extends Record<string, any>>(
|
||||
caseType: BlameRequestType,
|
||||
input: T,
|
||||
options: InquiryParticipantResolutionOptions = {},
|
||||
): NormalizedInquirySubmission<T> {
|
||||
const participants = resolveInquiryParticipants(
|
||||
caseType,
|
||||
input as any,
|
||||
options,
|
||||
);
|
||||
const driver = participantForRole(
|
||||
participants,
|
||||
InquiryParticipantRole.DRIVER,
|
||||
);
|
||||
const thirdPartyPolicyholder = participantForRole(
|
||||
participants,
|
||||
InquiryParticipantRole.THIRD_PARTY_POLICYHOLDER,
|
||||
);
|
||||
if (!driver || !thirdPartyPolicyholder) {
|
||||
throw new BadRequestException(
|
||||
"Driver and third-party policyholder identities are required.",
|
||||
);
|
||||
}
|
||||
const vehicleOwner = participantForRole(
|
||||
participants,
|
||||
InquiryParticipantRole.VEHICLE_OWNER,
|
||||
);
|
||||
const carBodyPolicyholder = participantForRole(
|
||||
participants,
|
||||
InquiryParticipantRole.CAR_BODY_POLICYHOLDER,
|
||||
);
|
||||
const vehicle = resolveInquiryVehicle(
|
||||
input.vehicle as InquiryVehicleInputDto,
|
||||
);
|
||||
const sameDriverAndPolicyholder =
|
||||
participants.roles.driver === participants.roles.thirdPartyPolicyholder;
|
||||
|
||||
return {
|
||||
dto: {
|
||||
...input,
|
||||
plate: vehicle.currentPlate,
|
||||
vin: vehicle.vin,
|
||||
nationalCodeOfDriver: driver.nationalCode,
|
||||
driverBirthday: driver.birthday,
|
||||
driverLicense: driver.licenseNumber,
|
||||
licenseType: driver.licenseType,
|
||||
userNoCertificate:
|
||||
driver.hasDrivingLicense == null
|
||||
? undefined
|
||||
: !driver.hasDrivingLicense,
|
||||
nationalCodeOfInsurer: thirdPartyPolicyholder.nationalCode,
|
||||
insurerBirthday: thirdPartyPolicyholder.birthday,
|
||||
driverIsInsurer: sameDriverAndPolicyholder,
|
||||
insurerLicense: sameDriverAndPolicyholder
|
||||
? driver.licenseNumber
|
||||
: undefined,
|
||||
isNewCar: vehicle.isNewCar,
|
||||
} as NormalizedInquirySubmission<T>["dto"],
|
||||
participants,
|
||||
driver,
|
||||
vehicleOwner,
|
||||
thirdPartyPolicyholder,
|
||||
carBodyPolicyholder,
|
||||
vehicle,
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user