All files / performance/schemas idp-pip-recognition.schema.ts

100% Statements 47/47
78.75% Branches 63/80
100% Functions 0/0
100% Lines 37/37

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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 1141x 1x     1x   1x     1x     1x                     1x   1x     1x   1x     1x     1x     1x   1x     1x   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: 'performance_idps' })
export class PerformanceIndividualDevelopmentPlan extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  employeeId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  mentorId: MongooseSchema.Types.ObjectId;
 
  @Prop({
    type: [{
      objective: { type: String, required: true },
      actionItem: { type: String, required: true },
      targetCompletionDate: { type: Date, required: true },
      status: { type: String, enum: ['planned', 'in_progress', 'completed'], default: 'planned' }
    }],
    default: []
  })
  goals: Array<{ objective: string; actionItem: string; targetCompletionDate: Date; status: string }>;
}
export const PerformanceIndividualDevelopmentPlanSchema = SchemaFactory.createForClass(PerformanceIndividualDevelopmentPlan);
 
@Schema({ timestamps: true, collection: 'performance_training_requests' })
export class PerformanceTrainingRequest extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  employeeId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  topicName: string;
 
  @Prop({ required: true, enum: ['pending', 'approved', 'rejected'], default: 'pending' })
  status: string;
}
export const PerformanceTrainingRequestSchema = SchemaFactory.createForClass(PerformanceTrainingRequest);
 
@Schema({ timestamps: true, collection: 'performance_certifications' })
export class PerformanceCertificationTracker extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  employeeId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  certificationName: string;
 
  @Prop({ required: true })
  authority: string;
 
  @Prop({ required: true })
  expiryDate: Date;
}
export const PerformanceCertificationTrackerSchema = SchemaFactory.createForClass(PerformanceCertificationTracker);
 
@Schema({ timestamps: true, collection: 'performance_pips' })
export class PerformanceImprovementPlan extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  employeeId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  managerId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  startDate: Date;
 
  @Prop({ required: true })
  endDate: Date;
 
  @Prop({
    type: [{
      objective: { type: String, required: true },
      successCriteria: { type: String, required: true },
      progressComment: { type: String },
      isMet: { type: Boolean, default: false }
    }],
    default: []
  })
  objectives: Array<{ objective: string; successCriteria: string; progressComment?: string; isMet: boolean }>;
 
  @Prop({ required: true, enum: ['active', 'extended', 'successful_exit', 'unsuccessful_termination'], default: 'active' })
  status: string;
}
export const PerformanceImprovementPlanSchema = SchemaFactory.createForClass(PerformanceImprovementPlan);
 
@Schema({ timestamps: true, collection: 'performance_recognitions' })
export class PerformanceAward extends Document {
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
  employeeId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  awardName: string; // e.g. "Outstanding Contributor"
 
  @Prop({ required: true })
  badgeUrl: string;
 
  @Prop({ required: true, type: Number, default: 100 })
  points: number;
}
export const PerformanceAwardSchema = SchemaFactory.createForClass(PerformanceAward);