1
0
forked from Yara724/api

blame and claim refactored

This commit is contained in:
2026-02-24 12:19:25 +03:30
parent 0d8858f458
commit 35732dd70a
81 changed files with 11603 additions and 77 deletions

View File

@@ -0,0 +1,202 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Schema as MongooseSchema, Types } from "mongoose";
import { FactorStatus } from "src/Types&Enums/claim-request-management/factor-status.enum";
import { UserReplyEnum } from "src/Types&Enums/claim-request-management/userReply.enum";
@Schema({ _id: false })
export class ClaimPartPricing {
@Prop({ type: String })
partId: string;
@Prop({ type: String })
carPartDamage?: string;
@Prop({ type: String })
typeOfDamage?: string;
@Prop({ type: MongooseSchema.Types.Mixed })
price?: string | number;
@Prop({ type: MongooseSchema.Types.Mixed })
salary?: string | number;
@Prop({ type: MongooseSchema.Types.Mixed })
totalPayment?: string | number;
@Prop({ type: MongooseSchema.Types.Mixed })
daghi?: string | number;
@Prop({ type: Boolean, default: false })
factorNeeded?: boolean;
@Prop({ type: Types.ObjectId })
factorLink?: Types.ObjectId;
@Prop({ type: String, enum: FactorStatus, default: null })
factorStatus?: FactorStatus | null;
@Prop({ type: String, default: null })
rejectionReason?: string | null;
}
export const ClaimPartPricingSchema =
SchemaFactory.createForClass(ClaimPartPricing);
@Schema({ _id: false })
export class ClaimExpertActor {
@Prop({ type: String })
actorName?: string;
/**
* Kept as string to support existing queries like:
* `"damageExpertReply.actorDetail.actorId": actor.sub`
*/
@Prop({ type: String })
actorId?: string;
}
export const ClaimExpertActorSchema =
SchemaFactory.createForClass(ClaimExpertActor);
@Schema({ _id: false })
export class ClaimUserComment {
@Prop({ type: Boolean, default: null })
isAccept?: boolean | null;
@Prop({ type: Types.ObjectId })
signDetailId?: Types.ObjectId;
}
export const ClaimUserCommentSchema =
SchemaFactory.createForClass(ClaimUserComment);
@Schema({ _id: false })
export class ClaimExpertReply {
@Prop({ type: String })
description?: string;
@Prop({ type: ClaimExpertActorSchema })
actorDetail?: ClaimExpertActor;
@Prop({ type: [ClaimPartPricingSchema], default: [] })
parts?: ClaimPartPricing[];
@Prop({ type: Date, default: () => new Date() })
submittedAt?: Date;
@Prop({ type: ClaimUserCommentSchema })
userComment?: ClaimUserComment;
}
export const ClaimExpertReplySchema =
SchemaFactory.createForClass(ClaimExpertReply);
@Schema({ _id: false })
export class ClaimUserObjection {
@Prop({ type: String, required: true })
partId: string;
@Prop({ type: String })
reason?: string;
@Prop({ type: String })
partPrice?: string;
@Prop({ type: String })
partSalary?: string;
@Prop({ type: String })
typeOfDamage?: string;
}
export const ClaimUserObjectionSchema =
SchemaFactory.createForClass(ClaimUserObjection);
@Schema({ _id: false })
export class ClaimResendRequest {
@Prop({ type: String })
resendDescription?: string;
@Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
resendDocuments?: any[];
@Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
resendCarParts?: any[];
}
export const ClaimResendRequestSchema =
SchemaFactory.createForClass(ClaimResendRequest);
@Schema({ _id: false })
export class ClaimUserResendPayload {
@Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
documents?: any[];
@Prop({ type: [MongooseSchema.Types.Mixed], default: [] })
carParts?: any[];
}
export const ClaimUserResendPayloadSchema =
SchemaFactory.createForClass(ClaimUserResendPayload);
@Schema({ _id: false })
export class ClaimFileRating {
@Prop({ type: Number, min: 0, max: 5 })
collisionMethodAccuracy?: number;
@Prop({ type: Number, min: 0, max: 5 })
evaluationTimeliness?: number;
@Prop({ type: Number, min: 0, max: 5 })
accidentCauseAccuracy?: number;
@Prop({ type: Number, min: 0, max: 5 })
guiltyVehicleIdentification?: number;
}
export const ClaimFileRatingSchema =
SchemaFactory.createForClass(ClaimFileRating);
@Schema({ _id: false })
export class ClaimPriceDrop {
@Prop({ type: Number })
total?: number;
@Prop({ type: Number })
carPrice?: number;
@Prop({ type: Number })
carModel?: number;
@Prop({ type: [Number], default: [] })
carValue?: number[];
@Prop({ type: Number })
sumOfSeverity?: number;
}
export const ClaimPriceDropSchema = SchemaFactory.createForClass(ClaimPriceDrop);
@Schema({ _id: false })
export class ClaimEvaluation {
@Prop({ type: String, enum: UserReplyEnum, default: null })
effectedUserReply?: UserReplyEnum | null;
@Prop({ type: ClaimExpertReplySchema })
damageExpertReply?: ClaimExpertReply | null;
@Prop({ type: ClaimExpertReplySchema })
damageExpertReplyFinal?: ClaimExpertReply | null;
@Prop({ type: ClaimResendRequestSchema })
damageExpertResend?: ClaimResendRequest | null;
@Prop({ type: ClaimUserObjectionSchema })
objection?: ClaimUserObjection;
@Prop({ type: ClaimUserResendPayloadSchema })
userResendDocuments?: ClaimUserResendPayload;
@Prop({ type: ClaimFileRatingSchema })
rating?: ClaimFileRating;
@Prop({ type: String })
visitLocation?: string;
@Prop({ type: ClaimPriceDropSchema })
priceDrop?: ClaimPriceDrop;
}
export const ClaimEvaluationSchema =
SchemaFactory.createForClass(ClaimEvaluation);