forked from Yara724/api
Merge pull request 'blame status agreement fixed' (#30) from s.hajizadeh/yara724api:main into main
Reviewed-on: Yara724/api#30
This commit is contained in:
@@ -1154,18 +1154,13 @@ export class RequestManagementService {
|
||||
(party.statement as any).lightCondition = body.lightCondition;
|
||||
}
|
||||
|
||||
// If second party finished description, we’re ready for expert flow.
|
||||
if (stepKey === WorkflowStep.SECOND_DESCRIPTION) {
|
||||
req.status = CaseStatus.WAITING_FOR_EXPERT;
|
||||
}
|
||||
|
||||
await this.advanceWorkflowToNext(req, stepKey);
|
||||
|
||||
if (
|
||||
const isSecondThirdParty =
|
||||
stepKey === WorkflowStep.SECOND_DESCRIPTION &&
|
||||
req.type === BlameRequestType.THIRD_PARTY &&
|
||||
!(req as any).expert?.decision?.guiltyPartyId
|
||||
) {
|
||||
req.type === BlameRequestType.THIRD_PARTY;
|
||||
let closedByMutualAgreement = false;
|
||||
|
||||
// THIRD_PARTY + AGREED: guilt/damage already implied by first-party confession — no field expert needed.
|
||||
if (isSecondThirdParty && req.blameStatus === BlameStatus.AGREED) {
|
||||
const built = buildMutualAgreementExpertDecision(
|
||||
(req as any).toObject
|
||||
? (req as any).toObject()
|
||||
@@ -1174,6 +1169,40 @@ export class RequestManagementService {
|
||||
if (built) {
|
||||
if (!(req as any).expert) (req as any).expert = {};
|
||||
(req as any).expert.decision = built as any;
|
||||
const completed = Array.isArray(req.workflow.completedSteps)
|
||||
? req.workflow.completedSteps
|
||||
: [];
|
||||
if (!completed.includes(stepKey)) completed.push(stepKey);
|
||||
if (!completed.includes(WorkflowStep.COMPLETED as any)) {
|
||||
completed.push(WorkflowStep.COMPLETED as any);
|
||||
}
|
||||
req.workflow.completedSteps = completed;
|
||||
req.workflow.currentStep = WorkflowStep.COMPLETED;
|
||||
req.workflow.nextStep = undefined;
|
||||
req.status = CaseStatus.COMPLETED;
|
||||
closedByMutualAgreement = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!closedByMutualAgreement) {
|
||||
if (stepKey === WorkflowStep.SECOND_DESCRIPTION) {
|
||||
req.status = CaseStatus.WAITING_FOR_EXPERT;
|
||||
}
|
||||
await this.advanceWorkflowToNext(req, stepKey);
|
||||
if (
|
||||
stepKey === WorkflowStep.SECOND_DESCRIPTION &&
|
||||
req.type === BlameRequestType.THIRD_PARTY &&
|
||||
!(req as any).expert?.decision?.guiltyPartyId
|
||||
) {
|
||||
const built = buildMutualAgreementExpertDecision(
|
||||
(req as any).toObject
|
||||
? (req as any).toObject()
|
||||
: { ...req },
|
||||
);
|
||||
if (built) {
|
||||
if (!(req as any).expert) (req as any).expert = {};
|
||||
(req as any).expert.decision = built as any;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1187,7 +1216,12 @@ export class RequestManagementService {
|
||||
actorName: user?.fullName,
|
||||
actorType: "user",
|
||||
},
|
||||
metadata: { role },
|
||||
metadata: {
|
||||
role,
|
||||
...(closedByMutualAgreement
|
||||
? { mutualAgreementCaseComplete: true, closedWithoutExpert: true }
|
||||
: {}),
|
||||
},
|
||||
} as any);
|
||||
|
||||
await (req as any).save();
|
||||
|
||||
Reference in New Issue
Block a user