forked from Yara724/api
update the car name
This commit is contained in:
@@ -356,15 +356,16 @@ export class InquiryRefreshService {
|
|||||||
...(existingCarBody ? { carBody: existingCarBody } : {}),
|
...(existingCarBody ? { carBody: existingCarBody } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
next.vehicle.name =
|
const vehicleName = this.resolveVehicleName(mapped, raw);
|
||||||
mapped.vehiclePersianName ||
|
if (vehicleName) {
|
||||||
mapped.MapTypNam ||
|
next.vehicle.name = vehicleName;
|
||||||
next.vehicle.name ||
|
}
|
||||||
"اطلاعات این گزینه در استعلام موجود نیست";
|
|
||||||
next.vehicle.type =
|
const vehicleType = this.resolveVehicleType(mapped, raw);
|
||||||
mapped.persianCarType ||
|
if (vehicleType) {
|
||||||
mapped.MapUsageName ||
|
next.vehicle.type = vehicleType;
|
||||||
next.vehicle.type;
|
}
|
||||||
|
|
||||||
next.insurance.policyNumber =
|
next.insurance.policyNumber =
|
||||||
mapped.LastCompanyDocumentNumber ||
|
mapped.LastCompanyDocumentNumber ||
|
||||||
mapped.insuranceNumber ||
|
mapped.insuranceNumber ||
|
||||||
@@ -387,6 +388,54 @@ export class InquiryRefreshService {
|
|||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Same sources as FIRST_INITIAL_FORM + common Tejarat/ESG field aliases */
|
||||||
|
private resolveVehicleName(
|
||||||
|
mapped: Record<string, any>,
|
||||||
|
raw: Record<string, any>,
|
||||||
|
): string | undefined {
|
||||||
|
return this.firstNonEmptyString(
|
||||||
|
mapped?.vehiclePersianName,
|
||||||
|
mapped?.MapTypNam,
|
||||||
|
mapped?.TypeNameCii,
|
||||||
|
mapped?.CarName,
|
||||||
|
raw?.vehiclePersianName,
|
||||||
|
raw?.MapTypNam,
|
||||||
|
raw?.TypeNameCii,
|
||||||
|
raw?.CarName,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Matches request-management: `${UsageField} / ${MapUsageName}` */
|
||||||
|
private resolveVehicleType(
|
||||||
|
mapped: Record<string, any>,
|
||||||
|
raw: Record<string, any>,
|
||||||
|
): string | undefined {
|
||||||
|
const usageField = this.firstNonEmptyString(
|
||||||
|
mapped?.UsageField,
|
||||||
|
mapped?.persianCarType,
|
||||||
|
raw?.UsageField,
|
||||||
|
raw?.UsageNameCii,
|
||||||
|
);
|
||||||
|
const usageName = this.firstNonEmptyString(
|
||||||
|
mapped?.MapUsageName,
|
||||||
|
raw?.MapUsageName,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (usageField && usageName) {
|
||||||
|
return `${usageField} / ${usageName}`;
|
||||||
|
}
|
||||||
|
return usageField || usageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private firstNonEmptyString(...values: unknown[]): string | undefined {
|
||||||
|
for (const value of values) {
|
||||||
|
if (value === undefined || value === null) continue;
|
||||||
|
const text = String(value).trim();
|
||||||
|
if (text) return text;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutate an existing Mongoose document in place instead of $set on a lean-cloned
|
* Mutate an existing Mongoose document in place instead of $set on a lean-cloned
|
||||||
* parties array (which causes "Cast to embedded failed" on ObjectId sub-fields).
|
* parties array (which causes "Cast to embedded failed" on ObjectId sub-fields).
|
||||||
|
|||||||
Reference in New Issue
Block a user