@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.

Potentially problematic release.


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

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,967 @@
1
+ import payroll from './payroll.js';
2
+ export { Payroll, PayrollBuilder, createPayrollInstance, getPayroll, resetPayroll } from './payroll.js';
3
+ import { n as HRMConfig, D as DeepPartial, s as Department, t as EmploymentType, u as OrgRole, j as PayrollRecordDocument, v as HttpError, w as ErrorCode, x as PaymentFrequency, y as Allowance, z as Deduction, C as Compensation, F as CompensationBreakdownResult } from './types-BSYyX2KJ.js';
4
+ export { A as AddAllowanceParams, c as AddDeductionParams, I as AllowanceType, Q as BankDetails, B as BulkPayrollResult, J as DeductionType, E as EmployeeDocument, G as EmployeeStatus, V as EmploymentHistoryEntry, m as ExportPayrollParams, N as HRMTransactionCategory, H as HireEmployeeParams, L as ListEmployeesParams, o as Logger, O as ObjectIdLike, q as OperationContext, Z as PayrollBreakdown, i as PayrollHistoryParams, P as PayrollInitConfig, r as PayrollInstance, Y as PayrollPeriod, X as PayrollStats, K as PayrollStatus, k as PayrollSummaryParams, l as PayrollSummaryResult, h as ProcessBulkPayrollParams, f as ProcessSalaryParams, g as ProcessSalaryResult, R as ReHireEmployeeParams, b as RemoveAllowanceParams, d as RemoveDeductionParams, S as SingleTenantConfig, T as TerminateEmployeeParams, M as TerminationReason, e as UpdateBankDetailsParams, U as UpdateEmploymentParams, a as UpdateSalaryParams, W as WorkSchedule } from './types-BSYyX2KJ.js';
5
+ export { allowanceSchema, bankDetailsSchema, compensationSchema, deductionSchema, employmentFields, employmentHistorySchema, payrollStatsSchema, workScheduleSchema } from './schemas/index.js';
6
+ import mongoose, { Model, Schema } from 'mongoose';
7
+ import { AttendanceInput } from './core/index.js';
8
+ export { Container, ContainerConfig, Err, ModelsContainer, Ok, Result, err, initializeContainer, isErr, isOk, map, mapErr, ok, unwrap, unwrapOr } from './core/index.js';
9
+ export { E as EventBus, a as PayrollEventMap, P as PayrollPluginDefinition, d as PluginContext, b as PluginManager, c as createEventBus } from './plugin-D9mOr3_d.js';
10
+ export { B as BatchPayrollFactory, C as CompensationService, a as EmployeeBuilder, E as EmployeeFactory, b as EmployeeService, P as PayrollFactory, c as PayrollService } from './index-CTjHlCzz.js';
11
+ export { EmployeeQueryBuilder, PayrollQueryBuilder, QueryBuilder, addDays, addMonths, addYears, applyPercentage, calculateGross, calculateNet, calculateProRating, canReceiveSalary, compose, createValidator, diffInDays, diffInMonths, disableLogging, employee, enableLogging, endOfMonth, endOfYear, formatDateForDB, getCurrentPeriod, getLogger, getPayPeriod, getWorkingDaysInMonth, inRange, isActive, isDateInRange, isEmployed, isLoggingEnabled, isOnProbation, isTerminated, logger, max, min, oneOf, payroll, pipe, required, setLogger, startOfMonth, startOfYear, sum, sumAllowances, sumBy, sumDeductions, toObjectId } from './utils/index.js';
12
+
13
+ /**
14
+ * @classytic/payroll - Enums
15
+ *
16
+ * Type-safe enum definitions with const assertions
17
+ * Single source of truth for all enum values
18
+ */
19
+
20
+ declare const EMPLOYMENT_TYPE: {
21
+ readonly FULL_TIME: "full_time";
22
+ readonly PART_TIME: "part_time";
23
+ readonly CONTRACT: "contract";
24
+ readonly INTERN: "intern";
25
+ readonly CONSULTANT: "consultant";
26
+ };
27
+ declare const EMPLOYEE_STATUS: {
28
+ readonly ACTIVE: "active";
29
+ readonly ON_LEAVE: "on_leave";
30
+ readonly SUSPENDED: "suspended";
31
+ readonly TERMINATED: "terminated";
32
+ };
33
+ declare const DEPARTMENT: {
34
+ readonly MANAGEMENT: "management";
35
+ readonly TRAINING: "training";
36
+ readonly SALES: "sales";
37
+ readonly OPERATIONS: "operations";
38
+ readonly SUPPORT: "support";
39
+ readonly HR: "hr";
40
+ readonly MAINTENANCE: "maintenance";
41
+ readonly MARKETING: "marketing";
42
+ readonly FINANCE: "finance";
43
+ readonly IT: "it";
44
+ };
45
+ declare const PAYMENT_FREQUENCY: {
46
+ readonly MONTHLY: "monthly";
47
+ readonly BI_WEEKLY: "bi_weekly";
48
+ readonly WEEKLY: "weekly";
49
+ readonly HOURLY: "hourly";
50
+ readonly DAILY: "daily";
51
+ };
52
+ declare const ALLOWANCE_TYPE: {
53
+ readonly HOUSING: "housing";
54
+ readonly TRANSPORT: "transport";
55
+ readonly MEAL: "meal";
56
+ readonly MOBILE: "mobile";
57
+ readonly MEDICAL: "medical";
58
+ readonly EDUCATION: "education";
59
+ readonly BONUS: "bonus";
60
+ readonly OTHER: "other";
61
+ };
62
+ declare const DEDUCTION_TYPE: {
63
+ readonly TAX: "tax";
64
+ readonly LOAN: "loan";
65
+ readonly ADVANCE: "advance";
66
+ readonly PROVIDENT_FUND: "provident_fund";
67
+ readonly INSURANCE: "insurance";
68
+ readonly ABSENCE: "absence";
69
+ readonly OTHER: "other";
70
+ };
71
+ declare const PAYROLL_STATUS: {
72
+ readonly PENDING: "pending";
73
+ readonly PROCESSING: "processing";
74
+ readonly PAID: "paid";
75
+ readonly FAILED: "failed";
76
+ readonly CANCELLED: "cancelled";
77
+ };
78
+ declare const TERMINATION_REASON: {
79
+ readonly RESIGNATION: "resignation";
80
+ readonly RETIREMENT: "retirement";
81
+ readonly TERMINATION: "termination";
82
+ readonly CONTRACT_END: "contract_end";
83
+ readonly MUTUAL_AGREEMENT: "mutual_agreement";
84
+ readonly OTHER: "other";
85
+ };
86
+ declare const HRM_TRANSACTION_CATEGORIES: {
87
+ readonly SALARY: "salary";
88
+ readonly BONUS: "bonus";
89
+ readonly COMMISSION: "commission";
90
+ readonly OVERTIME: "overtime";
91
+ readonly SEVERANCE: "severance";
92
+ };
93
+
94
+ /**
95
+ * @classytic/payroll - Configuration
96
+ *
97
+ * Centralized configuration with type safety
98
+ * Configurable defaults for different use cases
99
+ */
100
+
101
+ declare const HRM_CONFIG: HRMConfig;
102
+ /**
103
+ * Calculate tax based on annual income
104
+ */
105
+ declare function calculateTax(annualIncome: number, currency?: string): number;
106
+ /**
107
+ * Determine the appropriate organization role for an employee
108
+ */
109
+ declare function determineOrgRole(employmentData: {
110
+ department?: Department | string;
111
+ type?: EmploymentType | string;
112
+ position?: string;
113
+ }): OrgRole;
114
+ /**
115
+ * Merge configuration with defaults
116
+ */
117
+ declare function mergeConfig(customConfig: Partial<HRMConfig> | DeepPartial<HRMConfig> | undefined): HRMConfig;
118
+
119
+ /**
120
+ * @classytic/payroll - PayrollRecord Model
121
+ *
122
+ * Mongoose schema for payroll records with TTL and auto-export
123
+ */
124
+
125
+ declare const payrollRecordSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
126
+ timestamps: true;
127
+ }, {
128
+ organizationId: mongoose.Types.ObjectId;
129
+ userId: mongoose.Types.ObjectId;
130
+ employeeId: mongoose.Types.ObjectId;
131
+ period: {
132
+ month: number;
133
+ year: number;
134
+ startDate: NativeDate;
135
+ endDate: NativeDate;
136
+ payDate?: NativeDate | null | undefined;
137
+ };
138
+ status: "pending" | "processing" | "paid" | "failed" | "cancelled";
139
+ exported: boolean;
140
+ paymentMethod: "bank" | "cash" | "check" | "mobile" | "bkash" | "nagad" | "rocket";
141
+ breakdown: {
142
+ baseAmount: number;
143
+ allowances: mongoose.Types.DocumentArray<{
144
+ type: string;
145
+ amount: number;
146
+ taxable: boolean;
147
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
148
+ type: string;
149
+ amount: number;
150
+ taxable: boolean;
151
+ }> & {
152
+ type: string;
153
+ amount: number;
154
+ taxable: boolean;
155
+ }>;
156
+ deductions: mongoose.Types.DocumentArray<{
157
+ type: string;
158
+ amount: number;
159
+ description?: string | null | undefined;
160
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
161
+ type: string;
162
+ amount: number;
163
+ description?: string | null | undefined;
164
+ }> & {
165
+ type: string;
166
+ amount: number;
167
+ description?: string | null | undefined;
168
+ }>;
169
+ grossSalary: number;
170
+ netSalary: number;
171
+ taxableAmount: number;
172
+ taxAmount: number;
173
+ attendanceDeduction: number;
174
+ proRatedAmount: number;
175
+ workingDays?: number | null | undefined;
176
+ actualDays?: number | null | undefined;
177
+ };
178
+ metadata: any;
179
+ corrections: mongoose.Types.DocumentArray<{
180
+ correctedAt: NativeDate;
181
+ reason?: string | null | undefined;
182
+ previousAmount?: number | null | undefined;
183
+ newAmount?: number | null | undefined;
184
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
185
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
186
+ correctedAt: NativeDate;
187
+ reason?: string | null | undefined;
188
+ previousAmount?: number | null | undefined;
189
+ newAmount?: number | null | undefined;
190
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
191
+ }> & {
192
+ correctedAt: NativeDate;
193
+ reason?: string | null | undefined;
194
+ previousAmount?: number | null | undefined;
195
+ newAmount?: number | null | undefined;
196
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
197
+ }>;
198
+ notes?: string | null | undefined;
199
+ processedAt?: NativeDate | null | undefined;
200
+ processedBy?: mongoose.Types.ObjectId | null | undefined;
201
+ transactionId?: mongoose.Types.ObjectId | null | undefined;
202
+ exportedAt?: NativeDate | null | undefined;
203
+ paidAt?: NativeDate | null | undefined;
204
+ } & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, {
205
+ organizationId: mongoose.Types.ObjectId;
206
+ userId: mongoose.Types.ObjectId;
207
+ employeeId: mongoose.Types.ObjectId;
208
+ period: {
209
+ month: number;
210
+ year: number;
211
+ startDate: NativeDate;
212
+ endDate: NativeDate;
213
+ payDate?: NativeDate | null | undefined;
214
+ };
215
+ status: "pending" | "processing" | "paid" | "failed" | "cancelled";
216
+ exported: boolean;
217
+ paymentMethod: "bank" | "cash" | "check" | "mobile" | "bkash" | "nagad" | "rocket";
218
+ breakdown: {
219
+ baseAmount: number;
220
+ allowances: mongoose.Types.DocumentArray<{
221
+ type: string;
222
+ amount: number;
223
+ taxable: boolean;
224
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
225
+ type: string;
226
+ amount: number;
227
+ taxable: boolean;
228
+ }> & {
229
+ type: string;
230
+ amount: number;
231
+ taxable: boolean;
232
+ }>;
233
+ deductions: mongoose.Types.DocumentArray<{
234
+ type: string;
235
+ amount: number;
236
+ description?: string | null | undefined;
237
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
238
+ type: string;
239
+ amount: number;
240
+ description?: string | null | undefined;
241
+ }> & {
242
+ type: string;
243
+ amount: number;
244
+ description?: string | null | undefined;
245
+ }>;
246
+ grossSalary: number;
247
+ netSalary: number;
248
+ taxableAmount: number;
249
+ taxAmount: number;
250
+ attendanceDeduction: number;
251
+ proRatedAmount: number;
252
+ workingDays?: number | null | undefined;
253
+ actualDays?: number | null | undefined;
254
+ };
255
+ metadata: any;
256
+ corrections: mongoose.Types.DocumentArray<{
257
+ correctedAt: NativeDate;
258
+ reason?: string | null | undefined;
259
+ previousAmount?: number | null | undefined;
260
+ newAmount?: number | null | undefined;
261
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
262
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
263
+ correctedAt: NativeDate;
264
+ reason?: string | null | undefined;
265
+ previousAmount?: number | null | undefined;
266
+ newAmount?: number | null | undefined;
267
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
268
+ }> & {
269
+ correctedAt: NativeDate;
270
+ reason?: string | null | undefined;
271
+ previousAmount?: number | null | undefined;
272
+ newAmount?: number | null | undefined;
273
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
274
+ }>;
275
+ notes?: string | null | undefined;
276
+ processedAt?: NativeDate | null | undefined;
277
+ processedBy?: mongoose.Types.ObjectId | null | undefined;
278
+ transactionId?: mongoose.Types.ObjectId | null | undefined;
279
+ exportedAt?: NativeDate | null | undefined;
280
+ paidAt?: NativeDate | null | undefined;
281
+ } & mongoose.DefaultTimestampProps, {
282
+ id: string;
283
+ }, mongoose.ResolveSchemaOptions<{
284
+ timestamps: true;
285
+ }>> & Omit<{
286
+ organizationId: mongoose.Types.ObjectId;
287
+ userId: mongoose.Types.ObjectId;
288
+ employeeId: mongoose.Types.ObjectId;
289
+ period: {
290
+ month: number;
291
+ year: number;
292
+ startDate: NativeDate;
293
+ endDate: NativeDate;
294
+ payDate?: NativeDate | null | undefined;
295
+ };
296
+ status: "pending" | "processing" | "paid" | "failed" | "cancelled";
297
+ exported: boolean;
298
+ paymentMethod: "bank" | "cash" | "check" | "mobile" | "bkash" | "nagad" | "rocket";
299
+ breakdown: {
300
+ baseAmount: number;
301
+ allowances: mongoose.Types.DocumentArray<{
302
+ type: string;
303
+ amount: number;
304
+ taxable: boolean;
305
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
306
+ type: string;
307
+ amount: number;
308
+ taxable: boolean;
309
+ }> & {
310
+ type: string;
311
+ amount: number;
312
+ taxable: boolean;
313
+ }>;
314
+ deductions: mongoose.Types.DocumentArray<{
315
+ type: string;
316
+ amount: number;
317
+ description?: string | null | undefined;
318
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
319
+ type: string;
320
+ amount: number;
321
+ description?: string | null | undefined;
322
+ }> & {
323
+ type: string;
324
+ amount: number;
325
+ description?: string | null | undefined;
326
+ }>;
327
+ grossSalary: number;
328
+ netSalary: number;
329
+ taxableAmount: number;
330
+ taxAmount: number;
331
+ attendanceDeduction: number;
332
+ proRatedAmount: number;
333
+ workingDays?: number | null | undefined;
334
+ actualDays?: number | null | undefined;
335
+ };
336
+ metadata: any;
337
+ corrections: mongoose.Types.DocumentArray<{
338
+ correctedAt: NativeDate;
339
+ reason?: string | null | undefined;
340
+ previousAmount?: number | null | undefined;
341
+ newAmount?: number | null | undefined;
342
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
343
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
344
+ correctedAt: NativeDate;
345
+ reason?: string | null | undefined;
346
+ previousAmount?: number | null | undefined;
347
+ newAmount?: number | null | undefined;
348
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
349
+ }> & {
350
+ correctedAt: NativeDate;
351
+ reason?: string | null | undefined;
352
+ previousAmount?: number | null | undefined;
353
+ newAmount?: number | null | undefined;
354
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
355
+ }>;
356
+ notes?: string | null | undefined;
357
+ processedAt?: NativeDate | null | undefined;
358
+ processedBy?: mongoose.Types.ObjectId | null | undefined;
359
+ transactionId?: mongoose.Types.ObjectId | null | undefined;
360
+ exportedAt?: NativeDate | null | undefined;
361
+ paidAt?: NativeDate | null | undefined;
362
+ } & mongoose.DefaultTimestampProps & {
363
+ _id: mongoose.Types.ObjectId;
364
+ } & {
365
+ __v: number;
366
+ }, "id"> & {
367
+ id: string;
368
+ }, {
369
+ [path: string]: mongoose.SchemaDefinitionProperty<undefined, any, any>;
370
+ } | {
371
+ [x: string]: mongoose.SchemaDefinitionProperty<any, any, mongoose.Document<unknown, {}, {
372
+ organizationId: mongoose.Types.ObjectId;
373
+ userId: mongoose.Types.ObjectId;
374
+ employeeId: mongoose.Types.ObjectId;
375
+ period: {
376
+ month: number;
377
+ year: number;
378
+ startDate: NativeDate;
379
+ endDate: NativeDate;
380
+ payDate?: NativeDate | null | undefined;
381
+ };
382
+ status: "pending" | "processing" | "paid" | "failed" | "cancelled";
383
+ exported: boolean;
384
+ paymentMethod: "bank" | "cash" | "check" | "mobile" | "bkash" | "nagad" | "rocket";
385
+ breakdown: {
386
+ baseAmount: number;
387
+ allowances: mongoose.Types.DocumentArray<{
388
+ type: string;
389
+ amount: number;
390
+ taxable: boolean;
391
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
392
+ type: string;
393
+ amount: number;
394
+ taxable: boolean;
395
+ }> & {
396
+ type: string;
397
+ amount: number;
398
+ taxable: boolean;
399
+ }>;
400
+ deductions: mongoose.Types.DocumentArray<{
401
+ type: string;
402
+ amount: number;
403
+ description?: string | null | undefined;
404
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
405
+ type: string;
406
+ amount: number;
407
+ description?: string | null | undefined;
408
+ }> & {
409
+ type: string;
410
+ amount: number;
411
+ description?: string | null | undefined;
412
+ }>;
413
+ grossSalary: number;
414
+ netSalary: number;
415
+ taxableAmount: number;
416
+ taxAmount: number;
417
+ attendanceDeduction: number;
418
+ proRatedAmount: number;
419
+ workingDays?: number | null | undefined;
420
+ actualDays?: number | null | undefined;
421
+ };
422
+ metadata: any;
423
+ corrections: mongoose.Types.DocumentArray<{
424
+ correctedAt: NativeDate;
425
+ reason?: string | null | undefined;
426
+ previousAmount?: number | null | undefined;
427
+ newAmount?: number | null | undefined;
428
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
429
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
430
+ correctedAt: NativeDate;
431
+ reason?: string | null | undefined;
432
+ previousAmount?: number | null | undefined;
433
+ newAmount?: number | null | undefined;
434
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
435
+ }> & {
436
+ correctedAt: NativeDate;
437
+ reason?: string | null | undefined;
438
+ previousAmount?: number | null | undefined;
439
+ newAmount?: number | null | undefined;
440
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
441
+ }>;
442
+ notes?: string | null | undefined;
443
+ processedAt?: NativeDate | null | undefined;
444
+ processedBy?: mongoose.Types.ObjectId | null | undefined;
445
+ transactionId?: mongoose.Types.ObjectId | null | undefined;
446
+ exportedAt?: NativeDate | null | undefined;
447
+ paidAt?: NativeDate | null | undefined;
448
+ } & mongoose.DefaultTimestampProps, {
449
+ id: string;
450
+ }, mongoose.ResolveSchemaOptions<{
451
+ timestamps: true;
452
+ }>> & Omit<{
453
+ organizationId: mongoose.Types.ObjectId;
454
+ userId: mongoose.Types.ObjectId;
455
+ employeeId: mongoose.Types.ObjectId;
456
+ period: {
457
+ month: number;
458
+ year: number;
459
+ startDate: NativeDate;
460
+ endDate: NativeDate;
461
+ payDate?: NativeDate | null | undefined;
462
+ };
463
+ status: "pending" | "processing" | "paid" | "failed" | "cancelled";
464
+ exported: boolean;
465
+ paymentMethod: "bank" | "cash" | "check" | "mobile" | "bkash" | "nagad" | "rocket";
466
+ breakdown: {
467
+ baseAmount: number;
468
+ allowances: mongoose.Types.DocumentArray<{
469
+ type: string;
470
+ amount: number;
471
+ taxable: boolean;
472
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
473
+ type: string;
474
+ amount: number;
475
+ taxable: boolean;
476
+ }> & {
477
+ type: string;
478
+ amount: number;
479
+ taxable: boolean;
480
+ }>;
481
+ deductions: mongoose.Types.DocumentArray<{
482
+ type: string;
483
+ amount: number;
484
+ description?: string | null | undefined;
485
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
486
+ type: string;
487
+ amount: number;
488
+ description?: string | null | undefined;
489
+ }> & {
490
+ type: string;
491
+ amount: number;
492
+ description?: string | null | undefined;
493
+ }>;
494
+ grossSalary: number;
495
+ netSalary: number;
496
+ taxableAmount: number;
497
+ taxAmount: number;
498
+ attendanceDeduction: number;
499
+ proRatedAmount: number;
500
+ workingDays?: number | null | undefined;
501
+ actualDays?: number | null | undefined;
502
+ };
503
+ metadata: any;
504
+ corrections: mongoose.Types.DocumentArray<{
505
+ correctedAt: NativeDate;
506
+ reason?: string | null | undefined;
507
+ previousAmount?: number | null | undefined;
508
+ newAmount?: number | null | undefined;
509
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
510
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
511
+ correctedAt: NativeDate;
512
+ reason?: string | null | undefined;
513
+ previousAmount?: number | null | undefined;
514
+ newAmount?: number | null | undefined;
515
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
516
+ }> & {
517
+ correctedAt: NativeDate;
518
+ reason?: string | null | undefined;
519
+ previousAmount?: number | null | undefined;
520
+ newAmount?: number | null | undefined;
521
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
522
+ }>;
523
+ notes?: string | null | undefined;
524
+ processedAt?: NativeDate | null | undefined;
525
+ processedBy?: mongoose.Types.ObjectId | null | undefined;
526
+ transactionId?: mongoose.Types.ObjectId | null | undefined;
527
+ exportedAt?: NativeDate | null | undefined;
528
+ paidAt?: NativeDate | null | undefined;
529
+ } & mongoose.DefaultTimestampProps & {
530
+ _id: mongoose.Types.ObjectId;
531
+ } & {
532
+ __v: number;
533
+ }, "id"> & {
534
+ id: string;
535
+ }> | undefined;
536
+ }, {
537
+ organizationId: mongoose.Types.ObjectId;
538
+ userId: mongoose.Types.ObjectId;
539
+ employeeId: mongoose.Types.ObjectId;
540
+ period: {
541
+ month: number;
542
+ year: number;
543
+ startDate: NativeDate;
544
+ endDate: NativeDate;
545
+ payDate?: NativeDate | null | undefined;
546
+ };
547
+ status: "pending" | "processing" | "paid" | "failed" | "cancelled";
548
+ exported: boolean;
549
+ paymentMethod: "bank" | "cash" | "check" | "mobile" | "bkash" | "nagad" | "rocket";
550
+ breakdown: {
551
+ baseAmount: number;
552
+ allowances: mongoose.Types.DocumentArray<{
553
+ type: string;
554
+ amount: number;
555
+ taxable: boolean;
556
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
557
+ type: string;
558
+ amount: number;
559
+ taxable: boolean;
560
+ }> & {
561
+ type: string;
562
+ amount: number;
563
+ taxable: boolean;
564
+ }>;
565
+ deductions: mongoose.Types.DocumentArray<{
566
+ type: string;
567
+ amount: number;
568
+ description?: string | null | undefined;
569
+ }, mongoose.Types.Subdocument<mongoose.mongo.BSON.ObjectId, unknown, {
570
+ type: string;
571
+ amount: number;
572
+ description?: string | null | undefined;
573
+ }> & {
574
+ type: string;
575
+ amount: number;
576
+ description?: string | null | undefined;
577
+ }>;
578
+ grossSalary: number;
579
+ netSalary: number;
580
+ taxableAmount: number;
581
+ taxAmount: number;
582
+ attendanceDeduction: number;
583
+ proRatedAmount: number;
584
+ workingDays?: number | null | undefined;
585
+ actualDays?: number | null | undefined;
586
+ };
587
+ metadata: any;
588
+ corrections: mongoose.Types.DocumentArray<{
589
+ correctedAt: NativeDate;
590
+ reason?: string | null | undefined;
591
+ previousAmount?: number | null | undefined;
592
+ newAmount?: number | null | undefined;
593
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
594
+ } | {
595
+ correctedAt: NativeDate;
596
+ reason?: string | null | undefined;
597
+ previousAmount?: number | null | undefined;
598
+ newAmount?: number | null | undefined;
599
+ correctedBy?: string | null | undefined;
600
+ _id: string;
601
+ }, mongoose.Types.Subdocument<string | mongoose.mongo.BSON.ObjectId, unknown, {
602
+ correctedAt: NativeDate;
603
+ reason?: string | null | undefined;
604
+ previousAmount?: number | null | undefined;
605
+ newAmount?: number | null | undefined;
606
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
607
+ } | {
608
+ correctedAt: NativeDate;
609
+ reason?: string | null | undefined;
610
+ previousAmount?: number | null | undefined;
611
+ newAmount?: number | null | undefined;
612
+ correctedBy?: string | null | undefined;
613
+ _id: string;
614
+ }> & ({
615
+ correctedAt: NativeDate;
616
+ reason?: string | null | undefined;
617
+ previousAmount?: number | null | undefined;
618
+ newAmount?: number | null | undefined;
619
+ correctedBy?: mongoose.Types.ObjectId | null | undefined;
620
+ } | {
621
+ correctedAt: NativeDate;
622
+ reason?: string | null | undefined;
623
+ previousAmount?: number | null | undefined;
624
+ newAmount?: number | null | undefined;
625
+ correctedBy?: string | null | undefined;
626
+ _id: string;
627
+ })>;
628
+ notes?: string | null | undefined;
629
+ processedAt?: NativeDate | null | undefined;
630
+ processedBy?: mongoose.Types.ObjectId | null | undefined;
631
+ transactionId?: mongoose.Types.ObjectId | null | undefined;
632
+ exportedAt?: NativeDate | null | undefined;
633
+ paidAt?: NativeDate | null | undefined;
634
+ createdAt: NativeDate;
635
+ updatedAt: NativeDate;
636
+ } & {
637
+ _id: mongoose.Types.ObjectId;
638
+ } & {
639
+ __v: number;
640
+ }>;
641
+ interface PayrollRecordModel extends Model<PayrollRecordDocument> {
642
+ findByPeriod(organizationId: mongoose.Types.ObjectId, month: number, year: number): ReturnType<Model<PayrollRecordDocument>['find']>;
643
+ findByEmployee(employeeId: mongoose.Types.ObjectId, limit?: number): ReturnType<Model<PayrollRecordDocument>['find']>;
644
+ getSummary(organizationId: mongoose.Types.ObjectId, month?: number, year?: number): Promise<{
645
+ totalGross: number;
646
+ totalNet: number;
647
+ count: number;
648
+ paidCount: number;
649
+ }>;
650
+ getExpiringSoon(organizationId: mongoose.Types.ObjectId, daysBeforeExpiry?: number): ReturnType<Model<PayrollRecordDocument>['find']>;
651
+ }
652
+ /**
653
+ * Get or create PayrollRecord model
654
+ */
655
+ declare function getPayrollRecordModel(connection?: mongoose.Connection): PayrollRecordModel;
656
+
657
+ /**
658
+ * @classytic/payroll - Employee Plugin
659
+ *
660
+ * Mongoose plugin that adds HRM methods and virtuals to Employee schema
661
+ */
662
+
663
+ interface EmployeePluginOptions {
664
+ /** Require bank details for salary payment */
665
+ requireBankDetails?: boolean;
666
+ /** Field name for compensation */
667
+ compensationField?: string;
668
+ /** Field name for status */
669
+ statusField?: string;
670
+ /** Enable auto salary calculation on save */
671
+ autoCalculateSalary?: boolean;
672
+ }
673
+ /**
674
+ * Mongoose plugin that adds HRM functionality to Employee schema
675
+ *
676
+ * @example
677
+ * const employeeSchema = new Schema({
678
+ * ...employmentFields,
679
+ * // Custom fields
680
+ * });
681
+ *
682
+ * employeeSchema.plugin(employeePlugin);
683
+ */
684
+ declare function employeePlugin(schema: Schema, options?: EmployeePluginOptions): void;
685
+
686
+ /**
687
+ * @classytic/payroll - Error Handling
688
+ *
689
+ * Custom error classes with error codes and HTTP status
690
+ */
691
+
692
+ declare class PayrollError extends Error implements HttpError {
693
+ readonly code: ErrorCode;
694
+ readonly status: number;
695
+ readonly context?: Record<string, unknown>;
696
+ readonly timestamp: Date;
697
+ constructor(message: string, code?: ErrorCode, status?: number, context?: Record<string, unknown>);
698
+ toJSON(): Record<string, unknown>;
699
+ }
700
+ /**
701
+ * Not initialized error
702
+ */
703
+ declare class NotInitializedError extends PayrollError {
704
+ constructor(message?: string);
705
+ }
706
+ /**
707
+ * Employee not found error
708
+ */
709
+ declare class EmployeeNotFoundError extends PayrollError {
710
+ constructor(employeeId?: string, context?: Record<string, unknown>);
711
+ }
712
+ /**
713
+ * Duplicate payroll error
714
+ */
715
+ declare class DuplicatePayrollError extends PayrollError {
716
+ constructor(employeeId: string, month: number, year: number, context?: Record<string, unknown>);
717
+ }
718
+ /**
719
+ * Validation error
720
+ */
721
+ declare class ValidationError extends PayrollError {
722
+ readonly errors: string[];
723
+ constructor(errors: string | string[], context?: Record<string, unknown>);
724
+ }
725
+ /**
726
+ * Employee terminated error
727
+ */
728
+ declare class EmployeeTerminatedError extends PayrollError {
729
+ constructor(employeeId?: string, context?: Record<string, unknown>);
730
+ }
731
+ /**
732
+ * Not eligible error
733
+ */
734
+ declare class NotEligibleError extends PayrollError {
735
+ constructor(message: string, context?: Record<string, unknown>);
736
+ }
737
+
738
+ /**
739
+ * @classytic/payroll - Compensation Factory
740
+ *
741
+ * Clean compensation structure creation
742
+ * Presets for common compensation packages
743
+ */
744
+
745
+ interface CreateCompensationParams {
746
+ baseAmount: number;
747
+ frequency?: PaymentFrequency;
748
+ currency?: string;
749
+ allowances?: Array<{
750
+ type: Allowance['type'];
751
+ value: number;
752
+ isPercentage?: boolean;
753
+ name?: string;
754
+ taxable?: boolean;
755
+ }>;
756
+ deductions?: Array<{
757
+ type: Deduction['type'];
758
+ value: number;
759
+ isPercentage?: boolean;
760
+ name?: string;
761
+ auto?: boolean;
762
+ }>;
763
+ effectiveFrom?: Date;
764
+ }
765
+ declare class CompensationFactory {
766
+ /**
767
+ * Create compensation object
768
+ */
769
+ static create(params: CreateCompensationParams): Compensation;
770
+ /**
771
+ * Create allowance
772
+ */
773
+ static createAllowance(params: {
774
+ type: Allowance['type'];
775
+ value: number;
776
+ isPercentage?: boolean;
777
+ name?: string;
778
+ taxable?: boolean;
779
+ }, baseAmount?: number): Allowance;
780
+ /**
781
+ * Create deduction
782
+ */
783
+ static createDeduction(params: {
784
+ type: Deduction['type'];
785
+ value: number;
786
+ isPercentage?: boolean;
787
+ name?: string;
788
+ auto?: boolean;
789
+ }, baseAmount?: number): Deduction;
790
+ /**
791
+ * Update base amount (immutable)
792
+ */
793
+ static updateBaseAmount(compensation: Compensation, newAmount: number, effectiveFrom?: Date): Compensation;
794
+ /**
795
+ * Add allowance (immutable)
796
+ */
797
+ static addAllowance(compensation: Compensation, allowance: Parameters<typeof this.createAllowance>[0]): Compensation;
798
+ /**
799
+ * Remove allowance (immutable)
800
+ */
801
+ static removeAllowance(compensation: Compensation, allowanceType: Allowance['type']): Compensation;
802
+ /**
803
+ * Add deduction (immutable)
804
+ */
805
+ static addDeduction(compensation: Compensation, deduction: Parameters<typeof this.createDeduction>[0]): Compensation;
806
+ /**
807
+ * Remove deduction (immutable)
808
+ */
809
+ static removeDeduction(compensation: Compensation, deductionType: Deduction['type']): Compensation;
810
+ /**
811
+ * Calculate compensation breakdown
812
+ */
813
+ static calculateBreakdown(compensation: Compensation): CompensationBreakdownResult;
814
+ /**
815
+ * Apply salary increment (immutable)
816
+ */
817
+ static applyIncrement(compensation: Compensation, params: {
818
+ percentage?: number;
819
+ amount?: number;
820
+ effectiveFrom?: Date;
821
+ }): Compensation;
822
+ }
823
+ declare class CompensationBuilder {
824
+ private data;
825
+ /**
826
+ * Set base amount
827
+ */
828
+ withBase(amount: number, frequency?: PaymentFrequency, currency?: string): this;
829
+ /**
830
+ * Add allowance
831
+ */
832
+ addAllowance(type: Allowance['type'], value: number, isPercentage?: boolean, name?: string): this;
833
+ /**
834
+ * Add deduction
835
+ */
836
+ addDeduction(type: Deduction['type'], value: number, isPercentage?: boolean, name?: string): this;
837
+ /**
838
+ * Set effective date
839
+ */
840
+ effectiveFrom(date: Date): this;
841
+ /**
842
+ * Build compensation
843
+ */
844
+ build(): Compensation;
845
+ }
846
+
847
+ /**
848
+ * @classytic/payroll - Attendance Integration
849
+ *
850
+ * Native integration with @classytic/clockin.
851
+ * ClockIn is a peer dependency - attendance is core to payroll.
852
+ */
853
+
854
+ /**
855
+ * Get attendance for payroll calculation
856
+ *
857
+ * @example
858
+ * ```typescript
859
+ * import { getAttendance } from '@classytic/payroll';
860
+ *
861
+ * const attendance = await getAttendance(Attendance, {
862
+ * organizationId: org._id,
863
+ * employeeId: emp._id,
864
+ * month: 3,
865
+ * year: 2024,
866
+ * expectedDays: 22,
867
+ * });
868
+ *
869
+ * await payroll.processSalary({ employeeId, month: 3, year: 2024, attendance });
870
+ * ```
871
+ */
872
+ declare function getAttendance(AttendanceModel: Model<any>, params: {
873
+ organizationId: any;
874
+ employeeId: any;
875
+ month: number;
876
+ year: number;
877
+ expectedDays: number;
878
+ }): Promise<(AttendanceInput & {
879
+ absentDays: number;
880
+ overtimeDays: number;
881
+ }) | null>;
882
+ /**
883
+ * Get attendance for multiple employees (efficient batch operation)
884
+ *
885
+ * @example
886
+ * ```typescript
887
+ * const attendanceMap = await batchGetAttendance(Attendance, {
888
+ * organizationId: org._id,
889
+ * employeeIds: [emp1._id, emp2._id, emp3._id],
890
+ * month: 3,
891
+ * year: 2024,
892
+ * expectedDays: 22,
893
+ * });
894
+ *
895
+ * const emp1Attendance = attendanceMap.get(emp1._id.toString());
896
+ * ```
897
+ */
898
+ declare function batchGetAttendance(AttendanceModel: Model<any>, params: {
899
+ organizationId: any;
900
+ employeeIds: any[];
901
+ month: number;
902
+ year: number;
903
+ expectedDays: number;
904
+ }): Promise<Map<string, AttendanceInput>>;
905
+
906
+ /**
907
+ * @classytic/payroll - Holiday Management
908
+ *
909
+ * Simple holiday storage and retrieval.
910
+ * ONE way to manage holidays - no confusion.
911
+ */
912
+
913
+ /**
914
+ * Holiday document
915
+ */
916
+ interface Holiday {
917
+ organizationId?: any;
918
+ date: Date;
919
+ name: string;
920
+ type: 'public' | 'company' | 'religious';
921
+ paid: boolean;
922
+ }
923
+ /**
924
+ * Create holiday schema
925
+ *
926
+ * @example
927
+ * ```typescript
928
+ * import { createHolidaySchema } from '@classytic/payroll';
929
+ *
930
+ * // Multi-tenant
931
+ * const Holiday = model('Holiday', createHolidaySchema());
932
+ *
933
+ * // Single-tenant
934
+ * const Holiday = model('Holiday', createHolidaySchema({ singleTenant: true }));
935
+ * ```
936
+ */
937
+ declare function createHolidaySchema(options?: {
938
+ singleTenant?: boolean;
939
+ }): Schema;
940
+ /**
941
+ * Get holidays for a period
942
+ *
943
+ * @example
944
+ * ```typescript
945
+ * const holidays = await getHolidays(Holiday, {
946
+ * organizationId: org._id, // optional for single-tenant
947
+ * startDate: new Date('2024-03-01'),
948
+ * endDate: new Date('2024-03-31'),
949
+ * });
950
+ * ```
951
+ */
952
+ declare function getHolidays(HolidayModel: Model<any>, params: {
953
+ organizationId?: any;
954
+ startDate: Date;
955
+ endDate: Date;
956
+ }): Promise<Date[]>;
957
+
958
+ /**
959
+ * @classytic/payroll
960
+ *
961
+ * Enterprise-grade HRM and Payroll Management for MongoDB/Mongoose
962
+ * Clean, pluggable, multi-tenant architecture
963
+ *
964
+ * @packageDocumentation
965
+ */
966
+
967
+ export { ALLOWANCE_TYPE, Allowance, Compensation, CompensationBuilder, CompensationFactory, DEDUCTION_TYPE, DEPARTMENT, Deduction, DeepPartial, Department, DuplicatePayrollError, EMPLOYEE_STATUS, EMPLOYMENT_TYPE, EmployeeNotFoundError, type EmployeePluginOptions, EmployeeTerminatedError, EmploymentType, HRMConfig, HRM_CONFIG, HRM_TRANSACTION_CATEGORIES, type Holiday, NotEligibleError, NotInitializedError, PAYMENT_FREQUENCY, PAYROLL_STATUS, PaymentFrequency, PayrollError, PayrollRecordDocument, type PayrollRecordModel, TERMINATION_REASON, ValidationError, batchGetAttendance, calculateTax, createHolidaySchema, payroll as default, determineOrgRole, employeePlugin, getAttendance, getHolidays, getPayrollRecordModel, mergeConfig, payroll as payrollInstance, payrollRecordSchema };