@classytic/payroll 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +168 -489
  2. package/dist/core/index.d.ts +480 -0
  3. package/dist/core/index.js +971 -0
  4. package/dist/core/index.js.map +1 -0
  5. package/dist/index-CTjHlCzz.d.ts +721 -0
  6. package/dist/index.d.ts +967 -0
  7. package/dist/index.js +4352 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/payroll.d.ts +233 -0
  10. package/dist/payroll.js +2103 -0
  11. package/dist/payroll.js.map +1 -0
  12. package/dist/plugin-D9mOr3_d.d.ts +333 -0
  13. package/dist/schemas/index.d.ts +2869 -0
  14. package/dist/schemas/index.js +440 -0
  15. package/dist/schemas/index.js.map +1 -0
  16. package/dist/services/index.d.ts +3 -0
  17. package/dist/services/index.js +1696 -0
  18. package/dist/services/index.js.map +1 -0
  19. package/dist/types-BSYyX2KJ.d.ts +671 -0
  20. package/dist/utils/index.d.ts +873 -0
  21. package/dist/utils/index.js +1046 -0
  22. package/dist/utils/index.js.map +1 -0
  23. package/package.json +54 -37
  24. package/dist/types/config.d.ts +0 -162
  25. package/dist/types/core/compensation.manager.d.ts +0 -54
  26. package/dist/types/core/employment.manager.d.ts +0 -49
  27. package/dist/types/core/payroll.manager.d.ts +0 -60
  28. package/dist/types/enums.d.ts +0 -117
  29. package/dist/types/factories/compensation.factory.d.ts +0 -196
  30. package/dist/types/factories/employee.factory.d.ts +0 -149
  31. package/dist/types/factories/payroll.factory.d.ts +0 -319
  32. package/dist/types/hrm.orchestrator.d.ts +0 -47
  33. package/dist/types/index.d.ts +0 -20
  34. package/dist/types/init.d.ts +0 -30
  35. package/dist/types/models/payroll-record.model.d.ts +0 -3
  36. package/dist/types/plugins/employee.plugin.d.ts +0 -2
  37. package/dist/types/schemas/employment.schema.d.ts +0 -959
  38. package/dist/types/services/compensation.service.d.ts +0 -94
  39. package/dist/types/services/employee.service.d.ts +0 -28
  40. package/dist/types/services/payroll.service.d.ts +0 -30
  41. package/dist/types/utils/calculation.utils.d.ts +0 -26
  42. package/dist/types/utils/date.utils.d.ts +0 -35
  43. package/dist/types/utils/logger.d.ts +0 -12
  44. package/dist/types/utils/query-builders.d.ts +0 -83
  45. package/dist/types/utils/validation.utils.d.ts +0 -33
  46. package/payroll.d.ts +0 -241
  47. package/src/config.js +0 -177
  48. package/src/core/compensation.manager.js +0 -242
  49. package/src/core/employment.manager.js +0 -224
  50. package/src/core/payroll.manager.js +0 -499
  51. package/src/enums.js +0 -141
  52. package/src/factories/compensation.factory.js +0 -198
  53. package/src/factories/employee.factory.js +0 -173
  54. package/src/factories/payroll.factory.js +0 -413
  55. package/src/hrm.orchestrator.js +0 -139
  56. package/src/index.js +0 -172
  57. package/src/init.js +0 -62
  58. package/src/models/payroll-record.model.js +0 -126
  59. package/src/plugins/employee.plugin.js +0 -164
  60. package/src/schemas/employment.schema.js +0 -126
  61. package/src/services/compensation.service.js +0 -231
  62. package/src/services/employee.service.js +0 -162
  63. package/src/services/payroll.service.js +0 -213
  64. package/src/utils/calculation.utils.js +0 -91
  65. package/src/utils/date.utils.js +0 -120
  66. package/src/utils/logger.js +0 -36
  67. package/src/utils/query-builders.js +0 -185
  68. package/src/utils/validation.utils.js +0 -122
