diff --git a/src/request-management/request-management.service.ts b/src/request-management/request-management.service.ts index 3b3df8b..7100100 100644 --- a/src/request-management/request-management.service.ts +++ b/src/request-management/request-management.service.ts @@ -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.", );