forked from Yara724/api
fanavaran driver and owner id (GEN..44 defauts) - culprit type id dynamic
This commit is contained in:
@@ -25,6 +25,9 @@ export type FanavaranOtherPeopleSource = {
|
||||
nationalCode?: unknown;
|
||||
birthday?: unknown;
|
||||
fullName?: unknown;
|
||||
/** Prefer these over splitting fullName when inquiry already returned them. */
|
||||
name?: unknown;
|
||||
lastName?: unknown;
|
||||
fatherName?: unknown;
|
||||
mobile?: unknown;
|
||||
tel?: unknown;
|
||||
@@ -33,7 +36,13 @@ export type FanavaranOtherPeopleSource = {
|
||||
jobAddress?: unknown;
|
||||
postalCode?: unknown;
|
||||
cityName?: unknown;
|
||||
/** Direct Fanavaran CityId when known; else lookup / default 9131. */
|
||||
cityId?: unknown;
|
||||
gender?: unknown;
|
||||
/** Direct Fanavaran GenderId from parties inquiry when available. */
|
||||
genderId?: unknown;
|
||||
/** Direct Fanavaran PersonKindId; else lookup / default 46 (حقیقی). */
|
||||
personKindId?: unknown;
|
||||
isIranian?: boolean;
|
||||
naturalizedCode?: unknown;
|
||||
identityNo?: unknown;
|
||||
@@ -82,6 +91,10 @@ const ANS_YES_TEXTS = ["بله", "بلی", "yes", "1"];
|
||||
const NATURAL_PERSON_TEXTS = ["حقیقی", "شخص حقیقی", "طبيعي", "natural"];
|
||||
const IRAN_COUNTRY_TEXTS = ["ایران", "ايران", "iran"];
|
||||
|
||||
/** Proven Parsian GEN.44 defaults when lookup / city name is missing. */
|
||||
export const FANAVARAN_OTHER_PEOPLE_DEFAULT_CITY_ID = 9131;
|
||||
export const FANAVARAN_OTHER_PEOPLE_DEFAULT_PERSON_KIND_ID = 46;
|
||||
|
||||
function asLookupRows(value: unknown): FanavaranLookupRow[] {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value.filter(
|
||||
@@ -213,8 +226,8 @@ export function buildFanavaranOtherPeoplePayload(
|
||||
|
||||
return {
|
||||
NationalCode: nationalCode,
|
||||
Name: names.name,
|
||||
LastName: names.lastName,
|
||||
Name: emptyToNull(source.name) ?? names.name,
|
||||
LastName: emptyToNull(source.lastName) ?? names.lastName,
|
||||
FatherName: emptyToNull(source.fatherName),
|
||||
BirthYear: birthday.year,
|
||||
BirthMonth: birthday.month,
|
||||
@@ -235,8 +248,13 @@ export function buildFanavaranOtherPeoplePayload(
|
||||
CompanyCode: emptyToNull(source.companyCode),
|
||||
IdentityNo: emptyToNull(source.identityNo),
|
||||
RegisterNo: emptyToNull(source.registerNo),
|
||||
CityId: pickLookupIdByCaption(lookups.cities, [source.cityName]),
|
||||
GenderId: pickLookupIdByCaption(lookups.gender, genderTexts),
|
||||
CityId:
|
||||
asPositiveId(source.cityId) ??
|
||||
pickLookupIdByCaption(lookups.cities, [source.cityName]) ??
|
||||
FANAVARAN_OTHER_PEOPLE_DEFAULT_CITY_ID,
|
||||
GenderId:
|
||||
asPositiveId(source.genderId) ??
|
||||
pickLookupIdByCaption(lookups.gender, genderTexts),
|
||||
MaritalStatus: pickLookupIdByCaption(lookups.maritalStatus, []),
|
||||
IsIranian: isIranian
|
||||
? (pickLookupIdByCaption(lookups.ans, ANS_YES_TEXTS) ?? 1)
|
||||
@@ -244,9 +262,9 @@ export function buildFanavaranOtherPeoplePayload(
|
||||
NationalityId: isIranian
|
||||
? null
|
||||
: pickLookupIdByCaption(lookups.countries, IRAN_COUNTRY_TEXTS),
|
||||
PersonKindId: pickLookupIdByCaption(
|
||||
lookups.personKind,
|
||||
NATURAL_PERSON_TEXTS,
|
||||
),
|
||||
PersonKindId:
|
||||
asPositiveId(source.personKindId) ??
|
||||
pickLookupIdByCaption(lookups.personKind, NATURAL_PERSON_TEXTS) ??
|
||||
FANAVARAN_OTHER_PEOPLE_DEFAULT_PERSON_KIND_ID,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user