Merge pull request 'Fix v2 flow sign of second party' (#206) from s.yahyaee/yara724-api:main into main

Reviewed-on: Yara724/api#206
This commit is contained in:
2026-07-22 15:35:53 +03:30

View File

@@ -2119,7 +2119,7 @@ export class RequestManagementService {
}
req.workflow.completedSteps = completed;
req.workflow.currentStep = WorkflowStep.WAITING_FOR_SIGNATURES;
req.workflow.nextStep = undefined;
req.workflow.nextStep = WorkflowStep.WAITING_FOR_SIGNATURES;
req.status = CaseStatus.WAITING_FOR_SIGNATURES;
closedByMutualAgreement = true;
@@ -2205,7 +2205,7 @@ export class RequestManagementService {
}
req.workflow.completedSteps = completed;
req.workflow.currentStep = WorkflowStep.WAITING_FOR_SIGNATURES;
req.workflow.nextStep = undefined;
req.workflow.nextStep = WorkflowStep.WAITING_FOR_SIGNATURES;
req.status = CaseStatus.WAITING_FOR_SIGNATURES;
} else if (!closedByMutualAgreement) {
if (stepKey === WorkflowStep.SECOND_DESCRIPTION) {
@@ -6796,17 +6796,16 @@ 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.
// In the V2 IN_PERSON mirror flow guilt is resolved automatically after both
// parties complete their narrative steps (addDescriptionV2). The sign step for
// both parties must happen BEFORE accident-fields is called — calling it earlier
// would overwrite the workflow and cause the frontend to skip the sign page.
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.`,
`accident-fields can only be submitted after both parties have signed (current status: ${req.status}). Complete both signatures first.`,
);
}
@@ -6837,9 +6836,14 @@ export class RequestManagementService {
},
};
// For IN_PERSON expert files: after accident fields are filled, guilt is
// decided and we can go straight to signatures (no separate review needed).
if (req.creationMethod === CreationMethod.IN_PERSON) {
// For IN_PERSON expert files that have not yet reached COMPLETED: after accident
// fields are filled, guilt is decided and we can go straight to signatures.
// When the file is already COMPLETED (both parties signed) we only save the
// supplemental fields without touching the workflow or status.
if (
req.creationMethod === CreationMethod.IN_PERSON &&
req.status !== CaseStatus.COMPLETED
) {
const completed = Array.isArray(req.workflow?.completedSteps)
? req.workflow.completedSteps
: [];