@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,873 @@
1
+ import { o as Logger, $ as PayPeriodInfo, a0 as ProRatingResult, y as Allowance, z as Deduction, C as Compensation, F as CompensationBreakdownResult, a1 as TaxCalculationResult, G as EmployeeStatus, a2 as EmployeeValidationResult, Q as BankDetails, t as EmploymentType, O as ObjectIdLike, s as Department, K as PayrollStatus } from '../types-BSYyX2KJ.js';
2
+ import { Types } from 'mongoose';
3
+
4
+ /**
5
+ * @classytic/payroll - Logger
6
+ *
7
+ * Pluggable logger abstraction
8
+ * Defaults to console, can be replaced with pino, winston, etc.
9
+ */
10
+
11
+ /**
12
+ * Get the current logger instance
13
+ */
14
+ declare function getLogger(): Logger;
15
+ /**
16
+ * Set a custom logger instance
17
+ */
18
+ declare function setLogger(logger: Logger): void;
19
+ /**
20
+ * Reset to default console logger
21
+ */
22
+ declare function resetLogger(): void;
23
+ /**
24
+ * Create a child logger with prefix
25
+ */
26
+ declare function createChildLogger(prefix: string): Logger;
27
+ /**
28
+ * Create a silent logger (for testing)
29
+ */
30
+ declare function createSilentLogger(): Logger;
31
+ /**
32
+ * Enable logging globally
33
+ */
34
+ declare function enableLogging(): void;
35
+ /**
36
+ * Disable logging globally (useful for production)
37
+ */
38
+ declare function disableLogging(): void;
39
+ /**
40
+ * Check if logging is enabled
41
+ */
42
+ declare function isLoggingEnabled(): boolean;
43
+ /**
44
+ * Logger proxy that always delegates to currentLogger
45
+ * Respects global logging enabled/disabled state
46
+ */
47
+ declare const logger: Logger;
48
+
49
+ /**
50
+ * @classytic/payroll - Date Utilities
51
+ *
52
+ * Pure, composable, testable date operations
53
+ * No side effects, no mutations
54
+ */
55
+
56
+ /**
57
+ * Add days to a date
58
+ */
59
+ declare function addDays(date: Date, days: number): Date;
60
+ /**
61
+ * Add months to a date
62
+ */
63
+ declare function addMonths(date: Date, months: number): Date;
64
+ /**
65
+ * Add years to a date
66
+ */
67
+ declare function addYears(date: Date, years: number): Date;
68
+ /**
69
+ * Subtract days from a date
70
+ */
71
+ declare function subDays(date: Date, days: number): Date;
72
+ /**
73
+ * Subtract months from a date
74
+ */
75
+ declare function subMonths(date: Date, months: number): Date;
76
+ /**
77
+ * Get the start of a month
78
+ */
79
+ declare function startOfMonth(date: Date): Date;
80
+ /**
81
+ * Get the end of a month
82
+ */
83
+ declare function endOfMonth(date: Date): Date;
84
+ /**
85
+ * Get the start of a year
86
+ */
87
+ declare function startOfYear(date: Date): Date;
88
+ /**
89
+ * Get the end of a year
90
+ */
91
+ declare function endOfYear(date: Date): Date;
92
+ /**
93
+ * Get the start of a day
94
+ */
95
+ declare function startOfDay(date: Date): Date;
96
+ /**
97
+ * Get the end of a day
98
+ */
99
+ declare function endOfDay(date: Date): Date;
100
+ /**
101
+ * Calculate difference in days between two dates
102
+ */
103
+ declare function diffInDays(start: Date, end: Date): number;
104
+ /**
105
+ * Calculate difference in months between two dates
106
+ */
107
+ declare function diffInMonths(start: Date, end: Date): number;
108
+ /**
109
+ * Calculate difference in years between two dates
110
+ */
111
+ declare function diffInYears(start: Date, end: Date): number;
112
+ declare const daysBetween: typeof diffInDays;
113
+ declare const monthsBetween: typeof diffInMonths;
114
+ /**
115
+ * Check if date is a weekday (Mon-Fri)
116
+ */
117
+ declare function isWeekday(date: Date): boolean;
118
+ /**
119
+ * Check if date is a weekend (Sat-Sun)
120
+ */
121
+ declare function isWeekend(date: Date): boolean;
122
+ /**
123
+ * Get day of week (0=Sunday, 6=Saturday)
124
+ */
125
+ declare function getDayOfWeek(date: Date): number;
126
+ /**
127
+ * Get day name
128
+ */
129
+ declare function getDayName(date: Date): string;
130
+ /**
131
+ * Get pay period for a given month and year
132
+ */
133
+ declare function getPayPeriod(month: number, year: number): PayPeriodInfo;
134
+ /**
135
+ * Get current pay period
136
+ */
137
+ declare function getCurrentPeriod(date?: Date): {
138
+ year: number;
139
+ month: number;
140
+ };
141
+ /**
142
+ * Get working days in a month
143
+ */
144
+ declare function getWorkingDaysInMonth(year: number, month: number): number;
145
+ /**
146
+ * Get total days in a month
147
+ */
148
+ declare function getDaysInMonth(year: number, month: number): number;
149
+ /**
150
+ * Calculate probation end date
151
+ */
152
+ declare function calculateProbationEnd(hireDate: Date, probationMonths: number): Date | null;
153
+ /**
154
+ * Check if employee is on probation
155
+ */
156
+ declare function isOnProbation(probationEndDate: Date | null | undefined, now?: Date): boolean;
157
+ /**
158
+ * Calculate years of service
159
+ */
160
+ declare function calculateYearsOfService(hireDate: Date, terminationDate?: Date | null): number;
161
+ /**
162
+ * Check if a date is within a range
163
+ */
164
+ declare function isDateInRange(date: Date, start: Date, end: Date): boolean;
165
+ /**
166
+ * Get date range for a pay period
167
+ */
168
+ declare function getPayPeriodDateRange(month: number, year: number): {
169
+ start: Date;
170
+ end: Date;
171
+ };
172
+ /**
173
+ * Format date for database storage
174
+ */
175
+ declare function formatDateForDB(date: Date): string;
176
+ /**
177
+ * Parse date from database
178
+ */
179
+ declare function parseDBDate(dateString: string): Date | null;
180
+ /**
181
+ * Format period as string (e.g., "01/2025")
182
+ */
183
+ declare function formatPeriod({ month, year }: {
184
+ month: number;
185
+ year: number;
186
+ }): string;
187
+ /**
188
+ * Parse period string back to object
189
+ */
190
+ declare function parsePeriod(periodString: string): {
191
+ month: number;
192
+ year: number;
193
+ };
194
+ /**
195
+ * Format month name
196
+ */
197
+ declare function getMonthName(month: number): string;
198
+ /**
199
+ * Format short month name
200
+ */
201
+ declare function getShortMonthName(month: number): string;
202
+ declare const _default$3: {
203
+ addDays: typeof addDays;
204
+ addMonths: typeof addMonths;
205
+ addYears: typeof addYears;
206
+ subDays: typeof subDays;
207
+ subMonths: typeof subMonths;
208
+ startOfMonth: typeof startOfMonth;
209
+ endOfMonth: typeof endOfMonth;
210
+ startOfYear: typeof startOfYear;
211
+ endOfYear: typeof endOfYear;
212
+ startOfDay: typeof startOfDay;
213
+ endOfDay: typeof endOfDay;
214
+ diffInDays: typeof diffInDays;
215
+ diffInMonths: typeof diffInMonths;
216
+ diffInYears: typeof diffInYears;
217
+ daysBetween: typeof diffInDays;
218
+ monthsBetween: typeof diffInMonths;
219
+ isWeekday: typeof isWeekday;
220
+ isWeekend: typeof isWeekend;
221
+ getDayOfWeek: typeof getDayOfWeek;
222
+ getDayName: typeof getDayName;
223
+ getPayPeriod: typeof getPayPeriod;
224
+ getCurrentPeriod: typeof getCurrentPeriod;
225
+ getWorkingDaysInMonth: typeof getWorkingDaysInMonth;
226
+ getDaysInMonth: typeof getDaysInMonth;
227
+ calculateProbationEnd: typeof calculateProbationEnd;
228
+ isOnProbation: typeof isOnProbation;
229
+ calculateYearsOfService: typeof calculateYearsOfService;
230
+ isDateInRange: typeof isDateInRange;
231
+ getPayPeriodDateRange: typeof getPayPeriodDateRange;
232
+ formatDateForDB: typeof formatDateForDB;
233
+ parseDBDate: typeof parseDBDate;
234
+ formatPeriod: typeof formatPeriod;
235
+ parsePeriod: typeof parsePeriod;
236
+ getMonthName: typeof getMonthName;
237
+ getShortMonthName: typeof getShortMonthName;
238
+ };
239
+
240
+ /**
241
+ * @classytic/payroll - Calculation Utilities
242
+ *
243
+ * Pure, functional, composable financial calculations
244
+ * No side effects, highly testable
245
+ */
246
+
247
+ /**
248
+ * Sum array of numbers
249
+ */
250
+ declare function sum(numbers: number[]): number;
251
+ /**
252
+ * Sum by property
253
+ */
254
+ declare function sumBy<T>(items: T[], getter: (item: T) => number): number;
255
+ /**
256
+ * Sum allowances
257
+ */
258
+ declare function sumAllowances(allowances: Array<{
259
+ amount: number;
260
+ }>): number;
261
+ /**
262
+ * Sum deductions
263
+ */
264
+ declare function sumDeductions(deductions: Array<{
265
+ amount: number;
266
+ }>): number;
267
+ /**
268
+ * Apply percentage to amount
269
+ */
270
+ declare function applyPercentage(amount: number, percentage: number): number;
271
+ /**
272
+ * Calculate percentage of total
273
+ */
274
+ declare function calculatePercentage(part: number, total: number): number;
275
+ /**
276
+ * Round to decimal places
277
+ */
278
+ declare function roundTo(value: number, decimals?: number): number;
279
+ /**
280
+ * Calculate gross salary from base and allowances
281
+ */
282
+ declare function calculateGross(baseAmount: number, allowances: Array<{
283
+ amount: number;
284
+ }>): number;
285
+ /**
286
+ * Calculate net salary from gross and deductions
287
+ */
288
+ declare function calculateNet(gross: number, deductions: Array<{
289
+ amount: number;
290
+ }>): number;
291
+ /**
292
+ * Calculate total compensation
293
+ */
294
+ declare function calculateTotalCompensation(baseAmount: number, allowances: Array<{
295
+ amount: number;
296
+ }>, deductions: Array<{
297
+ amount: number;
298
+ }>): {
299
+ gross: number;
300
+ net: number;
301
+ deductions: number;
302
+ };
303
+ /**
304
+ * Calculate allowance amount (handles percentage-based)
305
+ */
306
+ declare function calculateAllowanceAmount(allowance: Pick<Allowance, 'amount' | 'isPercentage' | 'value'>, baseAmount: number): number;
307
+ /**
308
+ * Calculate deduction amount (handles percentage-based)
309
+ */
310
+ declare function calculateDeductionAmount(deduction: Pick<Deduction, 'amount' | 'isPercentage' | 'value'>, baseAmount: number): number;
311
+ /**
312
+ * Calculate all allowances with their actual amounts
313
+ */
314
+ declare function calculateAllowances(allowances: Allowance[], baseAmount: number): Array<Allowance & {
315
+ calculatedAmount: number;
316
+ }>;
317
+ /**
318
+ * Calculate all deductions with their actual amounts
319
+ */
320
+ declare function calculateDeductions(deductions: Deduction[], baseAmount: number): Array<Deduction & {
321
+ calculatedAmount: number;
322
+ }>;
323
+ /**
324
+ * Calculate full compensation breakdown
325
+ */
326
+ declare function calculateCompensationBreakdown(compensation: Pick<Compensation, 'baseAmount' | 'allowances' | 'deductions'>): CompensationBreakdownResult;
327
+ /**
328
+ * Calculate pro-rating for mid-month hires
329
+ */
330
+ declare function calculateProRating(hireDate: Date, periodStart: Date, periodEnd: Date): ProRatingResult;
331
+ /**
332
+ * Apply pro-rating to an amount
333
+ */
334
+ declare function applyProRating(amount: number, proRating: ProRatingResult): number;
335
+ /**
336
+ * Calculate pro-rated salary
337
+ */
338
+ declare function calculateProRatedSalary(baseAmount: number, hireDate: Date, period: PayPeriodInfo): {
339
+ amount: number;
340
+ proRating: ProRatingResult;
341
+ };
342
+ /**
343
+ * Apply tax brackets to calculate tax
344
+ */
345
+ declare function applyTaxBrackets(amount: number, brackets: Array<{
346
+ min: number;
347
+ max: number;
348
+ rate: number;
349
+ }>): number;
350
+ /**
351
+ * Calculate tax with result
352
+ */
353
+ declare function calculateTax(amount: number, brackets: Array<{
354
+ min: number;
355
+ max: number;
356
+ rate: number;
357
+ }>): TaxCalculationResult;
358
+ /**
359
+ * Pipe functions left-to-right
360
+ * pipe(f, g, h)(x) === h(g(f(x)))
361
+ */
362
+ declare function pipe<T>(...fns: Array<(value: T) => T>): (value: T) => T;
363
+ /**
364
+ * Compose functions right-to-left
365
+ * compose(f, g, h)(x) === f(g(h(x)))
366
+ */
367
+ declare function compose<T>(...fns: Array<(value: T) => T>): (value: T) => T;
368
+ /**
369
+ * Create an allowance calculator factory
370
+ */
371
+ declare function createAllowanceCalculator(allowances: Allowance[]): (baseSalary: number) => Array<Allowance & {
372
+ calculatedAmount: number;
373
+ }>;
374
+ /**
375
+ * Create a deduction calculator factory
376
+ */
377
+ declare function createDeductionCalculator(deductions: Deduction[]): (baseSalary: number) => Array<Deduction & {
378
+ calculatedAmount: number;
379
+ }>;
380
+ /**
381
+ * Calculate overtime pay
382
+ */
383
+ declare function calculateOvertime(hourlyRate: number, overtimeHours: number, multiplier?: number): number;
384
+ /**
385
+ * Calculate hourly rate from monthly salary
386
+ */
387
+ declare function calculateHourlyRate(monthlySalary: number, hoursPerMonth?: number): number;
388
+ /**
389
+ * Calculate daily rate from monthly salary
390
+ */
391
+ declare function calculateDailyRate(monthlySalary: number, daysPerMonth?: number): number;
392
+ declare const _default$2: {
393
+ sum: typeof sum;
394
+ sumBy: typeof sumBy;
395
+ sumAllowances: typeof sumAllowances;
396
+ sumDeductions: typeof sumDeductions;
397
+ applyPercentage: typeof applyPercentage;
398
+ calculatePercentage: typeof calculatePercentage;
399
+ roundTo: typeof roundTo;
400
+ calculateGross: typeof calculateGross;
401
+ calculateNet: typeof calculateNet;
402
+ calculateTotalCompensation: typeof calculateTotalCompensation;
403
+ calculateAllowanceAmount: typeof calculateAllowanceAmount;
404
+ calculateDeductionAmount: typeof calculateDeductionAmount;
405
+ calculateAllowances: typeof calculateAllowances;
406
+ calculateDeductions: typeof calculateDeductions;
407
+ calculateCompensationBreakdown: typeof calculateCompensationBreakdown;
408
+ calculateProRating: typeof calculateProRating;
409
+ applyProRating: typeof applyProRating;
410
+ calculateProRatedSalary: typeof calculateProRatedSalary;
411
+ applyTaxBrackets: typeof applyTaxBrackets;
412
+ calculateTax: typeof calculateTax;
413
+ pipe: typeof pipe;
414
+ compose: typeof compose;
415
+ createAllowanceCalculator: typeof createAllowanceCalculator;
416
+ createDeductionCalculator: typeof createDeductionCalculator;
417
+ calculateOvertime: typeof calculateOvertime;
418
+ calculateHourlyRate: typeof calculateHourlyRate;
419
+ calculateDailyRate: typeof calculateDailyRate;
420
+ };
421
+
422
+ /**
423
+ * @classytic/payroll - Validation Utilities
424
+ *
425
+ * Fluent, composable, type-safe validation
426
+ * Clear semantics and helpful error messages
427
+ */
428
+
429
+ /**
430
+ * Check if employee is active
431
+ */
432
+ declare function isActive(employee: {
433
+ status?: EmployeeStatus;
434
+ }): boolean;
435
+ /**
436
+ * Check if employee is on leave
437
+ */
438
+ declare function isOnLeave(employee: {
439
+ status?: EmployeeStatus;
440
+ }): boolean;
441
+ /**
442
+ * Check if employee is suspended
443
+ */
444
+ declare function isSuspended(employee: {
445
+ status?: EmployeeStatus;
446
+ }): boolean;
447
+ /**
448
+ * Check if employee is terminated
449
+ */
450
+ declare function isTerminated(employee: {
451
+ status?: EmployeeStatus;
452
+ }): boolean;
453
+ /**
454
+ * Check if employee is employed (not terminated)
455
+ */
456
+ declare function isEmployed(employee: {
457
+ status?: EmployeeStatus;
458
+ }): boolean;
459
+ /**
460
+ * Check if employee can receive salary
461
+ */
462
+ declare function canReceiveSalary(employee: {
463
+ status?: EmployeeStatus;
464
+ compensation?: {
465
+ baseAmount?: number;
466
+ };
467
+ }): boolean;
468
+ /**
469
+ * Check if employment can be updated
470
+ */
471
+ declare function canUpdateEmployment(employee: {
472
+ status?: EmployeeStatus;
473
+ }): boolean;
474
+ /**
475
+ * Check if employee has valid compensation
476
+ */
477
+ declare function hasCompensation(employee: {
478
+ compensation?: {
479
+ baseAmount?: number;
480
+ };
481
+ }): boolean;
482
+ /**
483
+ * Check if compensation is valid
484
+ */
485
+ declare function isValidCompensation(compensation?: Compensation): boolean;
486
+ /**
487
+ * Check if bank details are valid
488
+ */
489
+ declare function isValidBankDetails(bankDetails?: BankDetails): boolean;
490
+ /**
491
+ * Check if employee is in probation
492
+ */
493
+ declare function isInProbation(employee: {
494
+ probationEndDate?: Date | null;
495
+ }, now?: Date): boolean;
496
+ /**
497
+ * Check if employee has completed probation
498
+ */
499
+ declare function hasCompletedProbation(employee: {
500
+ probationEndDate?: Date | null;
501
+ }, now?: Date): boolean;
502
+ /**
503
+ * Check if employee is eligible for bonus
504
+ */
505
+ declare function isEligibleForBonus(employee: {
506
+ status?: EmployeeStatus;
507
+ hireDate?: Date;
508
+ }, requiredMonths?: number): boolean;
509
+ /**
510
+ * Check if employee is eligible for payroll
511
+ */
512
+ declare function isEligibleForPayroll(employee: {
513
+ status?: EmployeeStatus;
514
+ compensation?: {
515
+ baseAmount?: number;
516
+ };
517
+ bankDetails?: BankDetails;
518
+ }): {
519
+ eligible: boolean;
520
+ reasons: string[];
521
+ };
522
+ /**
523
+ * Check if value is required
524
+ */
525
+ declare function required(fieldName: string): (value: unknown) => string | true;
526
+ /**
527
+ * Check minimum value
528
+ */
529
+ declare function min(minValue: number, fieldName: string): (value: number) => string | true;
530
+ /**
531
+ * Check maximum value
532
+ */
533
+ declare function max(maxValue: number, fieldName: string): (value: number) => string | true;
534
+ /**
535
+ * Check value is in range
536
+ */
537
+ declare function inRange(minValue: number, maxValue: number, fieldName: string): (value: number) => string | true;
538
+ /**
539
+ * Check value is positive
540
+ */
541
+ declare function isPositive(fieldName: string): (value: number) => string | true;
542
+ /**
543
+ * Check value is one of allowed values
544
+ */
545
+ declare function oneOf<T extends string>(allowedValues: readonly T[], fieldName: string): (value: T) => string | true;
546
+ /**
547
+ * Check if status is valid
548
+ */
549
+ declare function isValidStatus(value: string): value is EmployeeStatus;
550
+ /**
551
+ * Check if employment type is valid
552
+ */
553
+ declare function isValidEmploymentType(value: string): value is EmploymentType;
554
+ /**
555
+ * Compose multiple validators
556
+ */
557
+ declare function composeValidators<T>(...validators: Array<(value: T, data?: unknown) => string | true>): (value: T, data?: unknown) => string | true;
558
+ /**
559
+ * Create a validator from validation functions
560
+ */
561
+ declare function createValidator<T extends Record<string, unknown>>(validationFns: Record<string, (value: unknown, data: T) => string | true>): (data: T) => EmployeeValidationResult;
562
+ /**
563
+ * Validate required fields exist
564
+ */
565
+ declare function hasRequiredFields(obj: Record<string, unknown>, fields: string[]): {
566
+ valid: boolean;
567
+ missing: string[];
568
+ };
569
+ declare const minValue: typeof min;
570
+ declare const maxValue: typeof max;
571
+ declare const isInRange: typeof inRange;
572
+ declare const _default$1: {
573
+ isActive: typeof isActive;
574
+ isOnLeave: typeof isOnLeave;
575
+ isSuspended: typeof isSuspended;
576
+ isTerminated: typeof isTerminated;
577
+ isEmployed: typeof isEmployed;
578
+ canReceiveSalary: typeof canReceiveSalary;
579
+ canUpdateEmployment: typeof canUpdateEmployment;
580
+ hasCompensation: typeof hasCompensation;
581
+ isValidCompensation: typeof isValidCompensation;
582
+ isValidBankDetails: typeof isValidBankDetails;
583
+ isInProbation: typeof isInProbation;
584
+ hasCompletedProbation: typeof hasCompletedProbation;
585
+ isEligibleForBonus: typeof isEligibleForBonus;
586
+ isEligibleForPayroll: typeof isEligibleForPayroll;
587
+ required: typeof required;
588
+ min: typeof min;
589
+ max: typeof max;
590
+ inRange: typeof inRange;
591
+ isPositive: typeof isPositive;
592
+ oneOf: typeof oneOf;
593
+ isValidStatus: typeof isValidStatus;
594
+ isValidEmploymentType: typeof isValidEmploymentType;
595
+ composeValidators: typeof composeValidators;
596
+ createValidator: typeof createValidator;
597
+ hasRequiredFields: typeof hasRequiredFields;
598
+ };
599
+
600
+ /**
601
+ * @classytic/payroll - Query Builders
602
+ *
603
+ * Fluent API for building MongoDB queries
604
+ * Type-safe, chainable, beautiful
605
+ */
606
+
607
+ /**
608
+ * Convert string or ObjectId to ObjectId
609
+ */
610
+ declare function toObjectId(id: ObjectIdLike): Types.ObjectId;
611
+ /**
612
+ * Safely convert to ObjectId (returns null if invalid)
613
+ */
614
+ declare function safeToObjectId(id: unknown): Types.ObjectId | null;
615
+ /**
616
+ * Check if value is valid ObjectId
617
+ */
618
+ declare function isValidObjectId(value: unknown): boolean;
619
+ declare class QueryBuilder<T extends Record<string, unknown> = Record<string, unknown>> {
620
+ protected query: T;
621
+ constructor(initialQuery?: T);
622
+ /**
623
+ * Add where condition
624
+ */
625
+ where<K extends string>(field: K, value: unknown): this;
626
+ /**
627
+ * Add $in condition
628
+ */
629
+ whereIn<K extends string>(field: K, values: unknown[]): this;
630
+ /**
631
+ * Add $nin condition
632
+ */
633
+ whereNotIn<K extends string>(field: K, values: unknown[]): this;
634
+ /**
635
+ * Add $gte condition
636
+ */
637
+ whereGte<K extends string>(field: K, value: unknown): this;
638
+ /**
639
+ * Add $lte condition
640
+ */
641
+ whereLte<K extends string>(field: K, value: unknown): this;
642
+ /**
643
+ * Add $gt condition
644
+ */
645
+ whereGt<K extends string>(field: K, value: unknown): this;
646
+ /**
647
+ * Add $lt condition
648
+ */
649
+ whereLt<K extends string>(field: K, value: unknown): this;
650
+ /**
651
+ * Add between condition
652
+ */
653
+ whereBetween<K extends string>(field: K, start: unknown, end: unknown): this;
654
+ /**
655
+ * Add $exists condition
656
+ */
657
+ whereExists<K extends string>(field: K): this;
658
+ /**
659
+ * Add $exists: false condition
660
+ */
661
+ whereNotExists<K extends string>(field: K): this;
662
+ /**
663
+ * Add $ne condition
664
+ */
665
+ whereNot<K extends string>(field: K, value: unknown): this;
666
+ /**
667
+ * Add regex condition
668
+ */
669
+ whereRegex<K extends string>(field: K, pattern: string, flags?: string): this;
670
+ /**
671
+ * Merge another query
672
+ */
673
+ merge(otherQuery: Record<string, unknown>): this;
674
+ /**
675
+ * Build and return the query
676
+ */
677
+ build(): T;
678
+ }
679
+ declare class EmployeeQueryBuilder extends QueryBuilder {
680
+ /**
681
+ * Filter by organization
682
+ */
683
+ forOrganization(organizationId: ObjectIdLike): this;
684
+ /**
685
+ * Filter by user
686
+ */
687
+ forUser(userId: ObjectIdLike): this;
688
+ /**
689
+ * Filter by status(es)
690
+ */
691
+ withStatus(...statuses: EmployeeStatus[]): this;
692
+ /**
693
+ * Filter active employees
694
+ */
695
+ active(): this;
696
+ /**
697
+ * Filter employed employees (not terminated)
698
+ */
699
+ employed(): this;
700
+ /**
701
+ * Filter terminated employees
702
+ */
703
+ terminated(): this;
704
+ /**
705
+ * Filter by department
706
+ */
707
+ inDepartment(department: Department | string): this;
708
+ /**
709
+ * Filter by position
710
+ */
711
+ inPosition(position: string): this;
712
+ /**
713
+ * Filter by employment type
714
+ */
715
+ withEmploymentType(type: EmploymentType | string): this;
716
+ /**
717
+ * Filter by hire date (after)
718
+ */
719
+ hiredAfter(date: Date): this;
720
+ /**
721
+ * Filter by hire date (before)
722
+ */
723
+ hiredBefore(date: Date): this;
724
+ /**
725
+ * Filter by minimum salary
726
+ */
727
+ withMinSalary(amount: number): this;
728
+ /**
729
+ * Filter by maximum salary
730
+ */
731
+ withMaxSalary(amount: number): this;
732
+ /**
733
+ * Filter by salary range
734
+ */
735
+ withSalaryRange(min: number, max: number): this;
736
+ }
737
+ declare class PayrollQueryBuilder extends QueryBuilder {
738
+ /**
739
+ * Filter by organization
740
+ */
741
+ forOrganization(organizationId: ObjectIdLike): this;
742
+ /**
743
+ * Filter by employee
744
+ */
745
+ forEmployee(employeeId: ObjectIdLike): this;
746
+ /**
747
+ * Filter by period
748
+ */
749
+ forPeriod(month?: number, year?: number): this;
750
+ /**
751
+ * Filter by status(es)
752
+ */
753
+ withStatus(...statuses: PayrollStatus[]): this;
754
+ /**
755
+ * Filter paid records
756
+ */
757
+ paid(): this;
758
+ /**
759
+ * Filter pending records
760
+ */
761
+ pending(): this;
762
+ /**
763
+ * Filter by date range
764
+ */
765
+ inDateRange(start: Date, end: Date): this;
766
+ /**
767
+ * Filter exported records
768
+ */
769
+ exported(): this;
770
+ /**
771
+ * Filter not exported records
772
+ */
773
+ notExported(): this;
774
+ }
775
+ /**
776
+ * Create employee query builder
777
+ */
778
+ declare function employee(): EmployeeQueryBuilder;
779
+ /**
780
+ * Create payroll query builder
781
+ */
782
+ declare function payroll(): PayrollQueryBuilder;
783
+ /**
784
+ * Create generic query builder
785
+ */
786
+ declare function createQueryBuilder<T extends Record<string, unknown> = Record<string, unknown>>(initialQuery?: T): QueryBuilder<T>;
787
+ /**
788
+ * Build employee query from options
789
+ */
790
+ declare function buildEmployeeQuery(options: {
791
+ organizationId: ObjectIdLike;
792
+ userId?: ObjectIdLike;
793
+ statuses?: EmployeeStatus[];
794
+ department?: Department | string;
795
+ employmentType?: EmploymentType | string;
796
+ }): Record<string, unknown>;
797
+ /**
798
+ * Build payroll query from options
799
+ */
800
+ declare function buildPayrollQuery(options: {
801
+ employeeId?: ObjectIdLike;
802
+ organizationId?: ObjectIdLike;
803
+ month?: number;
804
+ year?: number;
805
+ statuses?: PayrollStatus[];
806
+ }): Record<string, unknown>;
807
+ /**
808
+ * Build aggregation pipeline from stages
809
+ */
810
+ declare function buildAggregationPipeline(...stages: Array<Record<string, unknown> | undefined | null>): Record<string, unknown>[];
811
+ /**
812
+ * Match stage
813
+ */
814
+ declare function matchStage(query: Record<string, unknown>): Record<string, unknown>;
815
+ /**
816
+ * Group stage
817
+ */
818
+ declare function groupStage(groupBy: string | null, aggregations: Record<string, unknown>): Record<string, unknown>;
819
+ /**
820
+ * Sort stage
821
+ */
822
+ declare function sortStage(sortBy: Record<string, 1 | -1>): Record<string, unknown>;
823
+ /**
824
+ * Limit stage
825
+ */
826
+ declare function limitStage(limit: number): Record<string, unknown>;
827
+ /**
828
+ * Skip stage
829
+ */
830
+ declare function skipStage(skip: number): Record<string, unknown>;
831
+ /**
832
+ * Project stage
833
+ */
834
+ declare function projectStage(fields: Record<string, unknown>): Record<string, unknown>;
835
+ /**
836
+ * Lookup stage
837
+ */
838
+ declare function lookupStage(options: {
839
+ from: string;
840
+ localField: string;
841
+ foreignField: string;
842
+ as: string;
843
+ }): Record<string, unknown>;
844
+ /**
845
+ * Unwind stage
846
+ */
847
+ declare function unwindStage(path: string, options?: {
848
+ preserveNullAndEmptyArrays?: boolean;
849
+ }): Record<string, unknown>;
850
+ declare const _default: {
851
+ toObjectId: typeof toObjectId;
852
+ safeToObjectId: typeof safeToObjectId;
853
+ isValidObjectId: typeof isValidObjectId;
854
+ QueryBuilder: typeof QueryBuilder;
855
+ EmployeeQueryBuilder: typeof EmployeeQueryBuilder;
856
+ PayrollQueryBuilder: typeof PayrollQueryBuilder;
857
+ employee: typeof employee;
858
+ payroll: typeof payroll;
859
+ createQueryBuilder: typeof createQueryBuilder;
860
+ buildEmployeeQuery: typeof buildEmployeeQuery;
861
+ buildPayrollQuery: typeof buildPayrollQuery;
862
+ buildAggregationPipeline: typeof buildAggregationPipeline;
863
+ matchStage: typeof matchStage;
864
+ groupStage: typeof groupStage;
865
+ sortStage: typeof sortStage;
866
+ limitStage: typeof limitStage;
867
+ skipStage: typeof skipStage;
868
+ projectStage: typeof projectStage;
869
+ lookupStage: typeof lookupStage;
870
+ unwindStage: typeof unwindStage;
871
+ };
872
+
873
+ export { EmployeeQueryBuilder, PayrollQueryBuilder, QueryBuilder, addDays, addMonths, addYears, applyPercentage, applyProRating, applyTaxBrackets, buildAggregationPipeline, buildEmployeeQuery, buildPayrollQuery, calculateAllowanceAmount, calculateAllowances, calculateCompensationBreakdown, calculateDailyRate, calculateDeductionAmount, calculateDeductions, calculateGross, calculateHourlyRate, calculateNet, calculateOvertime, calculatePercentage, calculateProRatedSalary, calculateProRating, calculateProbationEnd, calculateTax, calculateTotalCompensation, calculateYearsOfService, _default$2 as calculationUtils, canReceiveSalary, canUpdateEmployment, compose, composeValidators, createAllowanceCalculator, createChildLogger, createDeductionCalculator, createQueryBuilder, createSilentLogger, createValidator, _default$3 as dateUtils, daysBetween, diffInDays, diffInMonths, diffInYears, disableLogging, employee, enableLogging, endOfDay, endOfMonth, endOfYear, formatDateForDB, formatPeriod, getCurrentPeriod, getDayName, getDayOfWeek, getDaysInMonth, getLogger, getMonthName, getPayPeriod, getPayPeriodDateRange, getShortMonthName, getWorkingDaysInMonth, groupStage, hasCompensation, hasCompletedProbation, hasRequiredFields, inRange, isActive, isDateInRange, isEligibleForBonus, isEligibleForPayroll, isEmployed, isInProbation, isInRange, isLoggingEnabled, isOnLeave, isOnProbation, isPositive, isSuspended, isTerminated, isValidBankDetails, isValidCompensation, isValidEmploymentType, isValidObjectId, isValidStatus, isWeekday, isWeekend, limitStage, logger, lookupStage, matchStage, max, maxValue, min, minValue, monthsBetween, oneOf, parseDBDate, parsePeriod, payroll, pipe, projectStage, _default as queryBuilders, required, resetLogger, roundTo, safeToObjectId, setLogger, skipStage, sortStage, startOfDay, startOfMonth, startOfYear, subDays, subMonths, sum, sumAllowances, sumBy, sumDeductions, toObjectId, unwindStage, _default$1 as validationUtils };