@classytic/payroll 1.0.1 → 1.0.2
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/dist/types/config.d.ts +162 -0
- package/dist/types/core/compensation.manager.d.ts +54 -0
- package/dist/types/core/employment.manager.d.ts +49 -0
- package/dist/types/core/payroll.manager.d.ts +60 -0
- package/dist/types/enums.d.ts +117 -0
- package/dist/types/factories/compensation.factory.d.ts +196 -0
- package/dist/types/factories/employee.factory.d.ts +149 -0
- package/dist/types/factories/payroll.factory.d.ts +319 -0
- package/dist/types/hrm.orchestrator.d.ts +47 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/init.d.ts +30 -0
- package/dist/types/models/payroll-record.model.d.ts +3 -0
- package/dist/types/plugins/employee.plugin.d.ts +2 -0
- package/dist/types/schemas/employment.schema.d.ts +959 -0
- package/dist/types/services/compensation.service.d.ts +94 -0
- package/dist/types/services/employee.service.d.ts +28 -0
- package/dist/types/services/payroll.service.d.ts +30 -0
- package/dist/types/utils/calculation.utils.d.ts +26 -0
- package/dist/types/utils/date.utils.d.ts +35 -0
- package/dist/types/utils/logger.d.ts +12 -0
- package/dist/types/utils/query-builders.d.ts +83 -0
- package/dist/types/utils/validation.utils.d.ts +33 -0
- package/package.json +32 -13
- package/src/factories/payroll.factory.js +167 -1
- package/src/init.js +21 -0
- package/src/plugins/employee.plugin.js +9 -2
package/src/init.js
CHANGED
|
@@ -3,6 +3,27 @@ import logger, { setLogger } from './utils/logger.js';
|
|
|
3
3
|
|
|
4
4
|
let initialized = false;
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Initialize HRM/Payroll framework
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} options - Initialization options
|
|
10
|
+
* @param {Model} options.EmployeeModel - Employee model (required)
|
|
11
|
+
* @param {Model} options.PayrollRecordModel - Payroll record model (required)
|
|
12
|
+
* @param {Model} options.TransactionModel - Transaction model (required)
|
|
13
|
+
* @param {Model} options.AttendanceModel - Optional attendance model for integration
|
|
14
|
+
* @param {Object} options.logger - Optional custom logger
|
|
15
|
+
*
|
|
16
|
+
* @example Multi-Tenant (default)
|
|
17
|
+
* initializeHRM({
|
|
18
|
+
* EmployeeModel,
|
|
19
|
+
* PayrollRecordModel,
|
|
20
|
+
* TransactionModel
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @example Single-Tenant
|
|
24
|
+
* // For single-tenant apps, add organizationId with default value in your Employee schema:
|
|
25
|
+
* // organizationId: { type: ObjectId, required: true, default: () => FIXED_ORG_ID }
|
|
26
|
+
*/
|
|
6
27
|
export function initializeHRM({ EmployeeModel, PayrollRecordModel, TransactionModel, AttendanceModel = null, logger: customLogger }) {
|
|
7
28
|
// Allow users to inject their own logger
|
|
8
29
|
if (customLogger) {
|
|
@@ -136,11 +136,18 @@ export function employeePlugin(schema, options = {}) {
|
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Pre-save hook to automatically update salary calculations
|
|
141
|
+
* when compensation is modified.
|
|
142
|
+
*
|
|
143
|
+
* Mongoose v9 compatible - uses async function without next callback
|
|
144
|
+
* - Use throw instead of next(err) for errors
|
|
145
|
+
* - Use return instead of return next()
|
|
146
|
+
*/
|
|
147
|
+
schema.pre('save', async function() {
|
|
140
148
|
if (this.isModified('compensation')) {
|
|
141
149
|
this.updateSalaryCalculations();
|
|
142
150
|
}
|
|
143
|
-
next();
|
|
144
151
|
});
|
|
145
152
|
|
|
146
153
|
schema.index({ organizationId: 1, employeeId: 1 }, { unique: true });
|