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) ---- // ---- 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 = const personalNationalCode =
body.nationalCodeOfInsurer || body.nationalCodeOfDriver; body.nationalCodeOfInsurer || body.nationalCodeOfDriver;
const birthDateRaw = const personalBirthDate: number | string | null =
body.insurerBirthday ?? body.driverBirthday ?? null; (body.insurerBirthday ?? body.driverBirthday ?? null) as
const birthDateDigits = String(birthDateRaw ?? "") | number
.replace(/\D/g, "") | string
.trim(); | null;
const personalBirthDate = Number(birthDateDigits); if (
if (!personalNationalCode || !Number.isFinite(personalBirthDate) || personalBirthDate <= 0) { !personalNationalCode ||
personalBirthDate === null ||
personalBirthDate === undefined ||
String(personalBirthDate).trim() === ""
) {
throw new BadRequestException( throw new BadRequestException(
"Valid nationalCode and birthDate are required for personal inquiry.", "Valid nationalCode and birthDate are required for personal inquiry.",
); );