1
0
forked from Yara724/api

add blame in claim details plus auto expert decision bug fixed

This commit is contained in:
2026-04-19 11:57:18 +03:30
parent c5b2d7b520
commit 08a4d754c1
5 changed files with 393 additions and 8 deletions

View File

@@ -75,6 +75,10 @@ import { CaseStatus } from "src/Types&Enums/blame-request-management/caseStatus.
import { UploadContext } from "./entities/schema/blame-voice.schema";
import { HashService } from "src/utils/hash/hash.service";
import { UserAuthService } from "src/auth/auth-services/user.auth.service";
import {
buildMutualAgreementExpertDecision,
MUTUAL_AGREEMENT_EXPERT_DECISION_FIELDS,
} from "src/helpers/blame-party-agreement-decision";
@Injectable()
export class RequestManagementService {
@@ -1157,6 +1161,22 @@ export class RequestManagementService {
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;
}
}
if (!Array.isArray(req.history)) req.history = [];
req.history.push({
type: `${stepKey}_SUBMITTED`,
@@ -4435,8 +4455,18 @@ export class RequestManagementService {
formData.guiltyPartyPhoneNumber === formData.firstPartyPhoneNumber
? String(firstPartyUserId)
: String(secondPartyUserId);
const damagedPhone =
formData.guiltyPartyPhoneNumber === formData.firstPartyPhoneNumber
? formData.secondParty.phoneNumber
: formData.firstPartyPhoneNumber;
if (!req.expert) req.expert = {} as any;
req.expert.decision = { guiltyPartyId: new Types.ObjectId(guiltyPartyId) } as any;
req.expert.decision = {
guiltyPartyId: new Types.ObjectId(guiltyPartyId),
description: `با توافق طرفین مقصر و زیان دیده مشخص شد. کاربر ${formData.guiltyPartyPhoneNumber} مقصر و کاربر ${damagedPhone} زیان دیده می باشد.`,
decidedAt: new Date(),
decidedByExpertId: new Types.ObjectId(expert.sub),
fields: { ...MUTUAL_AGREEMENT_EXPERT_DECISION_FIELDS },
} as any;
req.workflow = {
currentStep: WorkflowStep.FIRST_LOCATION as any,
nextStep: WorkflowStep.SECOND_LOCATION as any,