1
0
forked from Yara724/api

daghi + expert and damage expert name in decision +

signature required added
This commit is contained in:
2026-04-20 18:19:25 +03:30
parent b63c2155bc
commit 41c44dcf23
13 changed files with 324 additions and 12 deletions

View File

@@ -0,0 +1,26 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
/**
* Immutable snapshot of the expert at reply time (field expert or damage expert).
* Stored on blame `expert.decision` and claim `evaluation.damageExpertReply*`.
*/
@Schema({ _id: false })
export class ExpertProfileSnapshot {
@Prop()
firstName?: string;
@Prop()
lastName?: string;
@Prop()
email?: string;
@Prop()
insuActivityCo?: string;
@Prop()
mobile?: string;
}
export const ExpertProfileSnapshotSchema =
SchemaFactory.createForClass(ExpertProfileSnapshot);

View File

@@ -1,6 +1,10 @@
//! NEW
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Types } from "mongoose";
import {
ExpertProfileSnapshot,
ExpertProfileSnapshotSchema,
} from "./expert-profile-snapshot.schema";
@Schema({ _id: false })
@@ -52,6 +56,10 @@ export class ExpertDecision {
accidentReason: { id: string; label: string; fanavaran: number };
accidentType: { id: string; label: string };
};
/** Field expert profile at decision time (from `expert` collection). */
@Prop({ type: ExpertProfileSnapshotSchema })
expertProfileSnapshot?: ExpertProfileSnapshot;
}
export const ExpertDecisionSchema = SchemaFactory.createForClass(ExpertDecision);
@@ -108,6 +116,10 @@ export class ExpertResend {
@Prop({ type: Types.ObjectId })
requestedByExpertId?: Types.ObjectId;
/** Field expert profile when resend was requested (`expert` collection). */
@Prop({ type: ExpertProfileSnapshotSchema })
expertProfileSnapshot?: ExpertProfileSnapshot;
/**
* @deprecated Unused for resend UI; clients use per-party requestedItems + inputKind.
*/

View File

@@ -249,6 +249,10 @@ export class SubmitReply {
@Prop()
systemResponse: string;
/** Field expert profile at reply time (`expert` collection). */
@Prop({ type: Object })
expertProfileSnapshot?: Record<string, string | undefined>;
}
export class ExpertResendParties {
@@ -271,6 +275,10 @@ export class ActorLockDetails {
@Prop({ type: Types.ObjectId })
actorId?: Types.ObjectId;
/** Field expert profile when lock was taken (`expert` collection). */
@Prop({ type: Object })
expertProfileSnapshot?: Record<string, string | undefined>;
}
export enum CreationMethod {
@@ -450,6 +458,14 @@ export class RequestManagementModel {
@Prop({ type: Boolean, default: false })
isHandledStatsUpdated?: boolean;
/** Latest field expert profile when expert requested party resend (V1 `sendAgainRequest`). */
@Prop({ type: Object })
expertResendByExpertProfileSnapshot?: Record<string, string | undefined>;
/** Field expert profile when expert marked in-person visit (V1 `inPersonVisit`). */
@Prop({ type: Object })
fieldExpertInPersonVisitProfileSnapshot?: Record<string, string | undefined>;
// Expert-initiated file tracking
@Prop({ type: Boolean, default: false })
expertInitiated?: boolean;

View File

@@ -2,6 +2,10 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Types } from "mongoose";
import { WorkflowStep } from "src/Types&Enums/blame-request-management/blameWorkflow-steps.enum";
import {
ExpertProfileSnapshot,
ExpertProfileSnapshotSchema,
} from "./expert-profile-snapshot.schema";
@Schema({ _id: false })
export class ActorLock {
@@ -13,6 +17,10 @@ export class ActorLock {
@Prop({ type: String, default: "expert" })
actorRole: "expert" | "admin";
/** Field expert profile when lock was taken (`expert` collection). */
@Prop({ type: ExpertProfileSnapshotSchema })
expertProfileSnapshot?: ExpertProfileSnapshot;
}
export const ActorLockSchema = SchemaFactory.createForClass(ActorLock);

View File

@@ -1173,13 +1173,14 @@ export class RequestManagementService {
? req.workflow.completedSteps
: [];
if (!completed.includes(stepKey)) completed.push(stepKey);
if (!completed.includes(WorkflowStep.COMPLETED as any)) {
completed.push(WorkflowStep.COMPLETED as any);
// Same as postfield-expert reply: guilt phase is satisfied without an expert; parties must still sign.
if (!completed.includes(WorkflowStep.WAITING_FOR_GUILT_DECISION)) {
completed.push(WorkflowStep.WAITING_FOR_GUILT_DECISION);
}
req.workflow.completedSteps = completed;
req.workflow.currentStep = WorkflowStep.COMPLETED;
req.workflow.currentStep = WorkflowStep.WAITING_FOR_SIGNATURES;
req.workflow.nextStep = undefined;
req.status = CaseStatus.COMPLETED;
req.status = CaseStatus.WAITING_FOR_SIGNATURES;
closedByMutualAgreement = true;
}
}
@@ -1219,7 +1220,11 @@ export class RequestManagementService {
metadata: {
role,
...(closedByMutualAgreement
? { mutualAgreementCaseComplete: true, closedWithoutExpert: true }
? {
mutualAgreementWithoutExpert: true,
closedWithoutExpert: true,
awaitingSignatures: true,
}
: {}),
},
} as any);