forked from Yara724/api
Fixed v2 flow
This commit is contained in:
@@ -34,6 +34,7 @@ import {
|
|||||||
LocationDto,
|
LocationDto,
|
||||||
} from "./dto/create-request-management.dto";
|
} from "./dto/create-request-management.dto";
|
||||||
import { CreateExpertInitiatedFileDto } from "./dto/expert-initiated.dto";
|
import { CreateExpertInitiatedFileDto } from "./dto/expert-initiated.dto";
|
||||||
|
import { CreationMethod } from "./entities/schema/request-management.schema";
|
||||||
import { SendPartyOtpsDto } from "./dto/send-party-otps.dto";
|
import { SendPartyOtpsDto } from "./dto/send-party-otps.dto";
|
||||||
import { VerifyPartyOtpsDto } from "./dto/verify-party-otps.dto";
|
import { VerifyPartyOtpsDto } from "./dto/verify-party-otps.dto";
|
||||||
import { SendPartyOtpDto, VerifyPartyOtpDto } from "./dto/party-otp.dto";
|
import { SendPartyOtpDto, VerifyPartyOtpDto } from "./dto/party-otp.dto";
|
||||||
@@ -75,17 +76,17 @@ export class ExpertInitiatedBlameMirrorController {
|
|||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: "[Expert mirror] Create expert-initiated blame file",
|
summary: "[Expert mirror] Create expert-initiated blame file",
|
||||||
description:
|
description:
|
||||||
"Use creationMethod=IN_PERSON for the on-site flow. Creates a BlameRequest owned by the parties but filled by the expert.",
|
"Creates an IN_PERSON blame file filled by the expert on behalf of both parties. creationMethod is always forced to IN_PERSON regardless of what is sent.",
|
||||||
})
|
})
|
||||||
@ApiBody({ type: CreateExpertInitiatedFileDto })
|
@ApiBody({ type: CreateExpertInitiatedFileDto })
|
||||||
async create(
|
async create(
|
||||||
@CurrentUser() expert: any,
|
@CurrentUser() expert: any,
|
||||||
@Body() dto: CreateExpertInitiatedFileDto,
|
@Body() dto: CreateExpertInitiatedFileDto,
|
||||||
) {
|
) {
|
||||||
return this.requestManagementService.createExpertInitiatedBlameV2(
|
return this.requestManagementService.createExpertInitiatedBlameV2(expert, {
|
||||||
expert,
|
...dto,
|
||||||
dto,
|
creationMethod: CreationMethod.IN_PERSON,
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post("send-link/:requestId")
|
@Post("send-link/:requestId")
|
||||||
|
|||||||
@@ -6637,11 +6637,11 @@ export class RequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.verifyExpertAccessForBlameV2(req, expert);
|
await this.verifyExpertAccessForBlameV2(req, expert);
|
||||||
// if (req.status !== CaseStatus.WAITING_FOR_SIGNATURES) {
|
if (req.status !== CaseStatus.WAITING_FOR_SIGNATURES) {
|
||||||
// throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
// "Request is not waiting for signatures. Current status: " + req.status,
|
"Request is not waiting for signatures. Current status: " + req.status,
|
||||||
// );
|
);
|
||||||
// }
|
}
|
||||||
const partyIndex = this.getPartyIndex(req, partyRole);
|
const partyIndex = this.getPartyIndex(req, partyRole);
|
||||||
if (partyIndex === -1) {
|
if (partyIndex === -1) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
@@ -6753,6 +6753,19 @@ export class RequestManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
await this.verifyExpertAccessForBlameV2(req, expert);
|
await this.verifyExpertAccessForBlameV2(req, expert);
|
||||||
|
// In the V2 IN_PERSON mirror flow guilt is resolved automatically during
|
||||||
|
// addDescriptionV2 — accident-fields must only be called once the file has
|
||||||
|
// reached WAITING_FOR_SIGNATURES (both parties' narrative steps are done).
|
||||||
|
// Calling it earlier would overwrite the workflow and skip the sign step.
|
||||||
|
if (
|
||||||
|
req.creationMethod === CreationMethod.IN_PERSON &&
|
||||||
|
req.status !== CaseStatus.WAITING_FOR_SIGNATURES &&
|
||||||
|
req.status !== CaseStatus.COMPLETED
|
||||||
|
) {
|
||||||
|
throw new BadRequestException(
|
||||||
|
`accident-fields can only be submitted after both parties have completed their narrative steps (current status: ${req.status}). Make sure both parties have gone through location, voice, and description before calling this endpoint.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!req.expert) req.expert = {} as any;
|
if (!req.expert) req.expert = {} as any;
|
||||||
if (!req.expert.decision) req.expert.decision = {} as any;
|
if (!req.expert.decision) req.expert.decision = {} as any;
|
||||||
|
|||||||
Reference in New Issue
Block a user