@@ -0,0 +1,671 @@
1
+ import { Model, Types, ClientSession, Document } from 'mongoose';
2
+
3
+ /**
4
+ * @classytic/payroll - Type Definitions
5
+ *
6
+ * Production-grade types for HRM and payroll management
7
+ * Follows industry patterns from Stripe, Netflix, Meta
8
+ *
9
+ * @module @classytic/payroll
10
+ */
11
+
12
+ /** Re-export mongoose ObjectId */
13
+ type ObjectId = Types.ObjectId;
14
+ /** ObjectId or string representation */
15
+ type ObjectIdLike = ObjectId | string;
16
+ /** Generic document type */
17
+ type AnyDocument = Document & Record<string, unknown>;
18
+ /** Deep partial type for nested objects */
19
+ type DeepPartial<T> = {
20
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
21
+ };
22
+ /** Employment type */
23
+ type EmploymentType = 'full_time' | 'part_time' | 'contract' | 'intern' | 'consultant';
24
+ /** Employee status */
25
+ type EmployeeStatus = 'active' | 'on_leave' | 'suspended' | 'terminated';
26
+ /** Department type */
27
+ type Department = 'management' | 'training' | 'sales' | 'operations' | 'support' | 'hr' | 'maintenance' | 'marketing' | 'finance' | 'it';
28
+ /** Payment frequency */
29
+ type PaymentFrequency = 'monthly' | 'bi_weekly' | 'weekly' | 'hourly' | 'daily';
30
+ /** Payment method */
31
+ type PaymentMethod = 'bank' | 'cash' | 'check' | 'mobile' | 'bkash' | 'nagad' | 'rocket';
32
+ /** Allowance type */
33
+ type AllowanceType = 'housing' | 'transport' | 'meal' | 'mobile' | 'medical' | 'education' | 'bonus' | 'other';
34
+ /** Deduction type */
35
+ type DeductionType = 'tax' | 'loan' | 'advance' | 'provident_fund' | 'insurance' | 'absence' | 'other';
36
+ /** Payroll status */
37
+ type PayrollStatus = 'pending' | 'processing' | 'paid' | 'failed' | 'cancelled';
38
+ /** Termination reason */
39
+ type TerminationReason = 'resignation' | 'retirement' | 'termination' | 'contract_end' | 'mutual_agreement' | 'other';
40
+ /** HRM transaction category */
41
+ type HRMTransactionCategory = 'salary' | 'bonus' | 'commission' | 'overtime' | 'severance';
42
+ /** Organization role */
43
+ type OrgRole = 'owner' | 'manager' | 'trainer' | 'staff' | 'intern' | 'consultant';
44
+ /** Data retention configuration */
45
+ interface DataRetentionConfig {
46
+ /** TTL for payroll records in seconds (default: 2 years) */
47
+ payrollRecordsTTL: number;
48
+ /** Days before TTL to warn (default: 30) */
49
+ exportWarningDays: number;
50
+ /** Archive records before deletion */
51
+ archiveBeforeDeletion: boolean;
52
+ }
53
+ /** Payroll configuration */
54
+ interface PayrollConfig {
55
+ /** Default currency code */
56
+ defaultCurrency: string;
57
+ /** Allow pro-rating for mid-month hires */
58
+ allowProRating: boolean;
59
+ /** Enable attendance integration */
60
+ attendanceIntegration: boolean;
61
+ /** Auto-apply deductions */
62
+ autoDeductions: boolean;
63
+ /** Enable overtime calculations */
64
+ overtimeEnabled: boolean;
65
+ /** Overtime multiplier (e.g., 1.5 for 150%) */
66
+ overtimeMultiplier: number;
67
+ }
68
+ /** Salary configuration */
69
+ interface SalaryConfig {
70
+ /** Minimum wage threshold */
71
+ minimumWage: number;
72
+ /** Maximum number of allowances */
73
+ maximumAllowances: number;
74
+ /** Maximum number of deductions */
75
+ maximumDeductions: number;
76
+ /** Default payment frequency */
77
+ defaultFrequency: PaymentFrequency;
78
+ }
79
+ /** Employment configuration */
80
+ interface EmploymentConfig {
81
+ /** Default probation period in months */
82
+ defaultProbationMonths: number;
83
+ /** Maximum probation period in months */
84
+ maxProbationMonths: number;
85
+ /** Allow re-hiring terminated employees */
86
+ allowReHiring: boolean;
87
+ /** Track employment history */
88
+ trackEmploymentHistory: boolean;
89
+ }
90
+ /** Validation configuration */
91
+ interface ValidationConfig {
92
+ /** Require bank details for salary payment */
93
+ requireBankDetails: boolean;
94
+ /** Require employee ID */
95
+ requireEmployeeId: boolean;
96
+ /** Enforce unique employee ID per organization */
97
+ uniqueEmployeeIdPerOrg: boolean;
98
+ /** Allow same user in multiple organizations */
99
+ allowMultiTenantEmployees: boolean;
100
+ }
101
+ /** Main HRM configuration */
102
+ interface HRMConfig {
103
+ /** Data retention settings */
104
+ dataRetention: DataRetentionConfig;
105
+ /** Payroll settings */
106
+ payroll: PayrollConfig;
107
+ /** Salary settings */
108
+ salary: SalaryConfig;
109
+ /** Employment settings */
110
+ employment: EmploymentConfig;
111
+ /** Validation settings */
112
+ validation: ValidationConfig;
113
+ }
114
+ /** Single-tenant configuration */
115
+ interface SingleTenantConfig {
116
+ /** Fixed organization ID (optional - will use default if not provided) */
117
+ organizationId?: ObjectIdLike;
118
+ /** Auto-inject organizationId if missing (default: true) */
119
+ autoInject?: boolean;
120
+ }
121
+ /** Main Payroll initialization config */
122
+ interface PayrollInitConfig {
123
+ /** Employee model (required) */
124
+ EmployeeModel: Model<any>;
125
+ /** Payroll record model (required) */
126
+ PayrollRecordModel: Model<any>;
127
+ /** Transaction model (required) */
128
+ TransactionModel: Model<any>;
129
+ /** Attendance model (optional, for integration) */
130
+ AttendanceModel?: Model<any> | null;
131
+ /** Single-tenant configuration */
132
+ singleTenant?: SingleTenantConfig | null;
133
+ /** Custom logger */
134
+ logger?: Logger;
135
+ /** Custom HRM config overrides */
136
+ config?: DeepPartial<HRMConfig>;
137
+ }
138
+ /** Bank details */
139
+ interface BankDetails {
140
+ accountName?: string;
141
+ accountNumber?: string;
142
+ bankName?: string;
143
+ branchName?: string;
144
+ routingNumber?: string;
145
+ }
146
+ /** Allowance entry */
147
+ interface Allowance {
148
+ type: AllowanceType;
149
+ name?: string;
150
+ amount: number;
151
+ /** Whether amount is percentage of base salary */
152
+ isPercentage?: boolean;
153
+ /** Percentage value if isPercentage is true */
154
+ value?: number;
155
+ taxable?: boolean;
156
+ recurring?: boolean;
157
+ effectiveFrom?: Date;
158
+ effectiveTo?: Date | null;
159
+ }
160
+ /** Deduction entry */
161
+ interface Deduction {
162
+ type: DeductionType;
163
+ name?: string;
164
+ amount: number;
165
+ /** Whether amount is percentage of base salary */
166
+ isPercentage?: boolean;
167
+ /** Percentage value if isPercentage is true */
168
+ value?: number;
169
+ auto?: boolean;
170
+ recurring?: boolean;
171
+ effectiveFrom?: Date;
172
+ effectiveTo?: Date | null;
173
+ description?: string;
174
+ }
175
+ /** Compensation structure */
176
+ interface Compensation {
177
+ /** Base salary amount */
178
+ baseAmount: number;
179
+ /** Payment frequency */
180
+ frequency: PaymentFrequency;
181
+ /** Currency code */
182
+ currency: string;
183
+ /** Allowances array */
184
+ allowances: Allowance[];
185
+ /** Deductions array */
186
+ deductions: Deduction[];
187
+ /** Calculated gross salary */
188
+ grossSalary?: number;
189
+ /** Calculated net salary */
190
+ netSalary?: number;
191
+ /** When compensation became effective */
192
+ effectiveFrom?: Date;
193
+ /** Last modified timestamp */
194
+ lastModified?: Date;
195
+ }
196
+ /** Work schedule */
197
+ interface WorkSchedule {
198
+ hoursPerWeek?: number;
199
+ hoursPerDay?: number;
200
+ /** Working days (0=Sunday, 6=Saturday) */
201
+ workingDays?: number[];
202
+ shiftStart?: string;
203
+ shiftEnd?: string;
204
+ }
205
+ /** Employment history entry */
206
+ interface EmploymentHistoryEntry {
207
+ hireDate: Date;
208
+ terminationDate: Date;
209
+ reason?: TerminationReason;
210
+ finalSalary?: number;
211
+ position?: string;
212
+ department?: string;
213
+ notes?: string;
214
+ createdAt?: Date;
215
+ updatedAt?: Date;
216
+ }
217
+ /** Payroll stats (pre-calculated) */
218
+ interface PayrollStats {
219
+ totalPaid: number;
220
+ lastPaymentDate?: Date | null;
221
+ nextPaymentDate?: Date | null;
222
+ paymentsThisYear: number;
223
+ averageMonthly: number;
224
+ updatedAt?: Date;
225
+ }
226
+ /** Employee document structure */
227
+ interface EmployeeDocument extends Document {
228
+ _id: ObjectId;
229
+ userId: ObjectId;
230
+ organizationId: ObjectId;
231
+ employeeId: string;
232
+ employmentType: EmploymentType;
233
+ status: EmployeeStatus;
234
+ department?: Department;
235
+ position: string;
236
+ hireDate: Date;
237
+ terminationDate?: Date | null;
238
+ probationEndDate?: Date | null;
239
+ employmentHistory: EmploymentHistoryEntry[];
240
+ compensation: Compensation;
241
+ workSchedule?: WorkSchedule;
242
+ bankDetails?: BankDetails;
243
+ payrollStats: PayrollStats;
244
+ notes?: string;
245
+ createdAt?: Date;
246
+ updatedAt?: Date;
247
+ save(options?: {
248
+ session?: ClientSession;
249
+ }): Promise<this>;
250
+ toObject(): Record<string, unknown>;
251
+ }
252
+ /** Payroll period */
253
+ interface PayrollPeriod {
254
+ month: number;
255
+ year: number;
256
+ startDate: Date;
257
+ endDate: Date;
258
+ payDate: Date;
259
+ }
260
+ /** Payroll breakdown */
261
+ interface PayrollBreakdown {
262
+ baseAmount: number;
263
+ allowances: Array<{
264
+ type: string;
265
+ amount: number;
266
+ taxable?: boolean;
267
+ }>;
268
+ deductions: Array<{
269
+ type: string;
270
+ amount: number;
271
+ description?: string;
272
+ }>;
273
+ grossSalary: number;
274
+ netSalary: number;
275
+ /** Taxable amount (base + taxable allowances) */
276
+ taxableAmount?: number;
277
+ /** Calculated tax amount */
278
+ taxAmount?: number;
279
+ workingDays?: number;
280
+ actualDays?: number;
281
+ proRatedAmount?: number;
282
+ attendanceDeduction?: number;
283
+ overtimeAmount?: number;
284
+ bonusAmount?: number;
285
+ }
286
+ /** Payroll record document */
287
+ interface PayrollRecordDocument extends Document {
288
+ _id: ObjectId;
289
+ organizationId: ObjectId;
290
+ employeeId: ObjectId;
291
+ userId?: ObjectId;
292
+ period: PayrollPeriod;
293
+ breakdown: PayrollBreakdown;
294
+ transactionId?: ObjectId | null;
295
+ status: PayrollStatus;
296
+ paidAt?: Date | null;
297
+ processedAt?: Date | null;
298
+ paymentMethod?: PaymentMethod;
299
+ metadata?: Record<string, unknown>;
300
+ processedBy?: ObjectId;
301
+ notes?: string;
302
+ payslipUrl?: string;
303
+ exported: boolean;
304
+ exportedAt?: Date | null;
305
+ createdAt?: Date;
306
+ updatedAt?: Date;
307
+ save(options?: {
308
+ session?: ClientSession;
309
+ }): Promise<this>;
310
+ toObject(): Record<string, unknown>;
311
+ }
312
+ /** Base operation context */
313
+ interface OperationContext {
314
+ /** User performing the operation */
315
+ userId?: ObjectIdLike;
316
+ /** User name */
317
+ userName?: string;
318
+ /** User role */
319
+ userRole?: string;
320
+ /** Organization ID (auto-injected in single-tenant mode) */
321
+ organizationId?: ObjectIdLike;
322
+ /** MongoDB session for transactions */
323
+ session?: ClientSession;
324
+ }
325
+ /** Hire employee parameters */
326
+ interface HireEmployeeParams {
327
+ /** User ID */
328
+ userId: ObjectIdLike;
329
+ /** Organization ID (optional in single-tenant mode - auto-injected) */
330
+ organizationId?: ObjectIdLike;
331
+ /** Employment details */
332
+ employment: {
333
+ employeeId?: string;
334
+ type?: EmploymentType;
335
+ department?: Department | string;
336
+ position: string;
337
+ hireDate?: Date;
338
+ probationMonths?: number;
339
+ workSchedule?: WorkSchedule;
340
+ };
341
+ /** Compensation details */
342
+ compensation: {
343
+ baseAmount: number;
344
+ frequency?: PaymentFrequency;
345
+ currency?: string;
346
+ allowances?: Array<Partial<Allowance>>;
347
+ deductions?: Array<Partial<Deduction>>;
348
+ };
349
+ /** Bank details */
350
+ bankDetails?: BankDetails;
351
+ /** Operation context */
352
+ context?: OperationContext;
353
+ }
354
+ /** Update employment parameters */
355
+ interface UpdateEmploymentParams {
356
+ /** Employee document ID */
357
+ employeeId: ObjectIdLike;
358
+ /** Fields to update */
359
+ updates: {
360
+ department?: Department;
361
+ position?: string;
362
+ employmentType?: EmploymentType;
363
+ status?: EmployeeStatus;
364
+ workSchedule?: WorkSchedule;
365
+ };
366
+ /** Operation context */
367
+ context?: OperationContext;
368
+ }
369
+ /** Terminate employee parameters */
370
+ interface TerminateEmployeeParams {
371
+ /** Employee document ID */
372
+ employeeId: ObjectIdLike;
373
+ /** Termination date */
374
+ terminationDate?: Date;
375
+ /** Termination reason */
376
+ reason?: TerminationReason;
377
+ /** Notes */
378
+ notes?: string;
379
+ /** Operation context */
380
+ context?: OperationContext;
381
+ }
382
+ /** Re-hire employee parameters */
383
+ interface ReHireEmployeeParams {
384
+ /** Employee document ID */
385
+ employeeId: ObjectIdLike;
386
+ /** New hire date */
387
+ hireDate?: Date;
388
+ /** New position */
389
+ position?: string;
390
+ /** New department */
391
+ department?: Department;
392
+ /** New compensation */
393
+ compensation?: DeepPartial<Compensation>;
394
+ /** Operation context */
395
+ context?: OperationContext;
396
+ }
397
+ /** List employees parameters */
398
+ interface ListEmployeesParams {
399
+ /** Organization ID */
400
+ organizationId: ObjectIdLike;
401
+ /** Filters */
402
+ filters?: {
403
+ status?: EmployeeStatus;
404
+ department?: Department;
405
+ employmentType?: EmploymentType;
406
+ minSalary?: number;
407
+ maxSalary?: number;
408
+ };
409
+ /** Pagination */
410
+ pagination?: {
411
+ page?: number;
412
+ limit?: number;
413
+ sort?: Record<string, 1 | -1>;
414
+ };
415
+ }
416
+ /** Update salary parameters */
417
+ interface UpdateSalaryParams {
418
+ /** Employee document ID */
419
+ employeeId: ObjectIdLike;
420
+ /** Compensation updates */
421
+ compensation: {
422
+ baseAmount?: number;
423
+ frequency?: PaymentFrequency;
424
+ currency?: string;
425
+ };
426
+ /** Effective from date */
427
+ effectiveFrom?: Date;
428
+ /** Operation context */
429
+ context?: OperationContext;
430
+ }
431
+ /** Add allowance parameters */
432
+ interface AddAllowanceParams {
433
+ /** Employee document ID */
434
+ employeeId: ObjectIdLike;
435
+ /** Allowance type */
436
+ type: AllowanceType;
437
+ /** Amount */
438
+ amount: number;
439
+ /** Is taxable */
440
+ taxable?: boolean;
441
+ /** Is recurring */
442
+ recurring?: boolean;
443
+ /** Effective from */
444
+ effectiveFrom?: Date;
445
+ /** Effective to */
446
+ effectiveTo?: Date | null;
447
+ /** Operation context */
448
+ context?: OperationContext;
449
+ }
450
+ /** Remove allowance parameters */
451
+ interface RemoveAllowanceParams {
452
+ /** Employee document ID */
453
+ employeeId: ObjectIdLike;
454
+ /** Allowance type to remove */
455
+ type: AllowanceType;
456
+ /** Operation context */
457
+ context?: OperationContext;
458
+ }
459
+ /** Add deduction parameters */
460
+ interface AddDeductionParams {
461
+ /** Employee document ID */
462
+ employeeId: ObjectIdLike;
463
+ /** Deduction type */
464
+ type: DeductionType;
465
+ /** Amount */
466
+ amount: number;
467
+ /** Auto-deduct from salary */
468
+ auto?: boolean;
469
+ /** Is recurring */
470
+ recurring?: boolean;
471
+ /** Description */
472
+ description?: string;
473
+ /** Effective from */
474
+ effectiveFrom?: Date;
475
+ /** Effective to */
476
+ effectiveTo?: Date | null;
477
+ /** Operation context */
478
+ context?: OperationContext;
479
+ }
480
+ /** Remove deduction parameters */
481
+ interface RemoveDeductionParams {
482
+ /** Employee document ID */
483
+ employeeId: ObjectIdLike;
484
+ /** Deduction type to remove */
485
+ type: DeductionType;
486
+ /** Operation context */
487
+ context?: OperationContext;
488
+ }
489
+ /** Update bank details parameters */
490
+ interface UpdateBankDetailsParams {
491
+ /** Employee document ID */
492
+ employeeId: ObjectIdLike;
493
+ /** Bank details */
494
+ bankDetails: BankDetails;
495
+ /** Operation context */
496
+ context?: OperationContext;
497
+ }
498
+ /** Process salary parameters */
499
+ interface ProcessSalaryParams {
500
+ /** Employee document ID */
501
+ employeeId: ObjectIdLike;
502
+ /** Month (1-12) */
503
+ month: number;
504
+ /** Year */
505
+ year: number;
506
+ /** Payment date */
507
+ paymentDate?: Date;
508
+ /** Payment method */
509
+ paymentMethod?: PaymentMethod;
510
+ /** Operation context */
511
+ context?: OperationContext;
512
+ }
513
+ /** Process bulk payroll parameters */
514
+ interface ProcessBulkPayrollParams {
515
+ /** Organization ID */
516
+ organizationId: ObjectIdLike;
517
+ /** Month (1-12) */
518
+ month: number;
519
+ /** Year */
520
+ year: number;
521
+ /** Specific employee IDs (empty = all active) */
522
+ employeeIds?: ObjectIdLike[];
523
+ /** Payment date */
524
+ paymentDate?: Date;
525
+ /** Payment method */
526
+ paymentMethod?: PaymentMethod;
527
+ /** Operation context */
528
+ context?: OperationContext;
529
+ }
530
+ /** Payroll history parameters */
531
+ interface PayrollHistoryParams {
532
+ /** Employee document ID */
533
+ employeeId?: ObjectIdLike;
534
+ /** Organization ID */
535
+ organizationId?: ObjectIdLike;
536
+ /** Month filter */
537
+ month?: number;
538
+ /** Year filter */
539
+ year?: number;
540
+ /** Status filter */
541
+ status?: PayrollStatus;
542
+ /** Pagination */
543
+ pagination?: {
544
+ page?: number;
545
+ limit?: number;
546
+ sort?: Record<string, 1 | -1>;
547
+ };
548
+ }
549
+ /** Payroll summary parameters */
550
+ interface PayrollSummaryParams {
551
+ /** Organization ID */
552
+ organizationId: ObjectIdLike;
553
+ /** Month */
554
+ month?: number;
555
+ /** Year */
556
+ year?: number;
557
+ }
558
+ /** Export payroll parameters */
559
+ interface ExportPayrollParams {
560
+ /** Organization ID */
561
+ organizationId: ObjectIdLike;
562
+ /** Start date */
563
+ startDate: Date;
564
+ /** End date */
565
+ endDate: Date;
566
+ /** Export format */
567
+ format?: 'json' | 'csv';
568
+ }
569
+ /** Process salary result */
570
+ interface ProcessSalaryResult {
571
+ payrollRecord: PayrollRecordDocument;
572
+ transaction: AnyDocument;
573
+ employee: EmployeeDocument;
574
+ }
575
+ /** Bulk payroll result */
576
+ interface BulkPayrollResult {
577
+ successful: Array<{
578
+ employeeId: string;
579
+ amount: number;
580
+ transactionId: ObjectId;
581
+ }>;
582
+ failed: Array<{
583
+ employeeId: string;
584
+ error: string;
585
+ }>;
586
+ total: number;
587
+ }
588
+ /** Payroll summary result */
589
+ interface PayrollSummaryResult {
590
+ totalGross: number;
591
+ totalNet: number;
592
+ totalDeductions: number;
593
+ employeeCount: number;
594
+ paidCount: number;
595
+ pendingCount: number;
596
+ }
597
+ /** Tax calculation result */
598
+ interface TaxCalculationResult {
599
+ gross: number;
600
+ tax: number;
601
+ net: number;
602
+ }
603
+ /** Compensation breakdown result */
604
+ interface CompensationBreakdownResult {
605
+ baseAmount: number;
606
+ allowances: Array<Allowance & {
607
+ calculatedAmount: number;
608
+ }>;
609
+ deductions: Array<Deduction & {
610
+ calculatedAmount: number;
611
+ }>;
612
+ grossAmount: number;
613
+ netAmount: number;
614
+ }
615
+ /** Payroll instance for plugin reference */
616
+ interface PayrollInstance {
617
+ /** Models container */
618
+ _models: {
619
+ EmployeeModel: Model<any>;
620
+ PayrollRecordModel: Model<any>;
621
+ TransactionModel: Model<any>;
622
+ AttendanceModel?: Model<any> | null;
623
+ } | null;
624
+ /** Event hooks */
625
+ _hooks: Map<string, Array<(data: unknown) => void | Promise<void>>>;
626
+ /** Is initialized */
627
+ _initialized: boolean;
628
+ /** Register event listener */
629
+ on(event: string, listener: (data: unknown) => void | Promise<void>): this;
630
+ /** Emit event */
631
+ emit(event: string, data: unknown): void;
632
+ /** Extended properties from plugins */
633
+ [key: string]: unknown;
634
+ }
635
+ /** Logger interface */
636
+ interface Logger {
637
+ info(message: string, meta?: Record<string, unknown>): void;
638
+ error(message: string, meta?: Record<string, unknown>): void;
639
+ warn(message: string, meta?: Record<string, unknown>): void;
640
+ debug(message: string, meta?: Record<string, unknown>): void;
641
+ }
642
+ /** Error codes */
643
+ type ErrorCode = 'PAYROLL_ERROR' | 'NOT_INITIALIZED' | 'EMPLOYEE_NOT_FOUND' | 'INVALID_EMPLOYEE' | 'DUPLICATE_PAYROLL' | 'VALIDATION_ERROR' | 'EMPLOYEE_TERMINATED' | 'ALREADY_PROCESSED' | 'NOT_ELIGIBLE';
644
+ /** HTTP error with status code */
645
+ interface HttpError extends Error {
646
+ code: ErrorCode;
647
+ status: number;
648
+ context?: Record<string, unknown>;
649
+ timestamp: Date;
650
+ }
651
+ /** Pro-rating calculation result */
652
+ interface ProRatingResult {
653
+ isProRated: boolean;
654
+ totalDays: number;
655
+ actualDays: number;
656
+ ratio: number;
657
+ }
658
+ /** Pay period info */
659
+ interface PayPeriodInfo {
660
+ month: number;
661
+ year: number;
662
+ startDate: Date;
663
+ endDate: Date;
664
+ }
665
+ /** Employee validation result */
666
+ interface EmployeeValidationResult {
667
+ valid: boolean;
668
+ errors: string[];
669
+ }
670
+
671
+ export type { PayPeriodInfo as $, AddAllowanceParams as A, BulkPayrollResult as B, Compensation as C, DeepPartial as D, EmployeeDocument as E, CompensationBreakdownResult as F, EmployeeStatus as G, HireEmployeeParams as H, AllowanceType as I, DeductionType as J, PayrollStatus as K, ListEmployeesParams as L, TerminationReason as M, HRMTransactionCategory as N, ObjectIdLike as O, PayrollInitConfig as P, BankDetails as Q, ReHireEmployeeParams as R, SingleTenantConfig as S, TerminateEmployeeParams as T, UpdateEmploymentParams as U, EmploymentHistoryEntry as V, WorkSchedule as W, PayrollStats as X, PayrollPeriod as Y, PayrollBreakdown as Z, PaymentMethod as _, UpdateSalaryParams as a, ProRatingResult as a0, TaxCalculationResult as a1, EmployeeValidationResult as a2, RemoveAllowanceParams as b, AddDeductionParams as c, RemoveDeductionParams as d, UpdateBankDetailsParams as e, ProcessSalaryParams as f, ProcessSalaryResult as g, ProcessBulkPayrollParams as h, PayrollHistoryParams as i, PayrollRecordDocument as j, PayrollSummaryParams as k, PayrollSummaryResult as l, ExportPayrollParams as m, HRMConfig as n, Logger as o, ObjectId as p, OperationContext as q, PayrollInstance as r, Department as s, EmploymentType as t, OrgRole as u, HttpError as v, ErrorCode as w, PaymentFrequency as x, Allowance as y, Deduction as z };