forked from Yara724/api
242 lines
6.2 KiB
TypeScript
242 lines
6.2 KiB
TypeScript
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);
|
|
|
|
/** One line item the user disputes on an expert-priced part */
|
|
@Schema({ _id: false })
|
|
export class ClaimUserObjectionPart {
|
|
@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;
|
|
|
|
@Prop({ type: String })
|
|
carPartDamage?: string;
|
|
|
|
@Prop({ type: String })
|
|
side?: string;
|
|
}
|
|
export const ClaimUserObjectionPartSchema =
|
|
SchemaFactory.createForClass(ClaimUserObjectionPart);
|
|
|
|
@Schema({ _id: false })
|
|
export class ClaimUserObjectionNewPart {
|
|
@Prop({ type: String })
|
|
partId?: string;
|
|
|
|
@Prop({ type: String, required: true })
|
|
partName: string;
|
|
|
|
@Prop({ type: String })
|
|
side?: string;
|
|
}
|
|
export const ClaimUserObjectionNewPartSchema =
|
|
SchemaFactory.createForClass(ClaimUserObjectionNewPart);
|
|
|
|
/**
|
|
* Full user objection payload (matches v1 DTO: objectionParts + newParts).
|
|
* Stored on {@link ClaimEvaluation.objection}.
|
|
*/
|
|
@Schema({ _id: false })
|
|
export class ClaimUserObjectionPayload {
|
|
@Prop({ type: [ClaimUserObjectionPartSchema], default: [] })
|
|
objectionParts?: ClaimUserObjectionPart[];
|
|
|
|
@Prop({ type: [ClaimUserObjectionNewPartSchema], default: [] })
|
|
newParts?: ClaimUserObjectionNewPart[];
|
|
|
|
@Prop({ type: Date, default: () => new Date() })
|
|
submittedAt?: Date;
|
|
}
|
|
export const ClaimUserObjectionPayloadSchema =
|
|
SchemaFactory.createForClass(ClaimUserObjectionPayload);
|
|
|
|
@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: ClaimUserObjectionPayloadSchema })
|
|
objection?: ClaimUserObjectionPayload;
|
|
|
|
@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);
|
|
|