All files / src/domains/hr/attendance/schemas lock.schema.ts

0% Statements 0/18
0% Branches 0/8
100% Functions 0/0
0% Lines 0/16

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                                                                                   
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'attendance_locks' })
export class AttendanceLock extends Document {
  @Prop({ required: true, index: true })
  tenantId: string;
 
  @Prop({ required: true })
  lockPeriodName: string; // e.g., 'Jan 2026 Payroll'
 
  @Prop({ required: true })
  startDate: string; // YYYY-MM-DD
 
  @Prop({ required: true })
  endDate: string; // YYYY-MM-DD
 
  @Prop({ type: [{ type: String }], default: [] })
  targetEmployeeIds: string[]; // empty means all employees
 
  @Prop({ type: [{ type: String }], default: [] })
  targetBranchIds: string[];
 
  @Prop({ default: 'locked' })
  status: string; // locked, unlocked (temporary)
 
  @Prop({ default: null })
  lockedAt: Date;
 
  @Prop({ required: true })
  lockedBy: string;
 
  @Prop()
  unlockReason: string;
 
  @Prop({ default: null })
  unlockedUntil: Date;
}
export const AttendanceLockSchema =
  SchemaFactory.createForClass(AttendanceLock);
AttendanceLockSchema.index({ tenantId: 1, startDate: 1, endDate: 1 });