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 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ collection: 'employee_compensations', timestamps: true }) export class EmployeeCompensation extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true }) employeeId!: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId }) structureId?: MongooseSchema.Types.ObjectId; @Prop({ default: 'INR' }) currency!: string; @Prop({ default: 0 }) ctc!: number; @Prop({ default: 0 }) grossSalary!: number; @Prop({ default: 0 }) netSalaryEstimate!: number; @Prop({ required: true }) effectiveFrom!: Date; @Prop() effectiveTo?: Date; @Prop({ default: 'active', enum: ['draft', 'pending_approval', 'active', 'inactive', 'superseded'], }) status!: string; @Prop({ default: 1 }) version!: number; @Prop() changeReason?: string; @Prop({ type: MongooseSchema.Types.ObjectId }) approvedBy?: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId }) createdBy?: MongooseSchema.Types.ObjectId; } export const EmployeeCompensationSchema = SchemaFactory.createForClass(EmployeeCompensation); EmployeeCompensationSchema.index({ tenantId: 1, employeeId: 1, effectiveFrom: -1, }); EmployeeCompensationSchema.index({ tenantId: 1, employeeId: 1, status: 1 }); @Schema({ collection: 'employee_compensation_versions', timestamps: true }) export class EmployeeCompensationVersion extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId, required: true }) compensationId!: MongooseSchema.Types.ObjectId; @Prop({ required: true }) version!: number; @Prop({ type: MongooseSchema.Types.Mixed, required: true }) snapshot!: Record< string, unknown >; } export const EmployeeCompensationVersionSchema = SchemaFactory.createForClass( EmployeeCompensationVersion, ); @Schema({ collection: 'employee_salary_components', timestamps: true }) export class EmployeeSalaryComponent extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId, required: true }) compensationId!: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId, required: true }) employeeId!: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId, required: true }) componentId!: MongooseSchema.Types.ObjectId; @Prop({ default: 0 }) amount!: number; @Prop() formulaOverride?: string; @Prop({ default: true }) isActive!: boolean; } export const EmployeeSalaryComponentSchema = SchemaFactory.createForClass( EmployeeSalaryComponent, ); EmployeeSalaryComponentSchema.index({ tenantId: 1, compensationId: 1 }); EmployeeSalaryComponentSchema.index({ tenantId: 1, employeeId: 1, componentId: 1, }); |