forked from Yara724/api
178 lines
4.7 KiB
TypeScript
178 lines
4.7 KiB
TypeScript
//! NEW
|
||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||
import { Schema as MongooseSchema, Types } from "mongoose";
|
||
import { Location, LocationSchema } from "./accidentInformation.type";
|
||
|
||
export enum PartyRole {
|
||
FIRST = "FIRST",
|
||
SECOND = "SECOND",
|
||
}
|
||
|
||
@Schema({ _id: false })
|
||
export class Person {
|
||
@Prop({ type: Types.ObjectId })
|
||
userId?: Types.ObjectId;
|
||
|
||
@Prop() fullName?: string;
|
||
@Prop() phoneNumber?: string;
|
||
@Prop({ type: Types.ObjectId }) clientId?: Types.ObjectId;
|
||
@Prop() birthday?: string;
|
||
|
||
// ---- FIRST_INITIAL_FORM (step-manager driven) ----
|
||
@Prop() nationalCodeOfInsurer?: string;
|
||
@Prop() nationalCodeOfDriver?: string;
|
||
@Prop() insurerLicense?: string;
|
||
@Prop() driverLicense?: string;
|
||
|
||
@Prop({ type: Boolean })
|
||
driverIsInsurer?: boolean;
|
||
|
||
@Prop({ type: Boolean })
|
||
isNewCar?: boolean;
|
||
|
||
/**
|
||
* Mirrors existing DTO `userNoCertificate` (true means user has NO certificate).
|
||
*/
|
||
@Prop({ type: Boolean })
|
||
userNoCertificate?: boolean;
|
||
|
||
@Prop({ type: Number })
|
||
insurerBirthday?: number;
|
||
|
||
@Prop({ type: String })
|
||
driverBirthday?: string | null;
|
||
}
|
||
export const PersonSchema = SchemaFactory.createForClass(Person);
|
||
|
||
@Schema({ _id: false })
|
||
export class Vehicle {
|
||
@Prop() plateId?: string;
|
||
@Prop() name?: string;
|
||
@Prop() model?: string;
|
||
@Prop() type?: string;
|
||
@Prop() isNew?: boolean;
|
||
|
||
/**
|
||
* Full external inquiry payload (Tejarat/SandHub) stored as-is
|
||
* so we never lose fields that are not mapped yet.
|
||
*/
|
||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||
inquiry?: any;
|
||
}
|
||
export const VehicleSchema = SchemaFactory.createForClass(Vehicle);
|
||
|
||
@Schema({ _id: false })
|
||
export class Insurance {
|
||
@Prop() policyNumber?: string;
|
||
@Prop() company?: string;
|
||
@Prop() startDate?: string;
|
||
@Prop() endDate?: string;
|
||
@Prop() financialCeiling?: string;
|
||
@Prop({ type: [String] })
|
||
coverages?: string[];
|
||
|
||
/** CAR_BODY only: mocked car-body insurance inquiry result */
|
||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||
carBodyInsurance?: {
|
||
policyNumber?: string;
|
||
startDate?: string;
|
||
endDate?: string;
|
||
insurerCompany?: string;
|
||
coverages?: string[];
|
||
};
|
||
}
|
||
export const InsuranceSchema = SchemaFactory.createForClass(Insurance);
|
||
|
||
@Schema({ _id: false })
|
||
export class PartyStatement {
|
||
|
||
@Prop({ default: false })
|
||
acceptsExpertOpinion?: boolean;
|
||
|
||
@Prop({ default: false })
|
||
claimsDamage?: boolean;
|
||
|
||
@Prop({ default: false })
|
||
admitsGuilt?: boolean;
|
||
|
||
@Prop({ type: String })
|
||
description?: string;
|
||
|
||
/** CAR_BODY: accident conditions from description step */
|
||
@Prop() accidentDate?: Date;
|
||
@Prop() accidentTime?: string;
|
||
@Prop() weatherCondition?: string;
|
||
@Prop() roadCondition?: string;
|
||
@Prop() lightCondition?: string;
|
||
}
|
||
export const PartyStatementSchema = SchemaFactory.createForClass(PartyStatement);
|
||
|
||
@Schema({ _id: false })
|
||
export class EvidenceBundle {
|
||
|
||
@Prop({ type: [String] })
|
||
images?: string[];
|
||
|
||
@Prop({ type: [String] })
|
||
voices?: string[];
|
||
|
||
@Prop() videoId?: string;
|
||
}
|
||
export const EvidenceBundleSchema = SchemaFactory.createForClass(EvidenceBundle);
|
||
|
||
@Schema({ _id: false })
|
||
export class Signature {
|
||
@Prop() fileId: string;
|
||
@Prop() fileName: string;
|
||
@Prop() fileUrl: string;
|
||
}
|
||
export const SignatureSchema = SchemaFactory.createForClass(Signature);
|
||
|
||
@Schema({ _id: false })
|
||
export class PartyConfirmation {
|
||
@Prop() partyRole: PartyRole;
|
||
@Prop() accepted: boolean;
|
||
@Prop({ type: SignatureSchema })
|
||
signature?: Signature;
|
||
}
|
||
export const PartyConfirmationSchema =
|
||
SchemaFactory.createForClass(PartyConfirmation);
|
||
|
||
@Schema({ _id: false })
|
||
export class Party {
|
||
|
||
@Prop({ enum: PartyRole })
|
||
role: PartyRole;
|
||
|
||
@Prop({ type: PersonSchema })
|
||
person: Person;
|
||
|
||
/**
|
||
* CAR_BODY only: first form – accident with car vs object.
|
||
* Second form (guilty/damaged) may be added later as carBodySecondForm.
|
||
*/
|
||
@Prop({ type: MongooseSchema.Types.Mixed })
|
||
carBodyFirstForm?: { car?: boolean; object?: boolean };
|
||
|
||
/**
|
||
* Party-submitted location (step-driven: FIRST_LOCATION / SECOND_LOCATION).
|
||
*/
|
||
@Prop({ type: LocationSchema })
|
||
location?: Location;
|
||
|
||
@Prop({ type: VehicleSchema })
|
||
vehicle?: Vehicle;
|
||
|
||
@Prop({ type: InsuranceSchema })
|
||
insurance?: Insurance;
|
||
|
||
@Prop({ type: PartyStatementSchema })
|
||
statement?: PartyStatement;
|
||
|
||
@Prop({ type: EvidenceBundleSchema })
|
||
evidence?: EvidenceBundle;
|
||
|
||
@Prop({ type: PartyConfirmationSchema })
|
||
confirmation?: PartyConfirmation;
|
||
}
|
||
export const PartySchema = SchemaFactory.createForClass(Party); |