Fixed v6 statuses and steps

This commit is contained in:
SepehrYahyaee
2026-08-03 12:12:47 +03:30
parent 0b9bd59a66
commit c8ccd943f2

View File

@@ -272,6 +272,31 @@ export class RequestManagementService {
req: any,
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.
if (
req.type === BlameRequestType.CAR_BODY &&
@@ -326,9 +351,15 @@ export class RequestManagementService {
req.creationMethod === CreationMethod.IN_PERSON &&
(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 => {
if (
isInPersonThirdParty &&
(isInPersonThirdParty || isCallCenterThirdParty) &&
step === WorkflowStep.WAITING_FOR_GUILT_DECISION
) {
return WorkflowStep.WAITING_FOR_SIGNATURES;
@@ -1045,6 +1076,17 @@ export class RequestManagementService {
if (!completed.includes(step3Key)) {
completed.push(step3Key);
}
// V6 call-center initiated THIRD_PARTY: inquiry already done by agent — skip
// FIRST_INITIAL_FORM and go straight to FIRST_LOCATION.
if (req.callCenterInitiated && req.type === BlameRequestType.THIRD_PARTY) {
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;
} else {
req.workflow.completedSteps = completed;
const nextStepKey = step3.nextPossibleSteps?.[0] as
@@ -1065,6 +1107,7 @@ export class RequestManagementService {
req.workflow.currentStep = nextStepKey;
req.workflow.nextStep = afterNext as WorkflowStep;
}
// History
if (!Array.isArray(req.history)) req.history = [];
@@ -2139,6 +2182,19 @@ export class RequestManagementService {
req.type === BlameRequestType.THIRD_PARTY;
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.
if (isSecondThirdParty && req.blameStatus === BlameStatus.AGREED) {
const built = buildMutualAgreementExpertDecision(
@@ -10743,7 +10799,9 @@ export class RequestManagementService {
const firstParty = req.parties[firstIdx];
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 = [];
(req as any).history.push({
type: "CALL_CENTER_INQUIRY_COMPLETED",