All files / src/domains/hr/payroll/configuration/schemas payroll-configuration.schema.ts

0% Statements 0/45
0% Branches 0/19
100% Functions 0/0
0% Lines 0/41

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                                                                                                                                 
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ collection: 'payroll_configurations', timestamps: true })
export class PayrollConfiguration extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId!: MongooseSchema.Types.ObjectId;
 
  @Prop({ default: false }) payrollEnabled!: boolean;
  @Prop({ default: 'IN' }) payrollCountry!: string;
  @Prop({ default: 'INR' }) baseCurrency!: string;
  @Prop({ default: 'Asia/Kolkata' }) payrollTimezone!: string;
  @Prop({ default: 4 }) financialYearStartMonth!: number;
  @Prop({
    default: 'monthly',
    enum: ['monthly', 'weekly', 'biweekly', 'semi_monthly', 'daily', 'custom'],
  })
  defaultPayrollFrequency!: string;
  @Prop({ default: 'calendar', enum: ['calendar', 'fixed', 'custom'] })
  defaultWorkingDayMethod!: string;
  @Prop({ default: 'nearest', enum: ['nearest', 'up', 'down', 'truncate'] })
  roundingMode!: string;
  @Prop({ default: 2 }) decimalPrecision!: number;
  @Prop({ default: 'monthly', enum: ['monthly', 'annual', 'ctc'] })
  salaryDisplayMode!: string;
  @Prop({ default: false }) allowNegativeNetPay!: boolean;
  @Prop({ default: true }) payrollApprovalRequired!: boolean;
  @Prop({ default: false }) financeApprovalRequired!: boolean;
  @Prop({ default: true }) autoLockAfterCompletion!: boolean;
  @Prop({ default: false }) payslipPasswordProtection!: boolean;
  @Prop({ default: true }) payslipEmailEnabled!: boolean;
  @Prop({ default: 'generic_csv' }) bankFileFormat!: string;
  @Prop() statutoryProviderKey?: string;
  @Prop() taxProviderKey?: string;
  @Prop({ default: 25 }) attendanceCutoffDay!: number;
  @Prop({ default: 25 }) leaveCutoffDay!: number;
  @Prop({ default: 28 }) payrollInputCutoffDay!: number;
  @Prop({ default: 1 }) paymentDay!: number;
  @Prop({ default: true }) arrearsEnabled!: boolean;
  @Prop({ default: true }) offCyclePayrollEnabled!: boolean;
  @Prop({ default: true }) fullAndFinalEnabled!: boolean;
  @Prop({ default: 1 }) version!: number;
  @Prop({ default: 'draft', enum: ['draft', 'published'] }) status!: string;
}
export const PayrollConfigurationSchema =
  SchemaFactory.createForClass(PayrollConfiguration);
PayrollConfigurationSchema.index({ tenantId: 1 }, { unique: true });
 
@Schema({ collection: 'payroll_configuration_versions', timestamps: true })
export class PayrollConfigurationVersion extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ required: true }) version!: number;
  @Prop({ type: MongooseSchema.Types.Mixed, required: true }) snapshot!: Record<
    string,
    unknown
  >;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  publishedBy?: MongooseSchema.Types.ObjectId;
}
export const PayrollConfigurationVersionSchema = SchemaFactory.createForClass(
  PayrollConfigurationVersion,
);
PayrollConfigurationVersionSchema.index({ tenantId: 1, version: -1 });