forked from Yara724/api
Merge pull request 'Fixed v6 statuses and steps' (#244) from s.yahyaee/yara724-api:main into main
Reviewed-on: Yara724/api#244
This commit is contained in:
@@ -272,6 +272,31 @@ export class RequestManagementService {
|
|||||||
req: any,
|
req: any,
|
||||||
submittedStepKey: WorkflowStep,
|
submittedStepKey: WorkflowStep,
|
||||||
) {
|
) {
|
||||||
|
// V6 call-center initiated THIRD_PARTY: skip FIRST_INITIAL_FORM because the
|
||||||
|
// call-center agent already ran the inquiry during run-inquiry.
|
||||||
|
// After FIRST_VIDEO, jump straight to FIRST_LOCATION.
|
||||||
|
if (
|
||||||
|
req.callCenterInitiated &&
|
||||||
|
req.type === BlameRequestType.THIRD_PARTY &&
|
||||||
|
submittedStepKey === WorkflowStep.FIRST_VIDEO
|
||||||
|
) {
|
||||||
|
const completed = Array.isArray(req.workflow.completedSteps)
|
||||||
|
? req.workflow.completedSteps
|
||||||
|
: [];
|
||||||
|
if (!completed.includes(submittedStepKey)) completed.push(submittedStepKey);
|
||||||
|
// Also mark FIRST_INITIAL_FORM as completed so the step chain is consistent
|
||||||
|
if (!completed.includes(WorkflowStep.FIRST_INITIAL_FORM)) {
|
||||||
|
completed.push(WorkflowStep.FIRST_INITIAL_FORM);
|
||||||
|
}
|
||||||
|
req.workflow.completedSteps = completed;
|
||||||
|
req.workflow.currentStep = WorkflowStep.FIRST_LOCATION;
|
||||||
|
req.workflow.nextStep = WorkflowStep.FIRST_VOICE;
|
||||||
|
this.logger.debug(
|
||||||
|
"[WORKFLOW] V6 call-center: skipped FIRST_INITIAL_FORM after FIRST_VIDEO, advanced to FIRST_LOCATION",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// CAR_BODY: after first-party description, move to signature step.
|
// CAR_BODY: after first-party description, move to signature step.
|
||||||
if (
|
if (
|
||||||
req.type === BlameRequestType.CAR_BODY &&
|
req.type === BlameRequestType.CAR_BODY &&
|
||||||
@@ -326,9 +351,15 @@ export class RequestManagementService {
|
|||||||
req.creationMethod === CreationMethod.IN_PERSON &&
|
req.creationMethod === CreationMethod.IN_PERSON &&
|
||||||
(req.expertInitiated || req.registrarInitiated);
|
(req.expertInitiated || req.registrarInitiated);
|
||||||
|
|
||||||
|
// V6 call-center THIRD_PARTY: guilt is pre-decided (first party is always guilty),
|
||||||
|
// so skip the WAITING_FOR_GUILT_DECISION waiting state just like IN_PERSON.
|
||||||
|
const isCallCenterThirdParty =
|
||||||
|
req.type === BlameRequestType.THIRD_PARTY &&
|
||||||
|
!!req.callCenterInitiated;
|
||||||
|
|
||||||
const resolveStep = (step: WorkflowStep | undefined): WorkflowStep | undefined => {
|
const resolveStep = (step: WorkflowStep | undefined): WorkflowStep | undefined => {
|
||||||
if (
|
if (
|
||||||
isInPersonThirdParty &&
|
(isInPersonThirdParty || isCallCenterThirdParty) &&
|
||||||
step === WorkflowStep.WAITING_FOR_GUILT_DECISION
|
step === WorkflowStep.WAITING_FOR_GUILT_DECISION
|
||||||
) {
|
) {
|
||||||
return WorkflowStep.WAITING_FOR_SIGNATURES;
|
return WorkflowStep.WAITING_FOR_SIGNATURES;
|
||||||
@@ -1045,26 +1076,38 @@ export class RequestManagementService {
|
|||||||
if (!completed.includes(step3Key)) {
|
if (!completed.includes(step3Key)) {
|
||||||
completed.push(step3Key);
|
completed.push(step3Key);
|
||||||
}
|
}
|
||||||
req.workflow.completedSteps = completed;
|
|
||||||
|
|
||||||
const nextStepKey = step3.nextPossibleSteps?.[0] as
|
// V6 call-center initiated THIRD_PARTY: inquiry already done by agent — skip
|
||||||
| WorkflowStep
|
// FIRST_INITIAL_FORM and go straight to FIRST_LOCATION.
|
||||||
| undefined;
|
if (req.callCenterInitiated && req.type === BlameRequestType.THIRD_PARTY) {
|
||||||
if (!nextStepKey) {
|
if (!completed.includes(WorkflowStep.FIRST_INITIAL_FORM)) {
|
||||||
throw new InternalServerErrorException(
|
completed.push(WorkflowStep.FIRST_INITIAL_FORM);
|
||||||
"Workflow stepNumber=3 has no nextPossibleSteps configured",
|
}
|
||||||
);
|
req.workflow.completedSteps = completed;
|
||||||
}
|
req.workflow.currentStep = WorkflowStep.FIRST_LOCATION;
|
||||||
const nextStepDoc = await this.getWorkflowStep({ stepKey: nextStepKey });
|
req.workflow.nextStep = WorkflowStep.FIRST_VOICE;
|
||||||
const afterNext = nextStepDoc.nextPossibleSteps?.[0];
|
} else {
|
||||||
if (!afterNext) {
|
req.workflow.completedSteps = completed;
|
||||||
throw new InternalServerErrorException(
|
|
||||||
`Workflow step ${nextStepKey} has no nextPossibleSteps configured`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
req.workflow.currentStep = nextStepKey;
|
const nextStepKey = step3.nextPossibleSteps?.[0] as
|
||||||
req.workflow.nextStep = afterNext as WorkflowStep;
|
| WorkflowStep
|
||||||
|
| undefined;
|
||||||
|
if (!nextStepKey) {
|
||||||
|
throw new InternalServerErrorException(
|
||||||
|
"Workflow stepNumber=3 has no nextPossibleSteps configured",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const nextStepDoc = await this.getWorkflowStep({ stepKey: nextStepKey });
|
||||||
|
const afterNext = nextStepDoc.nextPossibleSteps?.[0];
|
||||||
|
if (!afterNext) {
|
||||||
|
throw new InternalServerErrorException(
|
||||||
|
`Workflow step ${nextStepKey} has no nextPossibleSteps configured`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
req.workflow.currentStep = nextStepKey;
|
||||||
|
req.workflow.nextStep = afterNext as WorkflowStep;
|
||||||
|
}
|
||||||
|
|
||||||
// History
|
// History
|
||||||
if (!Array.isArray(req.history)) req.history = [];
|
if (!Array.isArray(req.history)) req.history = [];
|
||||||
@@ -2147,6 +2190,19 @@ export class RequestManagementService {
|
|||||||
req.type === BlameRequestType.THIRD_PARTY;
|
req.type === BlameRequestType.THIRD_PARTY;
|
||||||
let closedByMutualAgreement = false;
|
let closedByMutualAgreement = false;
|
||||||
|
|
||||||
|
// V6 call-center initiated THIRD_PARTY: first party is always the guilty party.
|
||||||
|
// If blameStatus is still UNKNOWN here (pre-fix file or race condition), force it to AGREED now.
|
||||||
|
if (isSecondThirdParty && req.callCenterInitiated && req.blameStatus !== BlameStatus.AGREED) {
|
||||||
|
const firstIdx = this.getPartyIndex(req, PartyRole.FIRST);
|
||||||
|
if (firstIdx !== -1) {
|
||||||
|
if (!req.parties[firstIdx].statement) req.parties[firstIdx].statement = {} as any;
|
||||||
|
req.parties[firstIdx].statement.admitsGuilt = true;
|
||||||
|
req.parties[firstIdx].statement.claimsDamage = false;
|
||||||
|
req.parties[firstIdx].statement.acceptsExpertOpinion = false;
|
||||||
|
}
|
||||||
|
req.blameStatus = BlameStatus.AGREED;
|
||||||
|
}
|
||||||
|
|
||||||
// THIRD_PARTY + AGREED: guilt/damage already implied by first-party confession — no field expert needed.
|
// THIRD_PARTY + AGREED: guilt/damage already implied by first-party confession — no field expert needed.
|
||||||
if (isSecondThirdParty && req.blameStatus === BlameStatus.AGREED) {
|
if (isSecondThirdParty && req.blameStatus === BlameStatus.AGREED) {
|
||||||
const built = buildMutualAgreementExpertDecision(
|
const built = buildMutualAgreementExpertDecision(
|
||||||
@@ -10759,7 +10815,9 @@ export class RequestManagementService {
|
|||||||
const firstParty = req.parties[firstIdx];
|
const firstParty = req.parties[firstIdx];
|
||||||
|
|
||||||
await this.runPartyInquiriesV3Internal(req, dto, PartyRole.FIRST, firstParty);
|
await this.runPartyInquiriesV3Internal(req, dto, PartyRole.FIRST, firstParty);
|
||||||
this.markPartyInquiriesCompleteOnBlame(req, PartyRole.FIRST, agent);
|
// Do NOT call markPartyInquiriesCompleteOnBlame here: that helper is for V3/V4/V5
|
||||||
|
// FileMaker flows and would advance the workflow to FIRST_LOCATION prematurely.
|
||||||
|
// In V6 the workflow must stay at CREATED until send-link advances it to FIRST_VIDEO.
|
||||||
if (!Array.isArray((req as any).history)) (req as any).history = [];
|
if (!Array.isArray((req as any).history)) (req as any).history = [];
|
||||||
(req as any).history.push({
|
(req as any).history.push({
|
||||||
type: "CALL_CENTER_INQUIRY_COMPLETED",
|
type: "CALL_CENTER_INQUIRY_COMPLETED",
|
||||||
|
|||||||
Reference in New Issue
Block a user