forked from Yara724/api
YARA-784
This commit is contained in:
@@ -4039,6 +4039,9 @@ export class RequestManagementService {
|
||||
if (!formData.carBodyForm) {
|
||||
throw new BadRequestException("carBodyForm is required.");
|
||||
}
|
||||
if (!formData?.expertDescription?.desc) {
|
||||
throw new BadRequestException("expertDescription.desc is required.");
|
||||
}
|
||||
|
||||
const firstPartyUserId = await this.getOrCreateUserByPhoneNumber(
|
||||
formData.firstPartyPhoneNumber,
|
||||
@@ -4110,12 +4113,12 @@ export class RequestManagementService {
|
||||
},
|
||||
},
|
||||
statement: {
|
||||
description: formData.firstPartyDescription?.desc,
|
||||
accidentDate: formData.firstPartyDescription?.accidentDate,
|
||||
accidentTime: formData.firstPartyDescription?.accidentTime,
|
||||
weatherCondition: formData.firstPartyDescription?.weatherCondition,
|
||||
roadCondition: formData.firstPartyDescription?.roadCondition,
|
||||
lightCondition: formData.firstPartyDescription?.lightCondition,
|
||||
description: formData.expertDescription?.desc,
|
||||
accidentDate: formData.expertDescription?.accidentDate,
|
||||
accidentTime: formData.expertDescription?.accidentTime,
|
||||
weatherCondition: formData.expertDescription?.weatherCondition,
|
||||
roadCondition: formData.expertDescription?.roadCondition,
|
||||
lightCondition: formData.expertDescription?.lightCondition,
|
||||
},
|
||||
location: req.parties?.[0]?.location,
|
||||
carBodyFirstForm: {
|
||||
@@ -4184,6 +4187,9 @@ export class RequestManagementService {
|
||||
if (!formData.secondParty || !formData.guiltyPartyPhoneNumber) {
|
||||
throw new BadRequestException("secondParty and guiltyPartyPhoneNumber are required.");
|
||||
}
|
||||
if (!formData?.expertDescription?.desc) {
|
||||
throw new BadRequestException("expertDescription.desc is required.");
|
||||
}
|
||||
|
||||
const firstPartyUserId = await this.getOrCreateUserByPhoneNumber(
|
||||
formData.firstPartyPhoneNumber,
|
||||
@@ -4254,7 +4260,7 @@ export class RequestManagementService {
|
||||
firstPartyUserId,
|
||||
formData.firstPartyInitialForm,
|
||||
formData.firstPartyPlate,
|
||||
formData.firstPartyDescription?.desc || "",
|
||||
formData.expertDescription?.desc || "",
|
||||
PartyRole.FIRST,
|
||||
);
|
||||
const secondParty = await buildPartyFromForm(
|
||||
@@ -4262,7 +4268,7 @@ export class RequestManagementService {
|
||||
secondPartyUserId,
|
||||
formData.secondParty.initialForm,
|
||||
formData.secondParty.plate,
|
||||
formData.secondParty.description?.desc || "",
|
||||
formData.expertDescription?.desc || "",
|
||||
PartyRole.SECOND,
|
||||
);
|
||||
|
||||
@@ -4320,7 +4326,7 @@ export class RequestManagementService {
|
||||
async expertAddLocationsForBlameV2(
|
||||
expert: any,
|
||||
requestId: string,
|
||||
dto: { firstPartyLocation: LocationDto; secondPartyLocation?: LocationDto },
|
||||
dto: { location: LocationDto },
|
||||
): Promise<any> {
|
||||
const req = await this.blameRequestDbService.findById(requestId);
|
||||
if (!req) throw new NotFoundException("Request not found");
|
||||
@@ -4336,21 +4342,10 @@ export class RequestManagementService {
|
||||
|
||||
const firstIdx = this.getPartyIndex(req, PartyRole.FIRST);
|
||||
if (firstIdx === -1) throw new BadRequestException("First party not found");
|
||||
if (!dto?.firstPartyLocation) {
|
||||
throw new BadRequestException("firstPartyLocation is required");
|
||||
}
|
||||
req.parties[firstIdx].location = dto.firstPartyLocation as any;
|
||||
|
||||
if (req.type === BlameRequestType.THIRD_PARTY) {
|
||||
const secondIdx = this.getPartyIndex(req, PartyRole.SECOND);
|
||||
if (secondIdx === -1) throw new BadRequestException("Second party not found");
|
||||
if (!dto?.secondPartyLocation) {
|
||||
throw new BadRequestException(
|
||||
"secondPartyLocation is required for THIRD_PARTY",
|
||||
);
|
||||
}
|
||||
req.parties[secondIdx].location = dto.secondPartyLocation as any;
|
||||
if (!dto?.location) {
|
||||
throw new BadRequestException("location is required");
|
||||
}
|
||||
req.parties[firstIdx].location = dto.location as any;
|
||||
|
||||
const completed = Array.isArray(req.workflow?.completedSteps)
|
||||
? req.workflow.completedSteps
|
||||
@@ -4358,12 +4353,6 @@ export class RequestManagementService {
|
||||
if (!completed.includes(WorkflowStep.FIRST_LOCATION as any)) {
|
||||
completed.push(WorkflowStep.FIRST_LOCATION as any);
|
||||
}
|
||||
if (
|
||||
req.type === BlameRequestType.THIRD_PARTY &&
|
||||
!completed.includes(WorkflowStep.SECOND_LOCATION as any)
|
||||
) {
|
||||
completed.push(WorkflowStep.SECOND_LOCATION as any);
|
||||
}
|
||||
|
||||
req.workflow = {
|
||||
...(req.workflow || {}),
|
||||
@@ -4383,8 +4372,7 @@ export class RequestManagementService {
|
||||
actorType: expert?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
||||
},
|
||||
metadata: {
|
||||
hasFirstLocation: true,
|
||||
hasSecondLocation: req.type === BlameRequestType.THIRD_PARTY,
|
||||
hasLocation: true,
|
||||
},
|
||||
} as any);
|
||||
|
||||
@@ -4467,6 +4455,12 @@ export class RequestManagementService {
|
||||
const firstPartyIndex = this.getPartyIndex(req, PartyRole.FIRST);
|
||||
if (firstPartyIndex === -1) throw new BadRequestException("First party not found");
|
||||
const firstParty = req.parties[firstPartyIndex];
|
||||
if (
|
||||
Array.isArray(firstParty?.evidence?.voices) &&
|
||||
firstParty.evidence.voices.length > 0
|
||||
) {
|
||||
throw new ConflictException("Voice already uploaded for this file");
|
||||
}
|
||||
|
||||
const voiceDocument = await this.blameVoiceDbService.create({
|
||||
fileName: voiceFile.filename,
|
||||
|
||||
Reference in New Issue
Block a user