All files / logistics/schemas vehicle-driver.schema.ts

100% Statements 27/27
79.16% Branches 19/24
100% Functions 0/0
100% Lines 23/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 601x 1x     1x   1x     1x     1x     1x     1x     1x     1x     1x     1x     1x 1x     1x   1x     1x     1x     1x     1x     1x     1x 1x  
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'logistics_vehicles' })
export class LogisticsVehicleProfile extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  assetVehicleId: MongooseSchema.Types.ObjectId; // References Assets registry
 
  @Prop({ required: true })
  registrationNumber: string;
 
  @Prop({ required: true })
  vehicleType: string; // 'Bike' | 'Car' | 'Van' | 'Truck' | 'Refrigerated'
 
  @Prop({ required: true })
  loadCapacityWeightKg: number;
 
  @Prop({ required: true })
  loadCapacityVolumeM3: number;
 
  @Prop({ default: true })
  isAvailable: boolean;
 
  @Prop({ default: true })
  hasValidPermit: boolean;
 
  @Prop({ default: true })
  hasValidInsurance: boolean;
}
 
export const LogisticsVehicleProfileSchema = SchemaFactory.createForClass(LogisticsVehicleProfile);
LogisticsVehicleProfileSchema.index({ tenantId: 1, registrationNumber: 1 }, { unique: true });
 
@Schema({ timestamps: true, collection: 'logistics_drivers' })
export class DriverProfile extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  employeeId: MongooseSchema.Types.ObjectId; // References HR Employee registry
 
  @Prop({ required: true })
  licenseNumber: string;
 
  @Prop({ required: true })
  licenseExpiry: Date;
 
  @Prop({ default: true })
  isAvailable: boolean;
 
  @Prop({ default: 'active' })
  status: string; // 'active' | 'suspended'
}
 
export const DriverProfileSchema = SchemaFactory.createForClass(DriverProfile);
DriverProfileSchema.index({ tenantId: 1, licenseNumber: 1 }, { unique: true });