@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.
- package/README.md +168 -489
- package/dist/core/index.d.ts +480 -0
- package/dist/core/index.js +971 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index-CTjHlCzz.d.ts +721 -0
- package/dist/index.d.ts +967 -0
- package/dist/index.js +4352 -0
- package/dist/index.js.map +1 -0
- package/dist/payroll.d.ts +233 -0
- package/dist/payroll.js +2103 -0
- package/dist/payroll.js.map +1 -0
- package/dist/plugin-D9mOr3_d.d.ts +333 -0
- package/dist/schemas/index.d.ts +2869 -0
- package/dist/schemas/index.js +440 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +1696 -0
- package/dist/services/index.js.map +1 -0
- package/dist/types-BSYyX2KJ.d.ts +671 -0
- package/dist/utils/index.d.ts +873 -0
- package/dist/utils/index.js +1046 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +54 -37
- package/dist/types/config.d.ts +0 -162
- package/dist/types/core/compensation.manager.d.ts +0 -54
- package/dist/types/core/employment.manager.d.ts +0 -49
- package/dist/types/core/payroll.manager.d.ts +0 -60
- package/dist/types/enums.d.ts +0 -117
- package/dist/types/factories/compensation.factory.d.ts +0 -196
- package/dist/types/factories/employee.factory.d.ts +0 -149
- package/dist/types/factories/payroll.factory.d.ts +0 -319
- package/dist/types/hrm.orchestrator.d.ts +0 -47
- package/dist/types/index.d.ts +0 -20
- package/dist/types/init.d.ts +0 -30
- package/dist/types/models/payroll-record.model.d.ts +0 -3
- package/dist/types/plugins/employee.plugin.d.ts +0 -2
- package/dist/types/schemas/employment.schema.d.ts +0 -959
- package/dist/types/services/compensation.service.d.ts +0 -94
- package/dist/types/services/employee.service.d.ts +0 -28
- package/dist/types/services/payroll.service.d.ts +0 -30
- package/dist/types/utils/calculation.utils.d.ts +0 -26
- package/dist/types/utils/date.utils.d.ts +0 -35
- package/dist/types/utils/logger.d.ts +0 -12
- package/dist/types/utils/query-builders.d.ts +0 -83
- package/dist/types/utils/validation.utils.d.ts +0 -33
- package/payroll.d.ts +0 -241
- package/src/config.js +0 -177
- package/src/core/compensation.manager.js +0 -242
- package/src/core/employment.manager.js +0 -224
- package/src/core/payroll.manager.js +0 -499
- package/src/enums.js +0 -141
- package/src/factories/compensation.factory.js +0 -198
- package/src/factories/employee.factory.js +0 -173
- package/src/factories/payroll.factory.js +0 -413
- package/src/hrm.orchestrator.js +0 -139
- package/src/index.js +0 -172
- package/src/init.js +0 -62
- package/src/models/payroll-record.model.js +0 -126
- package/src/plugins/employee.plugin.js +0 -164
- package/src/schemas/employment.schema.js +0 -126
- package/src/services/compensation.service.js +0 -231
- package/src/services/employee.service.js +0 -162
- package/src/services/payroll.service.js +0 -213
- package/src/utils/calculation.utils.js +0 -91
- package/src/utils/date.utils.js +0 -120
- package/src/utils/logger.js +0 -36
- package/src/utils/query-builders.js +0 -185
- package/src/utils/validation.utils.js +0 -122
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
import { Model, ClientSession } from 'mongoose';
|
|
2
|
+
import { O as ObjectIdLike, t as EmploymentType, s as Department, W as WorkSchedule, x as PaymentFrequency, y as Allowance, z as Deduction, Q as BankDetails, C as Compensation, M as TerminationReason, _ as PaymentMethod, Y as PayrollPeriod, Z as PayrollBreakdown, E as EmployeeDocument, G as EmployeeStatus, q as OperationContext, j as PayrollRecordDocument, F as CompensationBreakdownResult } from './types-BSYyX2KJ.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @classytic/payroll - Employee Factory
|
|
6
|
+
*
|
|
7
|
+
* Clean object creation for employee documents
|
|
8
|
+
* Builder pattern for fluent API
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface CreateEmployeeParams {
|
|
12
|
+
userId: ObjectIdLike;
|
|
13
|
+
organizationId: ObjectIdLike;
|
|
14
|
+
employment: {
|
|
15
|
+
employeeId?: string;
|
|
16
|
+
type?: EmploymentType;
|
|
17
|
+
department?: Department | string;
|
|
18
|
+
position: string;
|
|
19
|
+
hireDate?: Date;
|
|
20
|
+
probationMonths?: number;
|
|
21
|
+
workSchedule?: WorkSchedule;
|
|
22
|
+
};
|
|
23
|
+
compensation: {
|
|
24
|
+
baseAmount: number;
|
|
25
|
+
frequency?: PaymentFrequency;
|
|
26
|
+
currency?: string;
|
|
27
|
+
allowances?: Array<Partial<Allowance>>;
|
|
28
|
+
deductions?: Array<Partial<Deduction>>;
|
|
29
|
+
};
|
|
30
|
+
bankDetails?: BankDetails;
|
|
31
|
+
}
|
|
32
|
+
interface EmployeeData {
|
|
33
|
+
userId: ObjectIdLike;
|
|
34
|
+
organizationId: ObjectIdLike;
|
|
35
|
+
employeeId: string;
|
|
36
|
+
employmentType: EmploymentType;
|
|
37
|
+
status: 'active';
|
|
38
|
+
department?: Department;
|
|
39
|
+
position: string;
|
|
40
|
+
hireDate: Date;
|
|
41
|
+
probationEndDate: Date | null;
|
|
42
|
+
compensation: Compensation;
|
|
43
|
+
workSchedule: WorkSchedule;
|
|
44
|
+
bankDetails: BankDetails;
|
|
45
|
+
payrollStats: {
|
|
46
|
+
totalPaid: number;
|
|
47
|
+
paymentsThisYear: number;
|
|
48
|
+
averageMonthly: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
interface TerminationData {
|
|
52
|
+
terminatedAt: Date;
|
|
53
|
+
terminationReason: TerminationReason;
|
|
54
|
+
terminationNotes?: string;
|
|
55
|
+
terminatedBy: {
|
|
56
|
+
userId?: ObjectIdLike;
|
|
57
|
+
name?: string;
|
|
58
|
+
role?: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
declare class EmployeeFactory {
|
|
62
|
+
/**
|
|
63
|
+
* Create employee data object
|
|
64
|
+
*/
|
|
65
|
+
static create(params: CreateEmployeeParams): EmployeeData;
|
|
66
|
+
/**
|
|
67
|
+
* Create compensation object
|
|
68
|
+
*/
|
|
69
|
+
static createCompensation(params: {
|
|
70
|
+
baseAmount: number;
|
|
71
|
+
frequency?: PaymentFrequency;
|
|
72
|
+
currency?: string;
|
|
73
|
+
allowances?: Array<Partial<Allowance>>;
|
|
74
|
+
deductions?: Array<Partial<Deduction>>;
|
|
75
|
+
}): Compensation;
|
|
76
|
+
/**
|
|
77
|
+
* Create allowance object
|
|
78
|
+
*/
|
|
79
|
+
static createAllowance(params: {
|
|
80
|
+
type: Allowance['type'];
|
|
81
|
+
amount: number;
|
|
82
|
+
name?: string;
|
|
83
|
+
isPercentage?: boolean;
|
|
84
|
+
taxable?: boolean;
|
|
85
|
+
recurring?: boolean;
|
|
86
|
+
}): Allowance;
|
|
87
|
+
/**
|
|
88
|
+
* Create deduction object
|
|
89
|
+
*/
|
|
90
|
+
static createDeduction(params: {
|
|
91
|
+
type: Deduction['type'];
|
|
92
|
+
amount: number;
|
|
93
|
+
name?: string;
|
|
94
|
+
isPercentage?: boolean;
|
|
95
|
+
auto?: boolean;
|
|
96
|
+
recurring?: boolean;
|
|
97
|
+
description?: string;
|
|
98
|
+
}): Deduction;
|
|
99
|
+
/**
|
|
100
|
+
* Default work schedule
|
|
101
|
+
*/
|
|
102
|
+
static defaultWorkSchedule(): WorkSchedule;
|
|
103
|
+
/**
|
|
104
|
+
* Create termination data
|
|
105
|
+
*/
|
|
106
|
+
static createTermination(params: {
|
|
107
|
+
reason: TerminationReason;
|
|
108
|
+
date?: Date;
|
|
109
|
+
notes?: string;
|
|
110
|
+
context?: {
|
|
111
|
+
userId?: ObjectIdLike;
|
|
112
|
+
userName?: string;
|
|
113
|
+
userRole?: string;
|
|
114
|
+
};
|
|
115
|
+
}): TerminationData;
|
|
116
|
+
}
|
|
117
|
+
declare class EmployeeBuilder {
|
|
118
|
+
private data;
|
|
119
|
+
/**
|
|
120
|
+
* Set user ID
|
|
121
|
+
*/
|
|
122
|
+
forUser(userId: ObjectIdLike): this;
|
|
123
|
+
/**
|
|
124
|
+
* Set organization ID
|
|
125
|
+
*/
|
|
126
|
+
inOrganization(organizationId: ObjectIdLike): this;
|
|
127
|
+
/**
|
|
128
|
+
* Set employee ID
|
|
129
|
+
*/
|
|
130
|
+
withEmployeeId(employeeId: string): this;
|
|
131
|
+
/**
|
|
132
|
+
* Set department
|
|
133
|
+
*/
|
|
134
|
+
inDepartment(department: Department): this;
|
|
135
|
+
/**
|
|
136
|
+
* Set position
|
|
137
|
+
*/
|
|
138
|
+
asPosition(position: string): this;
|
|
139
|
+
/**
|
|
140
|
+
* Set employment type
|
|
141
|
+
*/
|
|
142
|
+
withEmploymentType(type: EmploymentType): this;
|
|
143
|
+
/**
|
|
144
|
+
* Set hire date
|
|
145
|
+
*/
|
|
146
|
+
hiredOn(date: Date): this;
|
|
147
|
+
/**
|
|
148
|
+
* Set probation period
|
|
149
|
+
*/
|
|
150
|
+
withProbation(months: number): this;
|
|
151
|
+
/**
|
|
152
|
+
* Set work schedule
|
|
153
|
+
*/
|
|
154
|
+
withSchedule(schedule: WorkSchedule): this;
|
|
155
|
+
/**
|
|
156
|
+
* Set base salary
|
|
157
|
+
*/
|
|
158
|
+
withBaseSalary(amount: number, frequency?: PaymentFrequency, currency?: string): this;
|
|
159
|
+
/**
|
|
160
|
+
* Add allowance
|
|
161
|
+
*/
|
|
162
|
+
addAllowance(type: Allowance['type'], amount: number, options?: {
|
|
163
|
+
taxable?: boolean;
|
|
164
|
+
recurring?: boolean;
|
|
165
|
+
}): this;
|
|
166
|
+
/**
|
|
167
|
+
* Add deduction
|
|
168
|
+
*/
|
|
169
|
+
addDeduction(type: Deduction['type'], amount: number, options?: {
|
|
170
|
+
auto?: boolean;
|
|
171
|
+
recurring?: boolean;
|
|
172
|
+
description?: string;
|
|
173
|
+
}): this;
|
|
174
|
+
/**
|
|
175
|
+
* Set bank details
|
|
176
|
+
*/
|
|
177
|
+
withBankDetails(bankDetails: BankDetails): this;
|
|
178
|
+
/**
|
|
179
|
+
* Build employee data
|
|
180
|
+
*/
|
|
181
|
+
build(): EmployeeData;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @classytic/payroll - Payroll Factory
|
|
186
|
+
*
|
|
187
|
+
* Clean object creation for payroll records
|
|
188
|
+
* Immutable operations and builder pattern
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
interface CreatePayrollParams {
|
|
192
|
+
employeeId: ObjectIdLike;
|
|
193
|
+
organizationId: ObjectIdLike;
|
|
194
|
+
baseAmount: number;
|
|
195
|
+
allowances?: Array<{
|
|
196
|
+
type: string;
|
|
197
|
+
amount: number;
|
|
198
|
+
taxable?: boolean;
|
|
199
|
+
}>;
|
|
200
|
+
deductions?: Array<{
|
|
201
|
+
type: string;
|
|
202
|
+
amount: number;
|
|
203
|
+
description?: string;
|
|
204
|
+
}>;
|
|
205
|
+
period?: {
|
|
206
|
+
month?: number;
|
|
207
|
+
year?: number;
|
|
208
|
+
};
|
|
209
|
+
metadata?: {
|
|
210
|
+
currency?: string;
|
|
211
|
+
paymentMethod?: PaymentMethod;
|
|
212
|
+
notes?: string;
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
interface PayrollData {
|
|
216
|
+
employeeId: ObjectIdLike;
|
|
217
|
+
organizationId: ObjectIdLike;
|
|
218
|
+
period: PayrollPeriod;
|
|
219
|
+
breakdown: PayrollBreakdown;
|
|
220
|
+
status: 'pending';
|
|
221
|
+
processedAt: null;
|
|
222
|
+
paidAt: null;
|
|
223
|
+
metadata: {
|
|
224
|
+
currency: string;
|
|
225
|
+
paymentMethod?: PaymentMethod;
|
|
226
|
+
notes?: string;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
declare class PayrollFactory {
|
|
230
|
+
/**
|
|
231
|
+
* Create payroll data object
|
|
232
|
+
*/
|
|
233
|
+
static create(params: CreatePayrollParams): PayrollData;
|
|
234
|
+
/**
|
|
235
|
+
* Create pay period
|
|
236
|
+
*/
|
|
237
|
+
static createPeriod(params: {
|
|
238
|
+
month?: number;
|
|
239
|
+
year?: number;
|
|
240
|
+
payDate?: Date;
|
|
241
|
+
}): PayrollPeriod;
|
|
242
|
+
/**
|
|
243
|
+
* Calculate allowances from base amount
|
|
244
|
+
*/
|
|
245
|
+
static calculateAllowances(baseAmount: number, allowances: Array<{
|
|
246
|
+
type: string;
|
|
247
|
+
amount: number;
|
|
248
|
+
taxable?: boolean;
|
|
249
|
+
isPercentage?: boolean;
|
|
250
|
+
value?: number;
|
|
251
|
+
}>): Array<{
|
|
252
|
+
type: string;
|
|
253
|
+
amount: number;
|
|
254
|
+
taxable: boolean;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* Calculate deductions from base amount
|
|
258
|
+
*/
|
|
259
|
+
static calculateDeductions(baseAmount: number, deductions: Array<{
|
|
260
|
+
type: string;
|
|
261
|
+
amount: number;
|
|
262
|
+
description?: string;
|
|
263
|
+
isPercentage?: boolean;
|
|
264
|
+
value?: number;
|
|
265
|
+
}>): Array<{
|
|
266
|
+
type: string;
|
|
267
|
+
amount: number;
|
|
268
|
+
description?: string;
|
|
269
|
+
}>;
|
|
270
|
+
/**
|
|
271
|
+
* Create bonus object
|
|
272
|
+
*/
|
|
273
|
+
static createBonus(params: {
|
|
274
|
+
type: string;
|
|
275
|
+
amount: number;
|
|
276
|
+
reason: string;
|
|
277
|
+
approvedBy?: ObjectIdLike;
|
|
278
|
+
}): {
|
|
279
|
+
type: string;
|
|
280
|
+
amount: number;
|
|
281
|
+
reason: string;
|
|
282
|
+
approvedBy?: ObjectIdLike;
|
|
283
|
+
approvedAt: Date;
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Mark payroll as paid (immutable)
|
|
287
|
+
* Sets both top-level transactionId and metadata for compatibility
|
|
288
|
+
*/
|
|
289
|
+
static markAsPaid<T extends {
|
|
290
|
+
status: string;
|
|
291
|
+
paidAt?: Date | null;
|
|
292
|
+
processedAt?: Date | null;
|
|
293
|
+
transactionId?: unknown;
|
|
294
|
+
metadata?: Record<string, unknown>;
|
|
295
|
+
}>(payroll: T, params?: {
|
|
296
|
+
paidAt?: Date;
|
|
297
|
+
transactionId?: ObjectIdLike;
|
|
298
|
+
paymentMethod?: PaymentMethod;
|
|
299
|
+
}): T & {
|
|
300
|
+
status: 'paid';
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Mark payroll as processed (immutable)
|
|
304
|
+
*/
|
|
305
|
+
static markAsProcessed<T extends {
|
|
306
|
+
status: string;
|
|
307
|
+
processedAt: Date | null;
|
|
308
|
+
}>(payroll: T, params?: {
|
|
309
|
+
processedAt?: Date;
|
|
310
|
+
}): T & {
|
|
311
|
+
status: 'processing';
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
declare class BatchPayrollFactory {
|
|
315
|
+
/**
|
|
316
|
+
* Create payroll records for multiple employees
|
|
317
|
+
*/
|
|
318
|
+
static createBatch(employees: Array<{
|
|
319
|
+
_id: ObjectIdLike;
|
|
320
|
+
organizationId: ObjectIdLike;
|
|
321
|
+
compensation: Compensation;
|
|
322
|
+
}>, params: {
|
|
323
|
+
month: number;
|
|
324
|
+
year: number;
|
|
325
|
+
organizationId?: ObjectIdLike;
|
|
326
|
+
}): PayrollData[];
|
|
327
|
+
/**
|
|
328
|
+
* Calculate total payroll amounts
|
|
329
|
+
*/
|
|
330
|
+
static calculateTotalPayroll(payrolls: Array<{
|
|
331
|
+
breakdown: PayrollBreakdown;
|
|
332
|
+
}>): {
|
|
333
|
+
count: number;
|
|
334
|
+
totalGross: number;
|
|
335
|
+
totalNet: number;
|
|
336
|
+
totalAllowances: number;
|
|
337
|
+
totalDeductions: number;
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* @classytic/payroll - Employee Service
|
|
343
|
+
*
|
|
344
|
+
* High-level employee operations with dependency injection
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
declare class EmployeeService {
|
|
348
|
+
private readonly EmployeeModel;
|
|
349
|
+
constructor(EmployeeModel: Model<EmployeeDocument>);
|
|
350
|
+
/**
|
|
351
|
+
* Find employee by ID
|
|
352
|
+
*/
|
|
353
|
+
findById(employeeId: ObjectIdLike, options?: {
|
|
354
|
+
session?: ClientSession;
|
|
355
|
+
populate?: boolean;
|
|
356
|
+
}): Promise<EmployeeDocument | null>;
|
|
357
|
+
/**
|
|
358
|
+
* Find employee by user and organization
|
|
359
|
+
*/
|
|
360
|
+
findByUserId(userId: ObjectIdLike, organizationId: ObjectIdLike, options?: {
|
|
361
|
+
session?: ClientSession;
|
|
362
|
+
}): Promise<EmployeeDocument | null>;
|
|
363
|
+
/**
|
|
364
|
+
* Find active employees in organization
|
|
365
|
+
*/
|
|
366
|
+
findActive(organizationId: ObjectIdLike, options?: {
|
|
367
|
+
session?: ClientSession;
|
|
368
|
+
projection?: Record<string, number>;
|
|
369
|
+
}): Promise<EmployeeDocument[]>;
|
|
370
|
+
/**
|
|
371
|
+
* Find employed employees (not terminated)
|
|
372
|
+
*/
|
|
373
|
+
findEmployed(organizationId: ObjectIdLike, options?: {
|
|
374
|
+
session?: ClientSession;
|
|
375
|
+
projection?: Record<string, number>;
|
|
376
|
+
}): Promise<EmployeeDocument[]>;
|
|
377
|
+
/**
|
|
378
|
+
* Find employees by department
|
|
379
|
+
*/
|
|
380
|
+
findByDepartment(organizationId: ObjectIdLike, department: Department, options?: {
|
|
381
|
+
session?: ClientSession;
|
|
382
|
+
}): Promise<EmployeeDocument[]>;
|
|
383
|
+
/**
|
|
384
|
+
* Find employees eligible for payroll
|
|
385
|
+
*/
|
|
386
|
+
findEligibleForPayroll(organizationId: ObjectIdLike, options?: {
|
|
387
|
+
session?: ClientSession;
|
|
388
|
+
}): Promise<EmployeeDocument[]>;
|
|
389
|
+
/**
|
|
390
|
+
* Create new employee
|
|
391
|
+
*/
|
|
392
|
+
create(params: CreateEmployeeParams, options?: {
|
|
393
|
+
session?: ClientSession;
|
|
394
|
+
}): Promise<EmployeeDocument>;
|
|
395
|
+
/**
|
|
396
|
+
* Update employee status
|
|
397
|
+
*/
|
|
398
|
+
updateStatus(employeeId: ObjectIdLike, status: EmployeeStatus, context?: OperationContext, options?: {
|
|
399
|
+
session?: ClientSession;
|
|
400
|
+
}): Promise<EmployeeDocument>;
|
|
401
|
+
/**
|
|
402
|
+
* Update employee compensation
|
|
403
|
+
*
|
|
404
|
+
* NOTE: This merges the compensation fields rather than replacing the entire object.
|
|
405
|
+
* To update allowances/deductions, use addAllowance/removeAllowance methods.
|
|
406
|
+
*/
|
|
407
|
+
updateCompensation(employeeId: ObjectIdLike, compensation: Partial<Compensation>, options?: {
|
|
408
|
+
session?: ClientSession;
|
|
409
|
+
}): Promise<EmployeeDocument>;
|
|
410
|
+
/**
|
|
411
|
+
* Get employee statistics for organization
|
|
412
|
+
*/
|
|
413
|
+
getEmployeeStats(organizationId: ObjectIdLike, options?: {
|
|
414
|
+
session?: ClientSession;
|
|
415
|
+
}): Promise<{
|
|
416
|
+
total: number;
|
|
417
|
+
active: number;
|
|
418
|
+
employed: number;
|
|
419
|
+
canReceiveSalary: number;
|
|
420
|
+
byStatus: Record<string, number>;
|
|
421
|
+
byDepartment: Record<string, number>;
|
|
422
|
+
}>;
|
|
423
|
+
/**
|
|
424
|
+
* Group employees by status
|
|
425
|
+
*/
|
|
426
|
+
private groupByStatus;
|
|
427
|
+
/**
|
|
428
|
+
* Group employees by department
|
|
429
|
+
*/
|
|
430
|
+
private groupByDepartment;
|
|
431
|
+
/**
|
|
432
|
+
* Check if employee is active
|
|
433
|
+
*/
|
|
434
|
+
isActive(employee: EmployeeDocument): boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Check if employee is employed
|
|
437
|
+
*/
|
|
438
|
+
isEmployed(employee: EmployeeDocument): boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Check if employee can receive salary
|
|
441
|
+
*/
|
|
442
|
+
canReceiveSalary(employee: EmployeeDocument): boolean;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Create employee service instance
|
|
446
|
+
*/
|
|
447
|
+
declare function createEmployeeService(EmployeeModel: Model<EmployeeDocument>): EmployeeService;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* @classytic/payroll - Payroll Service
|
|
451
|
+
*
|
|
452
|
+
* High-level payroll operations with dependency injection
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
declare class PayrollService {
|
|
456
|
+
private readonly PayrollModel;
|
|
457
|
+
private readonly employeeService;
|
|
458
|
+
constructor(PayrollModel: Model<PayrollRecordDocument>, employeeService: EmployeeService);
|
|
459
|
+
/**
|
|
460
|
+
* Find payroll by ID
|
|
461
|
+
*/
|
|
462
|
+
findById(payrollId: ObjectIdLike, options?: {
|
|
463
|
+
session?: ClientSession;
|
|
464
|
+
}): Promise<PayrollRecordDocument | null>;
|
|
465
|
+
/**
|
|
466
|
+
* Find payrolls by employee
|
|
467
|
+
*/
|
|
468
|
+
findByEmployee(employeeId: ObjectIdLike, organizationId: ObjectIdLike, options?: {
|
|
469
|
+
session?: ClientSession;
|
|
470
|
+
limit?: number;
|
|
471
|
+
}): Promise<PayrollRecordDocument[]>;
|
|
472
|
+
/**
|
|
473
|
+
* Find payrolls for a period
|
|
474
|
+
*/
|
|
475
|
+
findForPeriod(organizationId: ObjectIdLike, month: number, year: number, options?: {
|
|
476
|
+
session?: ClientSession;
|
|
477
|
+
}): Promise<PayrollRecordDocument[]>;
|
|
478
|
+
/**
|
|
479
|
+
* Find pending payrolls
|
|
480
|
+
*/
|
|
481
|
+
findPending(organizationId: ObjectIdLike, month: number, year: number, options?: {
|
|
482
|
+
session?: ClientSession;
|
|
483
|
+
}): Promise<PayrollRecordDocument[]>;
|
|
484
|
+
/**
|
|
485
|
+
* Find payroll by employee and period
|
|
486
|
+
*/
|
|
487
|
+
findByEmployeeAndPeriod(employeeId: ObjectIdLike, organizationId: ObjectIdLike, month: number, year: number, options?: {
|
|
488
|
+
session?: ClientSession;
|
|
489
|
+
}): Promise<PayrollRecordDocument | null>;
|
|
490
|
+
/**
|
|
491
|
+
* Create payroll record
|
|
492
|
+
*/
|
|
493
|
+
create(data: PayrollData, options?: {
|
|
494
|
+
session?: ClientSession;
|
|
495
|
+
}): Promise<PayrollRecordDocument>;
|
|
496
|
+
/**
|
|
497
|
+
* Generate payroll for employee
|
|
498
|
+
*/
|
|
499
|
+
generateForEmployee(employeeId: ObjectIdLike, organizationId: ObjectIdLike, month: number, year: number, options?: {
|
|
500
|
+
session?: ClientSession;
|
|
501
|
+
}): Promise<PayrollRecordDocument>;
|
|
502
|
+
/**
|
|
503
|
+
* Generate batch payroll
|
|
504
|
+
*/
|
|
505
|
+
generateBatch(organizationId: ObjectIdLike, month: number, year: number, options?: {
|
|
506
|
+
session?: ClientSession;
|
|
507
|
+
}): Promise<{
|
|
508
|
+
success: boolean;
|
|
509
|
+
generated: number;
|
|
510
|
+
skipped: number;
|
|
511
|
+
payrolls: PayrollRecordDocument[];
|
|
512
|
+
message: string;
|
|
513
|
+
}>;
|
|
514
|
+
/**
|
|
515
|
+
* Mark payroll as paid
|
|
516
|
+
*/
|
|
517
|
+
markAsPaid(payrollId: ObjectIdLike, paymentDetails?: {
|
|
518
|
+
paidAt?: Date;
|
|
519
|
+
transactionId?: ObjectIdLike;
|
|
520
|
+
paymentMethod?: PaymentMethod;
|
|
521
|
+
}, options?: {
|
|
522
|
+
session?: ClientSession;
|
|
523
|
+
}): Promise<PayrollRecordDocument>;
|
|
524
|
+
/**
|
|
525
|
+
* Mark payroll as processed
|
|
526
|
+
*/
|
|
527
|
+
markAsProcessed(payrollId: ObjectIdLike, options?: {
|
|
528
|
+
session?: ClientSession;
|
|
529
|
+
}): Promise<PayrollRecordDocument>;
|
|
530
|
+
/**
|
|
531
|
+
* Calculate period summary
|
|
532
|
+
*/
|
|
533
|
+
calculatePeriodSummary(organizationId: ObjectIdLike, month: number, year: number, options?: {
|
|
534
|
+
session?: ClientSession;
|
|
535
|
+
}): Promise<{
|
|
536
|
+
period: {
|
|
537
|
+
month: number;
|
|
538
|
+
year: number;
|
|
539
|
+
};
|
|
540
|
+
count: number;
|
|
541
|
+
totalGross: number;
|
|
542
|
+
totalNet: number;
|
|
543
|
+
totalAllowances: number;
|
|
544
|
+
totalDeductions: number;
|
|
545
|
+
byStatus: Record<string, number>;
|
|
546
|
+
}>;
|
|
547
|
+
/**
|
|
548
|
+
* Get employee payroll history
|
|
549
|
+
*/
|
|
550
|
+
getEmployeePayrollHistory(employeeId: ObjectIdLike, organizationId: ObjectIdLike, limit?: number, options?: {
|
|
551
|
+
session?: ClientSession;
|
|
552
|
+
}): Promise<PayrollRecordDocument[]>;
|
|
553
|
+
/**
|
|
554
|
+
* Get overview stats
|
|
555
|
+
*/
|
|
556
|
+
getOverviewStats(organizationId: ObjectIdLike, options?: {
|
|
557
|
+
session?: ClientSession;
|
|
558
|
+
}): Promise<{
|
|
559
|
+
currentPeriod: {
|
|
560
|
+
month: number;
|
|
561
|
+
year: number;
|
|
562
|
+
};
|
|
563
|
+
count: number;
|
|
564
|
+
totalGross: number;
|
|
565
|
+
totalNet: number;
|
|
566
|
+
totalAllowances: number;
|
|
567
|
+
totalDeductions: number;
|
|
568
|
+
byStatus: Record<string, number>;
|
|
569
|
+
}>;
|
|
570
|
+
/**
|
|
571
|
+
* Group payrolls by status
|
|
572
|
+
*/
|
|
573
|
+
private groupByStatus;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Create payroll service instance
|
|
577
|
+
*/
|
|
578
|
+
declare function createPayrollService(PayrollModel: Model<PayrollRecordDocument>, employeeService: EmployeeService): PayrollService;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @classytic/payroll - Compensation Service
|
|
582
|
+
*
|
|
583
|
+
* High-level compensation operations with dependency injection
|
|
584
|
+
*/
|
|
585
|
+
|
|
586
|
+
declare class CompensationService {
|
|
587
|
+
private readonly EmployeeModel;
|
|
588
|
+
constructor(EmployeeModel: Model<EmployeeDocument>);
|
|
589
|
+
/**
|
|
590
|
+
* Get employee compensation
|
|
591
|
+
*/
|
|
592
|
+
getEmployeeCompensation(employeeId: ObjectIdLike, options?: {
|
|
593
|
+
session?: ClientSession;
|
|
594
|
+
}): Promise<Compensation>;
|
|
595
|
+
/**
|
|
596
|
+
* Calculate compensation breakdown
|
|
597
|
+
*/
|
|
598
|
+
calculateBreakdown(employeeId: ObjectIdLike, options?: {
|
|
599
|
+
session?: ClientSession;
|
|
600
|
+
}): Promise<CompensationBreakdownResult>;
|
|
601
|
+
/**
|
|
602
|
+
* Update base amount
|
|
603
|
+
*/
|
|
604
|
+
updateBaseAmount(employeeId: ObjectIdLike, newAmount: number, effectiveFrom?: Date, options?: {
|
|
605
|
+
session?: ClientSession;
|
|
606
|
+
}): Promise<CompensationBreakdownResult>;
|
|
607
|
+
/**
|
|
608
|
+
* Apply salary increment
|
|
609
|
+
*/
|
|
610
|
+
applyIncrement(employeeId: ObjectIdLike, params: {
|
|
611
|
+
percentage?: number;
|
|
612
|
+
amount?: number;
|
|
613
|
+
effectiveFrom?: Date;
|
|
614
|
+
}, options?: {
|
|
615
|
+
session?: ClientSession;
|
|
616
|
+
}): Promise<CompensationBreakdownResult>;
|
|
617
|
+
/**
|
|
618
|
+
* Add allowance
|
|
619
|
+
*/
|
|
620
|
+
addAllowance(employeeId: ObjectIdLike, allowance: {
|
|
621
|
+
type: Allowance['type'];
|
|
622
|
+
value: number;
|
|
623
|
+
isPercentage?: boolean;
|
|
624
|
+
name?: string;
|
|
625
|
+
taxable?: boolean;
|
|
626
|
+
}, options?: {
|
|
627
|
+
session?: ClientSession;
|
|
628
|
+
}): Promise<CompensationBreakdownResult>;
|
|
629
|
+
/**
|
|
630
|
+
* Remove allowance
|
|
631
|
+
*/
|
|
632
|
+
removeAllowance(employeeId: ObjectIdLike, allowanceType: Allowance['type'], options?: {
|
|
633
|
+
session?: ClientSession;
|
|
634
|
+
}): Promise<CompensationBreakdownResult>;
|
|
635
|
+
/**
|
|
636
|
+
* Add deduction
|
|
637
|
+
*/
|
|
638
|
+
addDeduction(employeeId: ObjectIdLike, deduction: {
|
|
639
|
+
type: Deduction['type'];
|
|
640
|
+
value: number;
|
|
641
|
+
isPercentage?: boolean;
|
|
642
|
+
name?: string;
|
|
643
|
+
auto?: boolean;
|
|
644
|
+
}, options?: {
|
|
645
|
+
session?: ClientSession;
|
|
646
|
+
}): Promise<CompensationBreakdownResult>;
|
|
647
|
+
/**
|
|
648
|
+
* Remove deduction
|
|
649
|
+
*/
|
|
650
|
+
removeDeduction(employeeId: ObjectIdLike, deductionType: Deduction['type'], options?: {
|
|
651
|
+
session?: ClientSession;
|
|
652
|
+
}): Promise<CompensationBreakdownResult>;
|
|
653
|
+
/**
|
|
654
|
+
* Set standard compensation
|
|
655
|
+
*/
|
|
656
|
+
setStandardCompensation(employeeId: ObjectIdLike, baseAmount: number, options?: {
|
|
657
|
+
session?: ClientSession;
|
|
658
|
+
}): Promise<CompensationBreakdownResult>;
|
|
659
|
+
/**
|
|
660
|
+
* Compare compensation between two employees
|
|
661
|
+
*/
|
|
662
|
+
compareCompensation(employeeId1: ObjectIdLike, employeeId2: ObjectIdLike, options?: {
|
|
663
|
+
session?: ClientSession;
|
|
664
|
+
}): Promise<{
|
|
665
|
+
employee1: CompensationBreakdownResult;
|
|
666
|
+
employee2: CompensationBreakdownResult;
|
|
667
|
+
difference: {
|
|
668
|
+
base: number;
|
|
669
|
+
gross: number;
|
|
670
|
+
net: number;
|
|
671
|
+
};
|
|
672
|
+
ratio: {
|
|
673
|
+
base: number;
|
|
674
|
+
gross: number;
|
|
675
|
+
net: number;
|
|
676
|
+
};
|
|
677
|
+
}>;
|
|
678
|
+
/**
|
|
679
|
+
* Get department compensation stats
|
|
680
|
+
*/
|
|
681
|
+
getDepartmentCompensationStats(organizationId: ObjectIdLike, department: Department, options?: {
|
|
682
|
+
session?: ClientSession;
|
|
683
|
+
}): Promise<{
|
|
684
|
+
department: string;
|
|
685
|
+
employeeCount: number;
|
|
686
|
+
totalBase: number;
|
|
687
|
+
totalGross: number;
|
|
688
|
+
totalNet: number;
|
|
689
|
+
averageBase: number;
|
|
690
|
+
averageGross: number;
|
|
691
|
+
averageNet: number;
|
|
692
|
+
}>;
|
|
693
|
+
/**
|
|
694
|
+
* Get organization compensation stats
|
|
695
|
+
*/
|
|
696
|
+
getOrganizationCompensationStats(organizationId: ObjectIdLike, options?: {
|
|
697
|
+
session?: ClientSession;
|
|
698
|
+
}): Promise<{
|
|
699
|
+
employeeCount: number;
|
|
700
|
+
totalBase: number;
|
|
701
|
+
totalGross: number;
|
|
702
|
+
totalNet: number;
|
|
703
|
+
averageBase: number;
|
|
704
|
+
averageGross: number;
|
|
705
|
+
averageNet: number;
|
|
706
|
+
byDepartment: Record<string, {
|
|
707
|
+
count: number;
|
|
708
|
+
totalNet: number;
|
|
709
|
+
}>;
|
|
710
|
+
}>;
|
|
711
|
+
/**
|
|
712
|
+
* Find employee helper
|
|
713
|
+
*/
|
|
714
|
+
private findEmployee;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Create compensation service instance
|
|
718
|
+
*/
|
|
719
|
+
declare function createCompensationService(EmployeeModel: Model<EmployeeDocument>): CompensationService;
|
|
720
|
+
|
|
721
|
+
export { BatchPayrollFactory as B, CompensationService as C, EmployeeFactory as E, PayrollFactory as P, EmployeeBuilder as a, EmployeeService as b, PayrollService as c, createEmployeeService as d, createPayrollService as e, createCompensationService as f };
|