forked from Yara724/api
Fix transferred vehicle inquiry routing
This commit is contained in:
@@ -14,6 +14,7 @@ import { ExternalExceptionFilter } from "@nestjs/core/exceptions/external-except
|
||||
import { Types } from "mongoose";
|
||||
import { ClientService } from "src/client/client.service";
|
||||
import { AddPlateDto } from "src/profile/dto/user/AddPlateDto";
|
||||
import { VehicleRegistrationState } from "src/common/dto/inquiry-participants.dto";
|
||||
import {
|
||||
CarBodyFormDto,
|
||||
CarBodySecondForm,
|
||||
@@ -466,6 +467,29 @@ export class RequestManagementService {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A VIN submission still carries the canonical current plate. For a recent
|
||||
* transfer, the car-body policy must be checked against that current plate
|
||||
* and the current policyholder; the previous plate is historical metadata
|
||||
* only. For ordinary VIN submissions we retain the dedicated VIN lookup.
|
||||
*/
|
||||
private async getCarBodyInquiryForVinSubmission(
|
||||
submission: NormalizedInquirySubmission<Record<string, any>>,
|
||||
): Promise<any> {
|
||||
if (
|
||||
submission.vehicle?.registrationState ===
|
||||
VehicleRegistrationState.RECENTLY_TRANSFERRED
|
||||
) {
|
||||
return this.getCarBodyPlateInquiry(submission);
|
||||
}
|
||||
|
||||
const subjects = resolveInquirySubjects(submission);
|
||||
return this.sandHubService.getCarBodyInquiry({
|
||||
nationalCodeOfInsurer: subjects.carBodyPolicyNationalCode!,
|
||||
plate: submission.vehicle?.vin as any,
|
||||
});
|
||||
}
|
||||
|
||||
private async getThirdPartyVinInquiry(
|
||||
submission: NormalizedInquirySubmission<Record<string, any>>,
|
||||
options?: Record<string, any>,
|
||||
@@ -2519,10 +2543,8 @@ export class RequestManagementService {
|
||||
// flow before the case is allowed to advance.
|
||||
if (req.type === BlameRequestType.CAR_BODY && role === PartyRole.FIRST) {
|
||||
try {
|
||||
const carBodyInfo = await this.sandHubService.getCarBodyInquiry({
|
||||
nationalCodeOfInsurer: subjects.carBodyPolicyNationalCode!,
|
||||
plate: body.vin,
|
||||
});
|
||||
const carBodyInfo =
|
||||
await this.getCarBodyInquiryForVinSubmission(inquirySubmission);
|
||||
this.recordPartyCaseInquiryStatus(req, "carBody", role, true, {
|
||||
source: carBodyInfo.source,
|
||||
raw: carBodyInfo.raw,
|
||||
@@ -11117,10 +11139,8 @@ export class RequestManagementService {
|
||||
partyRole === PartyRole.FIRST
|
||||
) {
|
||||
try {
|
||||
const carBodyInfo = await this.sandHubService.getCarBodyInquiry({
|
||||
nationalCodeOfInsurer: subjects.carBodyPolicyNationalCode!,
|
||||
plate: partyData.vin as any, // VIN used as identifier for CAR_BODY
|
||||
});
|
||||
const carBodyInfo =
|
||||
await this.getCarBodyInquiryForVinSubmission(inquirySubmission);
|
||||
this.recordPartyCaseInquiryStatus(req, "carBody", partyRole, true, {
|
||||
source: carBodyInfo.source,
|
||||
raw: carBodyInfo.raw,
|
||||
|
||||
Reference in New Issue
Block a user