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

0% Statements 0/49
0% Branches 0/64
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 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                                                                                                                                                                                               
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ collection: 'payroll_payment_batches', timestamps: true })
export class PayrollPaymentBatch extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  runId!: MongooseSchema.Types.ObjectId;
  @Prop({ required: true }) batchName!: string;
  @Prop({ default: 0 }) totalAmount!: number;
  @Prop({ default: 0 }) totalInstructions!: number;
  @Prop({
    default: 'pending',
    enum: [
      'pending',
      'generated',
      'submitted',
      'processing',
      'completed',
      'partially_completed',
      'failed',
    ],
  })
  status!: string;
  @Prop() fileId?: string;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  generatedBy?: MongooseSchema.Types.ObjectId;
}
export const PayrollPaymentBatchSchema =
  SchemaFactory.createForClass(PayrollPaymentBatch);
 
@Schema({ collection: 'payroll_payment_instructions', timestamps: true })
export class PayrollPaymentInstruction extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  batchId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  employeeId!: MongooseSchema.Types.ObjectId;
  @Prop({ default: 0 }) amount!: number;
  @Prop() bankName?: string;
  @Prop() accountNumberMasked?: string;
  @Prop() ifscCode?: string;
  @Prop() utrNumber?: string;
  @Prop({
    default: 'pending',
    enum: ['pending', 'processing', 'completed', 'failed', 'reversed'],
  })
  status!: string;
  @Prop() failureReason?: string;
}
export const PayrollPaymentInstructionSchema = SchemaFactory.createForClass(
  PayrollPaymentInstruction,
);
PayrollPaymentInstructionSchema.index({ tenantId: 1, batchId: 1 });
 
@Schema({ collection: 'payroll_bank_files', timestamps: true })
export class PayrollBankFile extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  batchId!: MongooseSchema.Types.ObjectId;
  @Prop({ required: true }) format!: string;
  @Prop() fileId?: string;
  @Prop() fileName?: string;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  generatedBy?: MongooseSchema.Types.ObjectId;
}
export const PayrollBankFileSchema =
  SchemaFactory.createForClass(PayrollBankFile);
 
@Schema({ collection: 'payroll_payment_reconciliations', timestamps: true })
export class PayrollPaymentReconciliation extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  batchId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  instructionId!: MongooseSchema.Types.ObjectId;
  @Prop() utrNumber?: string;
  @Prop({
    default: 'pending',
    enum: ['pending', 'matched', 'failed', 'disputed'],
  })
  status!: string;
  @Prop() reconciledAt?: Date;
}
export const PayrollPaymentReconciliationSchema = SchemaFactory.createForClass(
  PayrollPaymentReconciliation,
);
 
// ────────────────────────────────────────────────────────────────
// 19. ACCOUNTING EXPORT
// ────────────────────────────────────────────────────────────────