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

0% Statements 0/33
0% Branches 0/50
100% Functions 0/0
0% Lines 0/27

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                                                                                                                       
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ collection: 'payroll_accounting_mappings', timestamps: true })
export class PayrollAccountingMapping extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  componentId!: MongooseSchema.Types.ObjectId;
  @Prop({ required: true }) glAccountCode!: string;
  @Prop() glAccountName?: string;
  @Prop({ required: true, enum: ['debit', 'credit'] }) entryType!: string;
}
export const PayrollAccountingMappingSchema = SchemaFactory.createForClass(
  PayrollAccountingMapping,
);
 
@Schema({ collection: 'payroll_journal_exports', timestamps: true })
export class PayrollJournalExport extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  runId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  periodId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.Mixed, default: [] }) entries!: Record<
    string,
    unknown
  >[];
  @Prop() fileId?: string;
  @Prop({ default: 'draft', enum: ['draft', 'generated', 'exported'] })
  status!: string;
}
export const PayrollJournalExportSchema =
  SchemaFactory.createForClass(PayrollJournalExport);
 
@Schema({ collection: 'payroll_cost_allocations', timestamps: true })
export class PayrollCostAllocation extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  tenantId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true })
  runId!: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  departmentId?: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  branchId?: MongooseSchema.Types.ObjectId;
  @Prop({ type: MongooseSchema.Types.ObjectId })
  costCenterId?: MongooseSchema.Types.ObjectId;
  @Prop({ default: 0 }) totalCost!: number;
  @Prop({ default: 0 }) grossPay!: number;
  @Prop({ default: 0 }) employerContributions!: number;
}
export const PayrollCostAllocationSchema = SchemaFactory.createForClass(
  PayrollCostAllocation,
);
 
// ────────────────────────────────────────────────────────────────
// 20. OFF-CYCLE PAYROLL
// ────────────────────────────────────────────────────────────────