forked from Yara724/api
YARA-1216
This commit is contained in:
@@ -57,6 +57,7 @@ import { AutoCloseRequestService } from "src/utils/cron/cron.service";
|
||||
import { SmsOrchestrationService } from "src/sms-orchestration/sms-orchestration.service";
|
||||
import {
|
||||
DescriptionDto,
|
||||
DescriptionV4Dto,
|
||||
LocationDto,
|
||||
RequestManagementDtoRs,
|
||||
} from "./dto/create-request-management.dto";
|
||||
@@ -10260,6 +10261,72 @@ export class RequestManagementService {
|
||||
return { requestId: req._id, publicId: req.publicId, partyRole: role };
|
||||
}
|
||||
|
||||
/**
|
||||
* V4 description step.
|
||||
*
|
||||
* Identical to {@link addPartyDescriptionV3} but additionally requires
|
||||
* `accidentDate` and `accidentTime` for all blame types (THIRD_PARTY and
|
||||
* CAR_BODY alike) and persists them on `party.statement`. This lets the
|
||||
* front-end display the accident time consistently for every V4 file without
|
||||
* branching on blame type.
|
||||
*/
|
||||
async addPartyDescriptionV4(
|
||||
requestId: string,
|
||||
actor: any,
|
||||
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);
|
||||
|
||||
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 (!Array.isArray(req.history)) req.history = [];
|
||||
req.history.push({
|
||||
type: "V4_PARTY_DESCRIPTION_SAVED",
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
},
|
||||
metadata: {
|
||||
partyRole: role,
|
||||
accidentDate: body.accidentDate,
|
||||
accidentTime: body.accidentTime,
|
||||
},
|
||||
} as any);
|
||||
|
||||
await (req as any).save();
|
||||
return { requestId: req._id, publicId: req.publicId, partyRole: role };
|
||||
}
|
||||
|
||||
async carBodyAccidentTypeFormV3(
|
||||
requestId: string,
|
||||
body: CarBodyFormDto,
|
||||
|
||||
Reference in New Issue
Block a user