@classytic/payroll 2.7.5 → 2.8.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.
- package/README.md +333 -323
- package/dist/attendance.calculator-BZcv2iii.d.ts +336 -0
- package/dist/calculators/index.d.ts +3 -299
- package/dist/calculators/index.js +154 -19
- package/dist/calculators/index.js.map +1 -1
- package/dist/core/index.d.ts +321 -0
- package/dist/core/index.js +1962 -0
- package/dist/core/index.js.map +1 -0
- package/dist/{employee-identity-Cq2wo9-2.d.ts → error-helpers-Bm6lMny2.d.ts} +257 -7
- package/dist/{index-DjB72l6e.d.ts → index-BKLkuSAs.d.ts} +248 -132
- package/dist/index.d.ts +418 -658
- package/dist/index.js +1179 -373
- package/dist/index.js.map +1 -1
- package/dist/payroll-states-DBt0XVm-.d.ts +598 -0
- package/dist/{prorating.calculator-C7sdFiG2.d.ts → prorating.calculator-C33fWBQf.d.ts} +2 -2
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.js +95 -75
- package/dist/schemas/index.js.map +1 -1
- package/dist/{types-BVDjiVGS.d.ts → types-bZdAJueH.d.ts} +427 -12
- package/dist/utils/index.d.ts +17 -5
- package/dist/utils/index.js +185 -25
- package/dist/utils/index.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { _ as Compensation, $ as TaxBracket, a0 as TaxCalculationOptions, a1 as PayrollBreakdown } from './types-bZdAJueH.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @classytic/payroll - Salary Calculator
|
|
5
|
+
*
|
|
6
|
+
* Pure functions for complete salary breakdown calculations.
|
|
7
|
+
* No database dependencies - can be used client-side!
|
|
8
|
+
*
|
|
9
|
+
* This is the SINGLE SOURCE OF TRUTH for all salary calculations.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Input for salary breakdown calculation
|
|
16
|
+
*/
|
|
17
|
+
interface SalaryCalculationInput {
|
|
18
|
+
/**
|
|
19
|
+
* Employee data (minimal subset needed for calculation)
|
|
20
|
+
*/
|
|
21
|
+
employee: {
|
|
22
|
+
hireDate: Date;
|
|
23
|
+
terminationDate?: Date | null;
|
|
24
|
+
compensation: Compensation;
|
|
25
|
+
workSchedule?: {
|
|
26
|
+
workingDays?: number[];
|
|
27
|
+
hoursPerDay?: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Salary period
|
|
32
|
+
*/
|
|
33
|
+
period: {
|
|
34
|
+
month: number;
|
|
35
|
+
year: number;
|
|
36
|
+
startDate: Date;
|
|
37
|
+
endDate: Date;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Attendance data (optional)
|
|
41
|
+
*/
|
|
42
|
+
attendance?: {
|
|
43
|
+
expectedDays?: number;
|
|
44
|
+
actualDays?: number;
|
|
45
|
+
} | null;
|
|
46
|
+
/**
|
|
47
|
+
* Processing options
|
|
48
|
+
*/
|
|
49
|
+
options?: {
|
|
50
|
+
holidays?: Date[];
|
|
51
|
+
workSchedule?: {
|
|
52
|
+
workingDays?: number[];
|
|
53
|
+
hoursPerDay?: number;
|
|
54
|
+
};
|
|
55
|
+
skipTax?: boolean;
|
|
56
|
+
skipAttendance?: boolean;
|
|
57
|
+
skipProration?: boolean;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Configuration (minimal subset)
|
|
61
|
+
*/
|
|
62
|
+
config: {
|
|
63
|
+
allowProRating: boolean;
|
|
64
|
+
autoDeductions: boolean;
|
|
65
|
+
defaultCurrency: string;
|
|
66
|
+
attendanceIntegration: boolean;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Tax brackets for the employee's currency
|
|
70
|
+
*/
|
|
71
|
+
taxBrackets: TaxBracket[];
|
|
72
|
+
/**
|
|
73
|
+
* Enhanced tax calculation options (optional)
|
|
74
|
+
*
|
|
75
|
+
* When provided, enables jurisdiction-aware tax calculation with:
|
|
76
|
+
* - Standard deduction / tax-free threshold
|
|
77
|
+
* - Demographic-based thresholds (senior, disabled, etc.)
|
|
78
|
+
* - Pre-tax deductions handling
|
|
79
|
+
* - Tax credits/rebates
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* taxOptions: {
|
|
84
|
+
* applyStandardDeduction: true,
|
|
85
|
+
* taxpayerCategory: 'senior',
|
|
86
|
+
* preTaxDeductions: [{ type: 'provident_fund', amount: 5000 }],
|
|
87
|
+
* taxCredits: [{ type: 'investment', amount: 2000 }],
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
taxOptions?: TaxCalculationOptions;
|
|
92
|
+
/**
|
|
93
|
+
* Jurisdiction tax configuration (optional)
|
|
94
|
+
*
|
|
95
|
+
* When provided alongside taxOptions, enables lookup of:
|
|
96
|
+
* - standardDeduction from jurisdiction
|
|
97
|
+
* - thresholdsByCategory for taxpayer category
|
|
98
|
+
* - preTaxDeductionTypes for automatic pre-tax detection
|
|
99
|
+
*/
|
|
100
|
+
jurisdictionTaxConfig?: {
|
|
101
|
+
/** Standard deduction amount (annual) */
|
|
102
|
+
standardDeduction?: number;
|
|
103
|
+
/** Tax-free thresholds by taxpayer category (annual) */
|
|
104
|
+
thresholdsByCategory?: Record<string, number>;
|
|
105
|
+
/** Recognized pre-tax deduction types */
|
|
106
|
+
preTaxDeductionTypes?: string[];
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Processed allowance with calculated amount
|
|
111
|
+
*/
|
|
112
|
+
interface ProcessedAllowance {
|
|
113
|
+
type: string;
|
|
114
|
+
amount: number;
|
|
115
|
+
taxable: boolean;
|
|
116
|
+
originalAmount?: number;
|
|
117
|
+
isPercentage?: boolean;
|
|
118
|
+
value?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Processed deduction with calculated amount
|
|
122
|
+
*/
|
|
123
|
+
interface ProcessedDeduction {
|
|
124
|
+
type: string;
|
|
125
|
+
amount: number;
|
|
126
|
+
description?: string;
|
|
127
|
+
originalAmount?: number;
|
|
128
|
+
isPercentage?: boolean;
|
|
129
|
+
value?: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Calculate complete salary breakdown
|
|
133
|
+
*
|
|
134
|
+
* This is the SINGLE SOURCE OF TRUTH for salary calculations.
|
|
135
|
+
* All payroll processing uses this function.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const breakdown = calculateSalaryBreakdown({
|
|
140
|
+
* employee: {
|
|
141
|
+
* hireDate: new Date('2024-01-01'),
|
|
142
|
+
* compensation: {
|
|
143
|
+
* baseAmount: 100000,
|
|
144
|
+
* currency: 'USD',
|
|
145
|
+
* allowances: [{ type: 'housing', amount: 20000, taxable: true }],
|
|
146
|
+
* deductions: [{ type: 'insurance', amount: 5000 }],
|
|
147
|
+
* },
|
|
148
|
+
* },
|
|
149
|
+
* period: {
|
|
150
|
+
* month: 3,
|
|
151
|
+
* year: 2024,
|
|
152
|
+
* startDate: new Date('2024-03-01'),
|
|
153
|
+
* endDate: new Date('2024-03-31'),
|
|
154
|
+
* },
|
|
155
|
+
* attendance: {
|
|
156
|
+
* expectedDays: 22,
|
|
157
|
+
* actualDays: 20, // 2 days absent
|
|
158
|
+
* },
|
|
159
|
+
* options: {
|
|
160
|
+
* holidays: [new Date('2024-03-26')],
|
|
161
|
+
* },
|
|
162
|
+
* config: {
|
|
163
|
+
* allowProRating: true,
|
|
164
|
+
* autoDeductions: true,
|
|
165
|
+
* defaultCurrency: 'USD',
|
|
166
|
+
* attendanceIntegration: true,
|
|
167
|
+
* },
|
|
168
|
+
* taxBrackets: [...],
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @param input - Salary calculation parameters
|
|
173
|
+
* @returns Complete payroll breakdown
|
|
174
|
+
*
|
|
175
|
+
* @pure This function has no side effects and doesn't access database
|
|
176
|
+
*/
|
|
177
|
+
declare function calculateSalaryBreakdown(input: SalaryCalculationInput): PayrollBreakdown;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @classytic/payroll - Attendance Deduction Calculator
|
|
181
|
+
*
|
|
182
|
+
* Pure functions for calculating salary deductions based on attendance.
|
|
183
|
+
* No database dependencies - can be used client-side!
|
|
184
|
+
*
|
|
185
|
+
* All monetary calculations use banker's rounding for financial accuracy.
|
|
186
|
+
*
|
|
187
|
+
* @packageDocumentation
|
|
188
|
+
*/
|
|
189
|
+
/**
|
|
190
|
+
* Input for attendance deduction calculation
|
|
191
|
+
*/
|
|
192
|
+
interface AttendanceDeductionInput {
|
|
193
|
+
/**
|
|
194
|
+
* Expected working days in the period (for this specific employee)
|
|
195
|
+
* Should account for hire/termination dates
|
|
196
|
+
*/
|
|
197
|
+
expectedWorkingDays: number;
|
|
198
|
+
/**
|
|
199
|
+
* Actual working days the employee was present
|
|
200
|
+
*/
|
|
201
|
+
actualWorkingDays: number;
|
|
202
|
+
/**
|
|
203
|
+
* Daily salary rate for this employee
|
|
204
|
+
* Calculated as: baseAmount / expectedWorkingDays
|
|
205
|
+
*/
|
|
206
|
+
dailyRate: number;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Result of attendance deduction calculation
|
|
210
|
+
*/
|
|
211
|
+
interface AttendanceDeductionResult {
|
|
212
|
+
/**
|
|
213
|
+
* Number of absent days
|
|
214
|
+
*/
|
|
215
|
+
absentDays: number;
|
|
216
|
+
/**
|
|
217
|
+
* Total deduction amount
|
|
218
|
+
*/
|
|
219
|
+
deductionAmount: number;
|
|
220
|
+
/**
|
|
221
|
+
* Daily rate used for calculation
|
|
222
|
+
*/
|
|
223
|
+
dailyRate: number;
|
|
224
|
+
/**
|
|
225
|
+
* Whether any deduction was applied
|
|
226
|
+
*/
|
|
227
|
+
hasDeduction: boolean;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Calculate attendance deduction based on absent days
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const result = calculateAttendanceDeduction({
|
|
235
|
+
* expectedWorkingDays: 22,
|
|
236
|
+
* actualWorkingDays: 20, // 2 days absent
|
|
237
|
+
* dailyRate: 4545, // 100000 / 22
|
|
238
|
+
* });
|
|
239
|
+
*
|
|
240
|
+
* console.log(result);
|
|
241
|
+
* // {
|
|
242
|
+
* // absentDays: 2,
|
|
243
|
+
* // deductionAmount: 9090,
|
|
244
|
+
* // dailyRate: 4545,
|
|
245
|
+
* // hasDeduction: true
|
|
246
|
+
* // }
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @param input - Attendance deduction parameters
|
|
250
|
+
* @returns Deduction result with breakdown
|
|
251
|
+
*
|
|
252
|
+
* @pure This function has no side effects
|
|
253
|
+
*/
|
|
254
|
+
declare function calculateAttendanceDeduction(input: AttendanceDeductionInput): AttendanceDeductionResult;
|
|
255
|
+
/**
|
|
256
|
+
* Calculate daily rate from monthly salary and working days
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* const daily = calculateDailyRate(100000, 22); // 4545
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
263
|
+
* @param monthlySalary - Monthly base salary
|
|
264
|
+
* @param workingDays - Working days in the month
|
|
265
|
+
* @returns Daily rate (rounded)
|
|
266
|
+
*
|
|
267
|
+
* @pure No side effects
|
|
268
|
+
*/
|
|
269
|
+
declare function calculateDailyRate(monthlySalary: number, workingDays: number): number;
|
|
270
|
+
/**
|
|
271
|
+
* Calculate hourly rate from monthly salary
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* const hourly = calculateHourlyRate(100000, 22, 8); // 568
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @param monthlySalary - Monthly base salary
|
|
279
|
+
* @param workingDays - Working days in the month
|
|
280
|
+
* @param hoursPerDay - Hours per working day (default: 8)
|
|
281
|
+
* @returns Hourly rate (rounded)
|
|
282
|
+
*
|
|
283
|
+
* @pure No side effects
|
|
284
|
+
*/
|
|
285
|
+
declare function calculateHourlyRate(monthlySalary: number, workingDays: number, hoursPerDay?: number): number;
|
|
286
|
+
/**
|
|
287
|
+
* Calculate deduction for partial day absence (half-day, quarter-day, etc.)
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* // Half-day absence
|
|
292
|
+
* const deduction = calculatePartialDayDeduction(4545, 0.5); // 2272
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* @param dailyRate - Daily salary rate
|
|
296
|
+
* @param fractionAbsent - Fraction of day absent (0-1)
|
|
297
|
+
* @returns Deduction amount (rounded)
|
|
298
|
+
*
|
|
299
|
+
* @pure No side effects
|
|
300
|
+
*/
|
|
301
|
+
declare function calculatePartialDayDeduction(dailyRate: number, fractionAbsent: number): number;
|
|
302
|
+
/**
|
|
303
|
+
* Calculate total attendance deduction including full and partial day absences
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const result = calculateTotalAttendanceDeduction({
|
|
308
|
+
* dailyRate: 4545,
|
|
309
|
+
* fullDayAbsences: 2,
|
|
310
|
+
* partialDayAbsences: [0.5, 0.25], // Half-day + quarter-day
|
|
311
|
+
* });
|
|
312
|
+
*
|
|
313
|
+
* console.log(result);
|
|
314
|
+
* // {
|
|
315
|
+
* // fullDayDeduction: 9090,
|
|
316
|
+
* // partialDayDeduction: 3408,
|
|
317
|
+
* // totalDeduction: 12498
|
|
318
|
+
* // }
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* @param input - Absence breakdown
|
|
322
|
+
* @returns Deduction breakdown and total
|
|
323
|
+
*
|
|
324
|
+
* @pure No side effects
|
|
325
|
+
*/
|
|
326
|
+
declare function calculateTotalAttendanceDeduction(input: {
|
|
327
|
+
dailyRate: number;
|
|
328
|
+
fullDayAbsences?: number;
|
|
329
|
+
partialDayAbsences?: number[];
|
|
330
|
+
}): {
|
|
331
|
+
fullDayDeduction: number;
|
|
332
|
+
partialDayDeduction: number;
|
|
333
|
+
totalDeduction: number;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export { type AttendanceDeductionInput as A, type ProcessedAllowance as P, type SalaryCalculationInput as S, type AttendanceDeductionResult as a, type ProcessedDeduction as b, calculateAttendanceDeduction as c, calculateDailyRate as d, calculateHourlyRate as e, calculatePartialDayDeduction as f, calculateSalaryBreakdown as g, calculateTotalAttendanceDeduction as h };
|
|
@@ -1,300 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { P as ProRatingInput,
|
|
1
|
+
export { A as AttendanceDeductionInput, a as AttendanceDeductionResult, P as ProcessedAllowance, b as ProcessedDeduction, S as SalaryCalculationInput, c as calculateAttendanceDeduction, d as calculateDailyRate, e as calculateHourlyRate, f as calculatePartialDayDeduction, g as calculateSalaryBreakdown, h as calculateTotalAttendanceDeduction } from '../attendance.calculator-BZcv2iii.js';
|
|
2
|
+
export { P as ProRatingInput, a as ProRatingResult, b as applyProRating, c as calculateProRating, s as shouldProRate } from '../prorating.calculator-C33fWBQf.js';
|
|
3
|
+
import '../types-bZdAJueH.js';
|
|
3
4
|
import 'mongoose';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @classytic/payroll - Salary Calculator
|
|
7
|
-
*
|
|
8
|
-
* Pure functions for complete salary breakdown calculations.
|
|
9
|
-
* No database dependencies - can be used client-side!
|
|
10
|
-
*
|
|
11
|
-
* This is the SINGLE SOURCE OF TRUTH for all salary calculations.
|
|
12
|
-
*
|
|
13
|
-
* @packageDocumentation
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Input for salary breakdown calculation
|
|
18
|
-
*/
|
|
19
|
-
interface SalaryCalculationInput {
|
|
20
|
-
/**
|
|
21
|
-
* Employee data (minimal subset needed for calculation)
|
|
22
|
-
*/
|
|
23
|
-
employee: {
|
|
24
|
-
hireDate: Date;
|
|
25
|
-
terminationDate?: Date | null;
|
|
26
|
-
compensation: Compensation;
|
|
27
|
-
workSchedule?: {
|
|
28
|
-
workingDays?: number[];
|
|
29
|
-
hoursPerDay?: number;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Salary period
|
|
34
|
-
*/
|
|
35
|
-
period: {
|
|
36
|
-
month: number;
|
|
37
|
-
year: number;
|
|
38
|
-
startDate: Date;
|
|
39
|
-
endDate: Date;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Attendance data (optional)
|
|
43
|
-
*/
|
|
44
|
-
attendance?: {
|
|
45
|
-
expectedDays?: number;
|
|
46
|
-
actualDays?: number;
|
|
47
|
-
} | null;
|
|
48
|
-
/**
|
|
49
|
-
* Processing options
|
|
50
|
-
*/
|
|
51
|
-
options?: {
|
|
52
|
-
holidays?: Date[];
|
|
53
|
-
workSchedule?: {
|
|
54
|
-
workingDays?: number[];
|
|
55
|
-
hoursPerDay?: number;
|
|
56
|
-
};
|
|
57
|
-
skipTax?: boolean;
|
|
58
|
-
skipAttendance?: boolean;
|
|
59
|
-
skipProration?: boolean;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Configuration (minimal subset)
|
|
63
|
-
*/
|
|
64
|
-
config: {
|
|
65
|
-
allowProRating: boolean;
|
|
66
|
-
autoDeductions: boolean;
|
|
67
|
-
defaultCurrency: string;
|
|
68
|
-
attendanceIntegration: boolean;
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Tax brackets for the employee's currency
|
|
72
|
-
*/
|
|
73
|
-
taxBrackets: TaxBracket[];
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Processed allowance with calculated amount
|
|
77
|
-
*/
|
|
78
|
-
interface ProcessedAllowance {
|
|
79
|
-
type: string;
|
|
80
|
-
amount: number;
|
|
81
|
-
taxable: boolean;
|
|
82
|
-
originalAmount?: number;
|
|
83
|
-
isPercentage?: boolean;
|
|
84
|
-
value?: number;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Processed deduction with calculated amount
|
|
88
|
-
*/
|
|
89
|
-
interface ProcessedDeduction {
|
|
90
|
-
type: string;
|
|
91
|
-
amount: number;
|
|
92
|
-
description?: string;
|
|
93
|
-
originalAmount?: number;
|
|
94
|
-
isPercentage?: boolean;
|
|
95
|
-
value?: number;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Calculate complete salary breakdown
|
|
99
|
-
*
|
|
100
|
-
* This is the SINGLE SOURCE OF TRUTH for salary calculations.
|
|
101
|
-
* All payroll processing uses this function.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```typescript
|
|
105
|
-
* const breakdown = calculateSalaryBreakdown({
|
|
106
|
-
* employee: {
|
|
107
|
-
* hireDate: new Date('2024-01-01'),
|
|
108
|
-
* compensation: {
|
|
109
|
-
* baseAmount: 100000,
|
|
110
|
-
* currency: 'USD',
|
|
111
|
-
* allowances: [{ type: 'housing', amount: 20000, taxable: true }],
|
|
112
|
-
* deductions: [{ type: 'insurance', amount: 5000 }],
|
|
113
|
-
* },
|
|
114
|
-
* },
|
|
115
|
-
* period: {
|
|
116
|
-
* month: 3,
|
|
117
|
-
* year: 2024,
|
|
118
|
-
* startDate: new Date('2024-03-01'),
|
|
119
|
-
* endDate: new Date('2024-03-31'),
|
|
120
|
-
* },
|
|
121
|
-
* attendance: {
|
|
122
|
-
* expectedDays: 22,
|
|
123
|
-
* actualDays: 20, // 2 days absent
|
|
124
|
-
* },
|
|
125
|
-
* options: {
|
|
126
|
-
* holidays: [new Date('2024-03-26')],
|
|
127
|
-
* },
|
|
128
|
-
* config: {
|
|
129
|
-
* allowProRating: true,
|
|
130
|
-
* autoDeductions: true,
|
|
131
|
-
* defaultCurrency: 'USD',
|
|
132
|
-
* attendanceIntegration: true,
|
|
133
|
-
* },
|
|
134
|
-
* taxBrackets: [...],
|
|
135
|
-
* });
|
|
136
|
-
* ```
|
|
137
|
-
*
|
|
138
|
-
* @param input - Salary calculation parameters
|
|
139
|
-
* @returns Complete payroll breakdown
|
|
140
|
-
*
|
|
141
|
-
* @pure This function has no side effects and doesn't access database
|
|
142
|
-
*/
|
|
143
|
-
declare function calculateSalaryBreakdown(input: SalaryCalculationInput): PayrollBreakdown;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @classytic/payroll - Attendance Deduction Calculator
|
|
147
|
-
*
|
|
148
|
-
* Pure functions for calculating salary deductions based on attendance.
|
|
149
|
-
* No database dependencies - can be used client-side!
|
|
150
|
-
*
|
|
151
|
-
* @packageDocumentation
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* Input for attendance deduction calculation
|
|
155
|
-
*/
|
|
156
|
-
interface AttendanceDeductionInput {
|
|
157
|
-
/**
|
|
158
|
-
* Expected working days in the period (for this specific employee)
|
|
159
|
-
* Should account for hire/termination dates
|
|
160
|
-
*/
|
|
161
|
-
expectedWorkingDays: number;
|
|
162
|
-
/**
|
|
163
|
-
* Actual working days the employee was present
|
|
164
|
-
*/
|
|
165
|
-
actualWorkingDays: number;
|
|
166
|
-
/**
|
|
167
|
-
* Daily salary rate for this employee
|
|
168
|
-
* Calculated as: baseAmount / expectedWorkingDays
|
|
169
|
-
*/
|
|
170
|
-
dailyRate: number;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Result of attendance deduction calculation
|
|
174
|
-
*/
|
|
175
|
-
interface AttendanceDeductionResult {
|
|
176
|
-
/**
|
|
177
|
-
* Number of absent days
|
|
178
|
-
*/
|
|
179
|
-
absentDays: number;
|
|
180
|
-
/**
|
|
181
|
-
* Total deduction amount
|
|
182
|
-
*/
|
|
183
|
-
deductionAmount: number;
|
|
184
|
-
/**
|
|
185
|
-
* Daily rate used for calculation
|
|
186
|
-
*/
|
|
187
|
-
dailyRate: number;
|
|
188
|
-
/**
|
|
189
|
-
* Whether any deduction was applied
|
|
190
|
-
*/
|
|
191
|
-
hasDeduction: boolean;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Calculate attendance deduction based on absent days
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* ```typescript
|
|
198
|
-
* const result = calculateAttendanceDeduction({
|
|
199
|
-
* expectedWorkingDays: 22,
|
|
200
|
-
* actualWorkingDays: 20, // 2 days absent
|
|
201
|
-
* dailyRate: 4545, // 100000 / 22
|
|
202
|
-
* });
|
|
203
|
-
*
|
|
204
|
-
* console.log(result);
|
|
205
|
-
* // {
|
|
206
|
-
* // absentDays: 2,
|
|
207
|
-
* // deductionAmount: 9090,
|
|
208
|
-
* // dailyRate: 4545,
|
|
209
|
-
* // hasDeduction: true
|
|
210
|
-
* // }
|
|
211
|
-
* ```
|
|
212
|
-
*
|
|
213
|
-
* @param input - Attendance deduction parameters
|
|
214
|
-
* @returns Deduction result with breakdown
|
|
215
|
-
*
|
|
216
|
-
* @pure This function has no side effects
|
|
217
|
-
*/
|
|
218
|
-
declare function calculateAttendanceDeduction(input: AttendanceDeductionInput): AttendanceDeductionResult;
|
|
219
|
-
/**
|
|
220
|
-
* Calculate daily rate from monthly salary and working days
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```typescript
|
|
224
|
-
* const daily = calculateDailyRate(100000, 22); // 4545
|
|
225
|
-
* ```
|
|
226
|
-
*
|
|
227
|
-
* @param monthlySalary - Monthly base salary
|
|
228
|
-
* @param workingDays - Working days in the month
|
|
229
|
-
* @returns Daily rate (rounded)
|
|
230
|
-
*
|
|
231
|
-
* @pure No side effects
|
|
232
|
-
*/
|
|
233
|
-
declare function calculateDailyRate(monthlySalary: number, workingDays: number): number;
|
|
234
|
-
/**
|
|
235
|
-
* Calculate hourly rate from monthly salary
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* ```typescript
|
|
239
|
-
* const hourly = calculateHourlyRate(100000, 22, 8); // 568
|
|
240
|
-
* ```
|
|
241
|
-
*
|
|
242
|
-
* @param monthlySalary - Monthly base salary
|
|
243
|
-
* @param workingDays - Working days in the month
|
|
244
|
-
* @param hoursPerDay - Hours per working day (default: 8)
|
|
245
|
-
* @returns Hourly rate (rounded)
|
|
246
|
-
*
|
|
247
|
-
* @pure No side effects
|
|
248
|
-
*/
|
|
249
|
-
declare function calculateHourlyRate(monthlySalary: number, workingDays: number, hoursPerDay?: number): number;
|
|
250
|
-
/**
|
|
251
|
-
* Calculate deduction for partial day absence (half-day, quarter-day, etc.)
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```typescript
|
|
255
|
-
* // Half-day absence
|
|
256
|
-
* const deduction = calculatePartialDayDeduction(4545, 0.5); // 2272
|
|
257
|
-
* ```
|
|
258
|
-
*
|
|
259
|
-
* @param dailyRate - Daily salary rate
|
|
260
|
-
* @param fractionAbsent - Fraction of day absent (0-1)
|
|
261
|
-
* @returns Deduction amount (rounded)
|
|
262
|
-
*
|
|
263
|
-
* @pure No side effects
|
|
264
|
-
*/
|
|
265
|
-
declare function calculatePartialDayDeduction(dailyRate: number, fractionAbsent: number): number;
|
|
266
|
-
/**
|
|
267
|
-
* Calculate total attendance deduction including full and partial day absences
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* ```typescript
|
|
271
|
-
* const result = calculateTotalAttendanceDeduction({
|
|
272
|
-
* dailyRate: 4545,
|
|
273
|
-
* fullDayAbsences: 2,
|
|
274
|
-
* partialDayAbsences: [0.5, 0.25], // Half-day + quarter-day
|
|
275
|
-
* });
|
|
276
|
-
*
|
|
277
|
-
* console.log(result);
|
|
278
|
-
* // {
|
|
279
|
-
* // fullDayDeduction: 9090,
|
|
280
|
-
* // partialDayDeduction: 3408,
|
|
281
|
-
* // totalDeduction: 12498
|
|
282
|
-
* // }
|
|
283
|
-
* ```
|
|
284
|
-
*
|
|
285
|
-
* @param input - Absence breakdown
|
|
286
|
-
* @returns Deduction breakdown and total
|
|
287
|
-
*
|
|
288
|
-
* @pure No side effects
|
|
289
|
-
*/
|
|
290
|
-
declare function calculateTotalAttendanceDeduction(input: {
|
|
291
|
-
dailyRate: number;
|
|
292
|
-
fullDayAbsences?: number;
|
|
293
|
-
partialDayAbsences?: number[];
|
|
294
|
-
}): {
|
|
295
|
-
fullDayDeduction: number;
|
|
296
|
-
partialDayDeduction: number;
|
|
297
|
-
totalDeduction: number;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
export { type AttendanceDeductionInput, type AttendanceDeductionResult, type ProcessedAllowance, type ProcessedDeduction, type SalaryCalculationInput, calculateAttendanceDeduction, calculateDailyRate, calculateHourlyRate, calculatePartialDayDeduction, calculateSalaryBreakdown, calculateTotalAttendanceDeduction };
|