@classytic/payroll 1.0.0 → 2.7.5
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.
- package/README.md +525 -574
- package/dist/calculators/index.d.ts +300 -0
- package/dist/calculators/index.js +304 -0
- package/dist/calculators/index.js.map +1 -0
- package/dist/employee-identity-Cq2wo9-2.d.ts +490 -0
- package/dist/index-DjB72l6e.d.ts +3742 -0
- package/dist/index.d.ts +2924 -0
- package/dist/index.js +10648 -0
- package/dist/index.js.map +1 -0
- package/dist/prorating.calculator-C7sdFiG2.d.ts +135 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.js +1452 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/types-BVDjiVGS.d.ts +1856 -0
- package/dist/utils/index.d.ts +995 -0
- package/dist/utils/index.js +1629 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +77 -24
- 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 -247
- package/src/hrm.orchestrator.js +0 -139
- package/src/index.js +0 -172
- package/src/init.js +0 -41
- package/src/models/payroll-record.model.js +0 -126
- package/src/plugins/employee.plugin.js +0 -157
- 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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classytic/payroll - Pro-Rating Calculator
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for salary pro-rating calculations.
|
|
5
|
+
* No database dependencies - can be used client-side!
|
|
6
|
+
*
|
|
7
|
+
* Handles:
|
|
8
|
+
* - Mid-period hires
|
|
9
|
+
* - Mid-period terminations
|
|
10
|
+
* - Working days (not calendar days)
|
|
11
|
+
* - Holidays exclusion
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Input for pro-rating calculation
|
|
17
|
+
*/
|
|
18
|
+
interface ProRatingInput {
|
|
19
|
+
/**
|
|
20
|
+
* Employee hire date
|
|
21
|
+
*/
|
|
22
|
+
hireDate: Date;
|
|
23
|
+
/**
|
|
24
|
+
* Employee termination date (null if still employed)
|
|
25
|
+
*/
|
|
26
|
+
terminationDate: Date | null;
|
|
27
|
+
/**
|
|
28
|
+
* Start of the salary period
|
|
29
|
+
*/
|
|
30
|
+
periodStart: Date;
|
|
31
|
+
/**
|
|
32
|
+
* End of the salary period
|
|
33
|
+
*/
|
|
34
|
+
periodEnd: Date;
|
|
35
|
+
/**
|
|
36
|
+
* Working days of the week (1=Monday, 7=Sunday)
|
|
37
|
+
* @default [1, 2, 3, 4, 5] (Monday-Friday)
|
|
38
|
+
*/
|
|
39
|
+
workingDays: number[];
|
|
40
|
+
/**
|
|
41
|
+
* Public holidays to exclude from working days
|
|
42
|
+
* @default []
|
|
43
|
+
*/
|
|
44
|
+
holidays?: Date[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of pro-rating calculation
|
|
48
|
+
*/
|
|
49
|
+
interface ProRatingResult {
|
|
50
|
+
/**
|
|
51
|
+
* Whether the salary needs to be pro-rated
|
|
52
|
+
*/
|
|
53
|
+
isProRated: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Pro-rating ratio (0-1)
|
|
56
|
+
* 1 = full salary, 0.5 = half salary, etc.
|
|
57
|
+
*/
|
|
58
|
+
ratio: number;
|
|
59
|
+
/**
|
|
60
|
+
* Total working days in the period
|
|
61
|
+
*/
|
|
62
|
+
periodWorkingDays: number;
|
|
63
|
+
/**
|
|
64
|
+
* Working days the employee was actually employed
|
|
65
|
+
*/
|
|
66
|
+
effectiveWorkingDays: number;
|
|
67
|
+
/**
|
|
68
|
+
* Effective start date (max of hire date and period start)
|
|
69
|
+
*/
|
|
70
|
+
effectiveStart: Date;
|
|
71
|
+
/**
|
|
72
|
+
* Effective end date (min of termination date and period end)
|
|
73
|
+
*/
|
|
74
|
+
effectiveEnd: Date;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Calculate pro-rating for mid-period hires/terminations
|
|
78
|
+
*
|
|
79
|
+
* This function uses WORKING DAYS (not calendar days) for accurate pro-rating.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* // Employee hired on March 15th, process March salary
|
|
84
|
+
* const result = calculateProRating({
|
|
85
|
+
* hireDate: new Date('2024-03-15'),
|
|
86
|
+
* terminationDate: null,
|
|
87
|
+
* periodStart: new Date('2024-03-01'),
|
|
88
|
+
* periodEnd: new Date('2024-03-31'),
|
|
89
|
+
* workingDays: [1, 2, 3, 4, 5], // Mon-Fri
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* console.log(result);
|
|
93
|
+
* // {
|
|
94
|
+
* // isProRated: true,
|
|
95
|
+
* // ratio: 0.64, // Worked 14 out of 22 working days
|
|
96
|
+
* // periodWorkingDays: 22,
|
|
97
|
+
* // effectiveWorkingDays: 14
|
|
98
|
+
* // }
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @param input - Pro-rating calculation parameters
|
|
102
|
+
* @returns Pro-rating result with ratio and working days breakdown
|
|
103
|
+
*
|
|
104
|
+
* @pure This function has no side effects and doesn't access external state
|
|
105
|
+
*/
|
|
106
|
+
declare function calculateProRating(input: ProRatingInput): ProRatingResult;
|
|
107
|
+
/**
|
|
108
|
+
* Calculate pro-rated amount from base amount and ratio
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const proRatedSalary = applyProRating(100000, 0.64); // 64000
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @param baseAmount - Original amount
|
|
116
|
+
* @param ratio - Pro-rating ratio (0-1)
|
|
117
|
+
* @returns Pro-rated amount (rounded)
|
|
118
|
+
*
|
|
119
|
+
* @pure No side effects
|
|
120
|
+
*/
|
|
121
|
+
declare function applyProRating(baseAmount: number, ratio: number): number;
|
|
122
|
+
/**
|
|
123
|
+
* Check if pro-rating should be applied for a given hire/termination scenario
|
|
124
|
+
*
|
|
125
|
+
* @param hireDate - Employee hire date
|
|
126
|
+
* @param terminationDate - Employee termination date (null if active)
|
|
127
|
+
* @param periodStart - Salary period start
|
|
128
|
+
* @param periodEnd - Salary period end
|
|
129
|
+
* @returns True if pro-rating is needed
|
|
130
|
+
*
|
|
131
|
+
* @pure No side effects
|
|
132
|
+
*/
|
|
133
|
+
declare function shouldProRate(hireDate: Date, terminationDate: Date | null, periodStart: Date, periodEnd: Date): boolean;
|
|
134
|
+
|
|
135
|
+
export { type ProRatingInput as P, applyProRating as a, type ProRatingResult as b, calculateProRating as c, shouldProRate as s };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import 'bson';
|
|
2
|
+
import 'mongoose';
|
|
3
|
+
export { P as PayrollSchemaOptions, a as allowanceSchema, b as applyEmployeeIndexes, c as applyLeaveRequestIndexes, d as applyPayrollRecordIndexes, e as applyTaxWithholdingIndexes, f as bankDetailsSchema, g as compensationSchema, h as createEmployeeSchema, i as createEmploymentFields, j as createPayrollRecordFields, k as createPayrollRecordSchema, l as deductionSchema, _ as default, z as employeeIndexes, m as employmentHistorySchema, n as getLeaveRequestFields, o as getLeaveRequestModel, p as getTaxWithholdingFields, q as getTaxWithholdingModel, r as leaveBalanceFields, s as leaveBalanceSchema, t as leaveRequestIndexes, u as leaveRequestSchema, A as leaveRequestTTLIndex, B as payrollBreakdownSchema, C as payrollRecordIndexes, v as payrollStatsSchema, D as periodSchema, w as taxWithholdingIndexes, x as taxWithholdingSchema, y as workScheduleSchema } from '../index-DjB72l6e.js';
|
|
4
|
+
import '../types-BVDjiVGS.js';
|