All files / src/domains/hr/payroll/imports/schemas payroll-import-export.schema.ts

0% Statements 0/38
0% Branches 0/38
100% Functions 0/0
0% Lines 0/32

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                                                                                                                                                                         
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ collection: 'payroll_import_jobs', timestamps: true })
export class PayrollImportJob extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({
    required: true,
    enum: [
      'salary_structure',
      'compensation',
      'earning',
      'deduction',
      'loan',
      'advance',
      'reimbursement',
      'input',
      'ytd_opening',
    ],
  })
  importType!: string;
  @Prop() fileId?: string;
  @Prop() fileName?: string;
  @Prop({ default: 0 }) totalRows!: number;
  @Prop({ default: 0 }) successRows!: number;
  @Prop({ default: 0 }) errorRows!: number;
  @Prop({
    default: 'pending',
    enum: [
      'pending',
      'validating',
      'validated',
      'executing',
      'completed',
      'failed',
      'rolled_back',
    ],
  })
  status!: string;
  @Prop({ default: false }) isDryRun!: boolean;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  createdBy?: MongooseSchema.Types.ObjectId;
}
export const PayrollImportJobSchema =
  SchemaFactory.createForClass(PayrollImportJob);
 
@Schema({ collection: 'payroll_import_rows', timestamps: true })
export class PayrollImportRow extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  jobId!: MongooseSchema.Types.ObjectId;
  @Prop({ required: true }) rowNumber!: number;
  @Prop({ type: MongooseSchema.Types.Mixed, required: true }) data!: Record<
    string,
    unknown
  >;
  @Prop({ default: 'pending', enum: ['pending', 'valid', 'error', 'applied'] })
  status!: string;
  @Prop({ type: [String], default: [] }) validationErrors!: string[];
}
export const PayrollImportRowSchema =
  SchemaFactory.createForClass(PayrollImportRow);
PayrollImportRowSchema.index({ tenantId: 1, jobId: 1 });
 
@Schema({ collection: 'payroll_export_jobs', timestamps: true })
export class PayrollExportJob extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ required: true }) exportType!: string;
  @Prop({ type: MongooseSchema.Types.Mixed }) filters?: Record<string, unknown>;
  @Prop() fileId?: string;
  @Prop() fileName?: string;
  @Prop({
    default: 'pending',
    enum: ['pending', 'generating', 'completed', 'failed'],
  })
  status!: string;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  createdBy?: MongooseSchema.Types.ObjectId;
}
export const PayrollExportJobSchema =
  SchemaFactory.createForClass(PayrollExportJob);