forked from Yara724/api
Centralized car body inquiry
This commit is contained in:
@@ -1118,13 +1118,44 @@ export class RequestManagementService {
|
||||
party.insurance.startDate = inquiryMapped?.IssueDate;
|
||||
party.insurance.endDate = inquiryMapped?.EndDate;
|
||||
|
||||
// CAR_BODY: persist mocked car-body insurance in party's insurance (same place as usual inquiry)
|
||||
// CAR BODY EXTERNAL API INQUIRY
|
||||
if (req.type === BlameRequestType.CAR_BODY && role === PartyRole.FIRST) {
|
||||
const carBodyInfo = await this.sandHubService.getTejaratCarBodyInquiry({
|
||||
nationalCodeOfInsurer: body.nationalCodeOfInsurer,
|
||||
plate: body.plate,
|
||||
});
|
||||
(party.insurance as any).carBodyInsurance = carBodyInfo;
|
||||
|
||||
// Raw + mapped stored under vehicle (same pattern as third-party inquiry)
|
||||
party.vehicle.inquiry = {
|
||||
...party.vehicle.inquiry, // preserve existing third-party inquiry if present
|
||||
carBody: {
|
||||
source: "TEJARAT_CAR_BODY_INQUIRY",
|
||||
raw: carBodyInfo.raw,
|
||||
mapped: carBodyInfo.mapped,
|
||||
},
|
||||
};
|
||||
|
||||
// Flat key fields extracted alongside third-party insurance fields
|
||||
const m = carBodyInfo.mapped;
|
||||
(party.insurance as any).carBodyInsurance = {
|
||||
policyNumber: m.policyNumber ?? null,
|
||||
companyId: m.companyId ?? null,
|
||||
companyName: m.CompanyName ?? null,
|
||||
insurerName: m.insurerName ?? null,
|
||||
insurerNationalCode: m.insurerNationalCode ?? null,
|
||||
ownerNationalCode: m.ownerNationalCode ?? null,
|
||||
chassisNumber: m.ChassisNumberField ?? null,
|
||||
vin: m.VinNumberField ?? null,
|
||||
motorNumber: m.EngineNumberField ?? null,
|
||||
vehicleGroup: m.vehicleGroupTitle ?? null,
|
||||
vehicleSystem: m.vehicleSystemTitle ?? null,
|
||||
startDate: m.StartDate ?? null,
|
||||
endDate: m.EndDate ?? null,
|
||||
issueDate: m.IssueDate ?? null,
|
||||
noLossYearsCount: m.noLossYearsCount ?? null,
|
||||
lossDocuments: m.lossDocuments ?? [],
|
||||
hasEndorsement: m.hasEndorsement ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
// Advance workflow
|
||||
|
||||
Reference in New Issue
Block a user