@classytic/payroll 1.0.1 → 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 (46) 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 +61 -25
  24. package/payroll.d.ts +0 -241
  25. package/src/config.js +0 -177
  26. package/src/core/compensation.manager.js +0 -242
  27. package/src/core/employment.manager.js +0 -224
  28. package/src/core/payroll.manager.js +0 -499
  29. package/src/enums.js +0 -141
  30. package/src/factories/compensation.factory.js +0 -198
  31. package/src/factories/employee.factory.js +0 -173
  32. package/src/factories/payroll.factory.js +0 -247
  33. package/src/hrm.orchestrator.js +0 -139
  34. package/src/index.js +0 -172
  35. package/src/init.js +0 -41
  36. package/src/models/payroll-record.model.js +0 -126
  37. package/src/plugins/employee.plugin.js +0 -157
  38. package/src/schemas/employment.schema.js +0 -126
  39. package/src/services/compensation.service.js +0 -231
  40. package/src/services/employee.service.js +0 -162
  41. package/src/services/payroll.service.js +0 -213
  42. package/src/utils/calculation.utils.js +0 -91
  43. package/src/utils/date.utils.js +0 -120
  44. package/src/utils/logger.js +0 -36
  45. package/src/utils/query-builders.js +0 -185
  46. package/src/utils/validation.utils.js +0 -122
@@ -1,122 +0,0 @@
1
- /**
2
- * Validation Utilities - Fluent, Composable, Type-Safe
3
- * Beautiful validation with clear semantics
4
- */
5
-
6
- export const isActive = (employee) =>
7
- employee?.status === 'active';
8
-
9
- export const isOnLeave = (employee) =>
10
- employee?.status === 'on_leave';
11
-
12
- export const isSuspended = (employee) =>
13
- employee?.status === 'suspended';
14
-
15
- export const isTerminated = (employee) =>
16
- employee?.status === 'terminated';
17
-
18
- export const isEmployed = (employee) =>
19
- isActive(employee) || isOnLeave(employee) || isSuspended(employee);
20
-
21
- export const canReceiveSalary = (employee) =>
22
- isActive(employee) || isOnLeave(employee);
23
-
24
- export const canUpdateEmployment = (employee) =>
25
- !isTerminated(employee);
26
-
27
- export const isInProbation = (employee, now = new Date()) =>
28
- employee?.probationEndDate && new Date(employee.probationEndDate) > now;
29
-
30
- export const hasCompletedProbation = (employee, now = new Date()) =>
31
- employee?.probationEndDate && new Date(employee.probationEndDate) <= now;
32
-
33
- export const hasCompensation = (employee) =>
34
- employee?.compensation?.baseAmount > 0;
35
-
36
- export const isEligibleForBonus = (employee, requiredMonths = 6) => {
37
- if (!isActive(employee)) return false;
38
- const monthsEmployed = monthsBetween(employee.hireDate, new Date());
39
- return monthsEmployed >= requiredMonths;
40
- };
41
-
42
- export const isValidCompensation = (compensation) =>
43
- compensation?.baseAmount > 0 &&
44
- compensation?.frequency &&
45
- compensation?.currency;
46
-
47
- export const isValidBankDetails = (bankDetails) =>
48
- bankDetails?.accountNumber &&
49
- bankDetails?.bankName &&
50
- bankDetails?.accountHolderName;
51
-
52
- export const hasRequiredFields = (obj, fields) =>
53
- fields.every((field) => obj?.[field] !== undefined && obj?.[field] !== null);
54
-
55
- export const createValidator = (validationFns) => (data) => {
56
- const errors = [];
57
-
58
- for (const [field, validator] of Object.entries(validationFns)) {
59
- const result = validator(data[field], data);
60
- if (result !== true) {
61
- errors.push({ field, message: result });
62
- }
63
- }
64
-
65
- return {
66
- isValid: errors.length === 0,
67
- errors,
68
- };
69
- };
70
-
71
- export const required = (fieldName) => (value) =>
72
- value !== undefined && value !== null && value !== ''
73
- ? true
74
- : `${fieldName} is required`;
75
-
76
- export const min = (minValue, fieldName) => (value) =>
77
- value >= minValue ? true : `${fieldName} must be at least ${minValue}`;
78
-
79
- export const max = (maxValue, fieldName) => (value) =>
80
- value <= maxValue ? true : `${fieldName} must not exceed ${maxValue}`;
81
-
82
- export const inRange = (minValue, maxValue, fieldName) => (value) =>
83
- value >= minValue && value <= maxValue
84
- ? true
85
- : `${fieldName} must be between ${minValue} and ${maxValue}`;
86
-
87
- export const oneOf = (allowedValues, fieldName) => (value) =>
88
- allowedValues.includes(value)
89
- ? true
90
- : `${fieldName} must be one of: ${allowedValues.join(', ')}`;
91
-
92
- export const compose = (...validators) => (value, data) => {
93
- for (const validator of validators) {
94
- const result = validator(value, data);
95
- if (result !== true) return result;
96
- }
97
- return true;
98
- };
99
-
100
- // Additional validators
101
- export const isPositive = (fieldName) => (value) =>
102
- value > 0 ? true : `${fieldName} must be positive`;
103
-
104
- export const isValidStatus = (value) =>
105
- ['active', 'on_leave', 'suspended', 'terminated'].includes(value);
106
-
107
- export const isValidEmploymentType = (value) =>
108
- ['full_time', 'part_time', 'contract', 'internship'].includes(value);
109
-
110
- // Aliases for consistency
111
- export const minValue = min;
112
- export const maxValue = max;
113
- export const isInRange = inRange;
114
-
115
- const monthsBetween = (start, end) => {
116
- const startDate = new Date(start);
117
- const endDate = new Date(end);
118
- return (
119
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
120
- (endDate.getMonth() - startDate.getMonth())
121
- );
122
- };