1
0
forked from Yara724/api

Fixed personal inquiry

This commit is contained in:
SepehrYahyaee
2026-05-09 16:17:28 +03:30
parent eb648d8a87
commit fe163419c0

View File

@@ -870,15 +870,24 @@ export class RequestManagementService {
}
// ---- External inquiry 2: personal identity check (insurer/driver nationalCode + birthDate) ----
// The form sends the birthday as a Jalali date in any of these shapes:
// - number 13770624 (packed YYYYMMDD)
// - string "1377-06-24" / "1377/06/24" / "13770624"
// We forward it as-is; sandHubService.getPersonalInquiry() handles the
// Jalali → Gregorian conversion required by the external API.
const personalNationalCode =
body.nationalCodeOfInsurer || body.nationalCodeOfDriver;
const birthDateRaw =
body.insurerBirthday ?? body.driverBirthday ?? null;
const birthDateDigits = String(birthDateRaw ?? "")
.replace(/\D/g, "")
.trim();
const personalBirthDate = Number(birthDateDigits);
if (!personalNationalCode || !Number.isFinite(personalBirthDate) || personalBirthDate <= 0) {
const personalBirthDate: number | string | null =
(body.insurerBirthday ?? body.driverBirthday ?? null) as
| number
| string
| null;
if (
!personalNationalCode ||
personalBirthDate === null ||
personalBirthDate === undefined ||
String(personalBirthDate).trim() === ""
) {
throw new BadRequestException(
"Valid nationalCode and birthDate are required for personal inquiry.",
);