@classytic/payroll 1.0.2 → 2.3.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.

Potentially problematic release.


This version of @classytic/payroll might be problematic. Click here for more details.

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