forked from Yara724/api
Fixed YARA-1217
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { IsNotEmpty, IsString, MaxLength } from "class-validator";
|
||||
import { IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator";
|
||||
import { Types } from "mongoose";
|
||||
import { AddPlateDto } from "src/profile/dto/user/AddPlateDto";
|
||||
import { StepsEnum } from "src/Types&Enums/blame-request-management/steps.enum";
|
||||
@@ -98,20 +98,24 @@ export class DescriptionV4Dto {
|
||||
@IsNotEmpty()
|
||||
desc: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: "Date of the accident (required for all V4 files)",
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Date of the accident. Required for the first (guilty) party; " +
|
||||
"optional for the second (damaged) party.",
|
||||
example: "2025-12-08",
|
||||
})
|
||||
@IsNotEmpty()
|
||||
accidentDate: Date;
|
||||
@IsOptional()
|
||||
accidentDate?: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: "Time of the accident (required for all V4 files)",
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"Time of the accident. Required for the first (guilty) party; " +
|
||||
"optional for the second (damaged) party.",
|
||||
example: "14:30",
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
accidentTime: string;
|
||||
accidentTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10280,37 +10280,35 @@ export class RequestManagementService {
|
||||
body: DescriptionV4Dto,
|
||||
partyRole?: string,
|
||||
) {
|
||||
if (
|
||||
body.accidentDate == null ||
|
||||
body.accidentDate === ("" as any)
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"accidentDate is required for V4 files.",
|
||||
);
|
||||
}
|
||||
if (
|
||||
!body.accidentTime ||
|
||||
!String(body.accidentTime).trim()
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"accidentTime is required for V4 files.",
|
||||
);
|
||||
}
|
||||
|
||||
const req = await this.blameRequestDbService.findById(requestId);
|
||||
if (!req) throw new NotFoundException("Request not found");
|
||||
await this.verifyExpertAccessForBlameV2(req, actor);
|
||||
const role = this.resolvePartyRoleV3(req, partyRole);
|
||||
this.assertBlameV3PartyDetailPhase(req, role);
|
||||
|
||||
// accidentDate and accidentTime are only required for the first (guilty)
|
||||
// party — the second (damaged) party can skip them.
|
||||
if (role === PartyRole.FIRST) {
|
||||
if (body.accidentDate == null || body.accidentDate === ("" as any)) {
|
||||
throw new BadRequestException(
|
||||
"accidentDate is required for the first party in V4 files.",
|
||||
);
|
||||
}
|
||||
if (!body.accidentTime || !String(body.accidentTime).trim()) {
|
||||
throw new BadRequestException(
|
||||
"accidentTime is required for the first party in V4 files.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const idx = this.getPartyIndex(req, role);
|
||||
if (idx === -1) throw new BadRequestException(`${role} party not found`);
|
||||
|
||||
const party = req.parties[idx];
|
||||
if (!party.statement) party.statement = {} as any;
|
||||
party.statement.description = body.desc;
|
||||
party.statement.accidentDate = body.accidentDate as any;
|
||||
party.statement.accidentTime = body.accidentTime;
|
||||
if (body.accidentDate != null) party.statement.accidentDate = body.accidentDate as any;
|
||||
if (body.accidentTime) party.statement.accidentTime = body.accidentTime;
|
||||
|
||||
if (!Array.isArray(req.history)) req.history = [];
|
||||
req.history.push({
|
||||
|
||||
Reference in New Issue
Block a user