forked from Yara724/api
Merge pull request 'Fixed v2 flow' (#204) from s.yahyaee/yara724-api:main into main
Reviewed-on: Yara724/api#204
This commit is contained in:
@@ -34,6 +34,7 @@ import {
|
||||
LocationDto,
|
||||
} from "./dto/create-request-management.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 { VerifyPartyOtpsDto } from "./dto/verify-party-otps.dto";
|
||||
import { SendPartyOtpDto, VerifyPartyOtpDto } from "./dto/party-otp.dto";
|
||||
@@ -75,17 +76,17 @@ export class ExpertInitiatedBlameMirrorController {
|
||||
@ApiOperation({
|
||||
summary: "[Expert mirror] Create expert-initiated blame file",
|
||||
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 })
|
||||
async create(
|
||||
@CurrentUser() expert: any,
|
||||
@Body() dto: CreateExpertInitiatedFileDto,
|
||||
) {
|
||||
return this.requestManagementService.createExpertInitiatedBlameV2(
|
||||
expert,
|
||||
dto,
|
||||
);
|
||||
return this.requestManagementService.createExpertInitiatedBlameV2(expert, {
|
||||
...dto,
|
||||
creationMethod: CreationMethod.IN_PERSON,
|
||||
});
|
||||
}
|
||||
|
||||
@Post("send-link/:requestId")
|
||||
|
||||
@@ -6637,11 +6637,11 @@ export class RequestManagementService {
|
||||
);
|
||||
}
|
||||
await this.verifyExpertAccessForBlameV2(req, expert);
|
||||
// if (req.status !== CaseStatus.WAITING_FOR_SIGNATURES) {
|
||||
// throw new BadRequestException(
|
||||
// "Request is not waiting for signatures. Current status: " + req.status,
|
||||
// );
|
||||
// }
|
||||
if (req.status !== CaseStatus.WAITING_FOR_SIGNATURES) {
|
||||
throw new BadRequestException(
|
||||
"Request is not waiting for signatures. Current status: " + req.status,
|
||||
);
|
||||
}
|
||||
const partyIndex = this.getPartyIndex(req, partyRole);
|
||||
if (partyIndex === -1) {
|
||||
throw new BadRequestException(
|
||||
@@ -6753,6 +6753,19 @@ export class RequestManagementService {
|
||||
);
|
||||
}
|
||||
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.decision) req.expert.decision = {} as any;
|
||||
|
||||
Reference in New Issue
Block a user