@classytic/payroll 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/package.json +6 -4
  2. package/payroll.d.ts +241 -0
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@classytic/payroll",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Modern HRM and payroll management library for Node.js applications",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
+ "types": "./payroll.d.ts",
7
8
  "exports": {
8
9
  ".": "./src/index.js",
9
10
  "./init": "./src/init.js",
@@ -15,6 +16,7 @@
15
16
  },
16
17
  "files": [
17
18
  "src/**/*.js",
19
+ "payroll.d.ts",
18
20
  "README.md",
19
21
  "LICENSE"
20
22
  ],
@@ -43,9 +45,9 @@
43
45
  "mongoose": "^8.0.0"
44
46
  },
45
47
  "devDependencies": {
46
- "mongoose": "^8.0.0",
47
- "mongoose-paginate-v2": "^1.8.0",
48
- "mongoose-aggregate-paginate-v2": "^1.1.0"
48
+ "mongoose": "^8.8.1",
49
+ "mongoose-aggregate-paginate-v2": "^1.1.4",
50
+ "mongoose-paginate-v2": "^1.9.0"
49
51
  },
50
52
  "engines": {
51
53
  "node": ">=18.0.0"
package/payroll.d.ts ADDED
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Type declarations for @classytic/payroll
3
+ * This provides IntelliSense support for the HRM library
4
+ */
5
+
6
+ declare module '@classytic/payroll' {
7
+ import { Model, Document } from 'mongoose';
8
+
9
+ // Initialization
10
+ export function initializeHRM(config: {
11
+ EmployeeModel: Model<any>;
12
+ PayrollRecordModel: Model<any>;
13
+ TransactionModel: Model<any>;
14
+ AttendanceModel?: Model<any> | null;
15
+ logger?: any;
16
+ }): void;
17
+
18
+ export function isInitialized(): boolean;
19
+ export function setLogger(logger: any): void;
20
+
21
+ // Models
22
+ export const PayrollRecord: Model<any>;
23
+
24
+ // Orchestrator
25
+ export const hrm: any;
26
+ export const hrmOrchestrator: any;
27
+
28
+ // Enums
29
+ export const EMPLOYMENT_TYPE: Record<string, string>;
30
+ export const EMPLOYMENT_TYPE_VALUES: string[];
31
+ export const EMPLOYEE_STATUS: Record<string, string>;
32
+ export const EMPLOYEE_STATUS_VALUES: string[];
33
+ export const DEPARTMENT: Record<string, string>;
34
+ export const DEPARTMENT_VALUES: string[];
35
+ export const PAYMENT_FREQUENCY: Record<string, string>;
36
+ export const PAYMENT_FREQUENCY_VALUES: string[];
37
+ export const PAYMENT_METHOD: Record<string, string>;
38
+ export const PAYMENT_METHOD_VALUES: string[];
39
+ export const ALLOWANCE_TYPE: Record<string, string>;
40
+ export const ALLOWANCE_TYPE_VALUES: string[];
41
+ export const DEDUCTION_TYPE: Record<string, string>;
42
+ export const DEDUCTION_TYPE_VALUES: string[];
43
+ export const PAYROLL_STATUS: Record<string, string>;
44
+ export const PAYROLL_STATUS_VALUES: string[];
45
+ export const TERMINATION_REASON: Record<string, string>;
46
+ export const TERMINATION_REASON_VALUES: string[];
47
+ export const HRM_TRANSACTION_CATEGORIES: Record<string, string>;
48
+ export const HRM_CATEGORY_VALUES: string[];
49
+ export function isHRMManagedCategory(category: string): boolean;
50
+
51
+ // Config
52
+ export const HRM_CONFIG: any;
53
+ export const SALARY_BANDS: any;
54
+ export const TAX_BRACKETS: any;
55
+ export const ORG_ROLES: Record<string, string>;
56
+ export const ORG_ROLE_KEYS: string[];
57
+ export const ROLE_MAPPING: Record<string, any>;
58
+ export function calculateTax(income: number): number;
59
+ export function getSalaryBand(salary: number): any;
60
+ export function determineOrgRole(role: string): string;
61
+
62
+ // Schemas
63
+ export const employmentFields: Record<string, any>;
64
+ export const allowanceSchema: any;
65
+ export const deductionSchema: any;
66
+ export const compensationSchema: any;
67
+ export const workScheduleSchema: any;
68
+ export const bankDetailsSchema: any;
69
+ export const employmentHistorySchema: any;
70
+ export const payrollStatsSchema: any;
71
+
72
+ // Plugins
73
+ export function employeePlugin(schema: any, options?: any): void;
74
+
75
+ // Utilities
76
+ export function addDays(date: Date, days: number): Date;
77
+ export function addMonths(date: Date, months: number): Date;
78
+ export function diffInDays(date1: Date, date2: Date): number;
79
+ export function diffInMonths(date1: Date, date2: Date): number;
80
+ export function startOfMonth(date: Date): Date;
81
+ export function endOfMonth(date: Date): Date;
82
+ export function startOfYear(date: Date): Date;
83
+ export function endOfYear(date: Date): Date;
84
+ export function isWeekday(date: Date): boolean;
85
+ export function isWeekend(date: Date): boolean;
86
+ export function getPayPeriod(date: Date, frequency: string): any;
87
+ export function getCurrentPeriod(frequency: string): any;
88
+ export function calculateProbationEnd(startDate: Date, months: number): Date;
89
+ export function formatDateForDB(date: Date): string;
90
+ export function parseDBDate(dateString: string): Date;
91
+
92
+ // Calculation utilities
93
+ export function sum(...numbers: number[]): number;
94
+ export function sumBy<T>(array: T[], iteratee: (item: T) => number): number;
95
+ export function sumAllowances(allowances: any[]): number;
96
+ export function sumDeductions(deductions: any[]): number;
97
+ export function calculateGross(baseSalary: number, allowances: any[]): number;
98
+ export function calculateNet(gross: number, deductions: any[]): number;
99
+ export function applyPercentage(amount: number, percentage: number): number;
100
+ export function calculatePercentage(part: number, total: number): number;
101
+ export function createAllowanceCalculator(config: any): (salary: number) => number;
102
+ export function createDeductionCalculator(config: any): (salary: number) => number;
103
+ export function calculateTotalCompensation(compensation: any): number;
104
+ export function pipe(...fns: Function[]): Function;
105
+ export function compose(...fns: Function[]): Function;
106
+
107
+ // Validation utilities
108
+ export function isActive(employee: any): boolean;
109
+ export function isOnLeave(employee: any): boolean;
110
+ export function isSuspended(employee: any): boolean;
111
+ export function isTerminated(employee: any): boolean;
112
+ export function isEmployed(employee: any): boolean;
113
+ export function canReceiveSalary(employee: any): boolean;
114
+ export function hasCompensation(employee: any): boolean;
115
+ export function required(value: any): boolean;
116
+ export function minValue(min: number): (value: number) => boolean;
117
+ export function maxValue(max: number): (value: number) => boolean;
118
+ export function isInRange(min: number, max: number): (value: number) => boolean;
119
+ export function isPositive(value: number): boolean;
120
+ export function isValidStatus(status: string): boolean;
121
+ export function isValidEmploymentType(type: string): boolean;
122
+ export function composeValidators(...validators: Function[]): Function;
123
+
124
+ // Query Builders
125
+ export class QueryBuilder {
126
+ where(conditions: any): this;
127
+ select(fields: string | string[]): this;
128
+ populate(paths: string | any[]): this;
129
+ sort(sort: any): this;
130
+ limit(limit: number): this;
131
+ skip(skip: number): this;
132
+ lean(lean?: boolean): this;
133
+ exec(): Promise<any>;
134
+ }
135
+
136
+ export class EmployeeQueryBuilder extends QueryBuilder {
137
+ byOrganization(organizationId: string): this;
138
+ byStatus(status: string): this;
139
+ byDepartment(department: string): this;
140
+ active(): this;
141
+ terminated(): this;
142
+ }
143
+
144
+ export class PayrollQueryBuilder extends QueryBuilder {
145
+ byEmployee(employeeId: string): this;
146
+ byPeriod(year: number, month: number): this;
147
+ byStatus(status: string): this;
148
+ pending(): this;
149
+ processed(): this;
150
+ }
151
+
152
+ export function employee(model: Model<any>): EmployeeQueryBuilder;
153
+ export function payroll(model: Model<any>): PayrollQueryBuilder;
154
+ export function toObjectId(id: string): any;
155
+
156
+ // Factories
157
+ export class EmployeeFactory {
158
+ static create(data: any): any;
159
+ }
160
+
161
+ export class EmployeeBuilder {
162
+ setBasicInfo(info: any): this;
163
+ setEmployment(employment: any): this;
164
+ setCompensation(compensation: any): this;
165
+ build(): any;
166
+ }
167
+
168
+ export function createEmployee(data: any): any;
169
+
170
+ export class PayrollFactory {
171
+ static create(data: any): any;
172
+ }
173
+
174
+ export class PayrollBuilder {
175
+ setEmployee(employeeId: string): this;
176
+ setPeriod(year: number, month: number): this;
177
+ setEarnings(earnings: any): this;
178
+ setDeductions(deductions: any): this;
179
+ build(): any;
180
+ }
181
+
182
+ export class BatchPayrollFactory {
183
+ static createBatch(employees: any[], period: any): any[];
184
+ }
185
+
186
+ export function createPayroll(data: any): any;
187
+
188
+ export class CompensationFactory {
189
+ static create(data: any): any;
190
+ }
191
+
192
+ export class CompensationBuilder {
193
+ setBaseSalary(amount: number): this;
194
+ addAllowance(allowance: any): this;
195
+ addDeduction(deduction: any): this;
196
+ build(): any;
197
+ }
198
+
199
+ export const CompensationPresets: {
200
+ junior: (baseSalary: number) => any;
201
+ mid: (baseSalary: number) => any;
202
+ senior: (baseSalary: number) => any;
203
+ manager: (baseSalary: number) => any;
204
+ };
205
+
206
+ export function createCompensation(data: any): any;
207
+
208
+ // Services
209
+ export class EmployeeService {
210
+ constructor(model: Model<any>);
211
+ findById(id: string): Promise<any>;
212
+ findByOrganization(organizationId: string): Promise<any[]>;
213
+ create(data: any): Promise<any>;
214
+ update(id: string, data: any): Promise<any>;
215
+ delete(id: string): Promise<void>;
216
+ }
217
+
218
+ export function createEmployeeService(model: Model<any>): EmployeeService;
219
+
220
+ export class PayrollService {
221
+ constructor(payrollModel: Model<any>, employeeModel: Model<any>);
222
+ processPayroll(employeeId: string, period: any): Promise<any>;
223
+ findByPeriod(organizationId: string, year: number, month: number): Promise<any[]>;
224
+ }
225
+
226
+ export function createPayrollService(
227
+ payrollModel: Model<any>,
228
+ employeeModel: Model<any>
229
+ ): PayrollService;
230
+
231
+ export class CompensationService {
232
+ constructor(employeeModel: Model<any>);
233
+ updateCompensation(employeeId: string, compensation: any): Promise<any>;
234
+ getCompensationHistory(employeeId: string): Promise<any[]>;
235
+ }
236
+
237
+ export function createCompensationService(model: Model<any>): CompensationService;
238
+
239
+ export default hrm;
240
+ }
241
+