@classytic/payroll 1.0.2 → 2.3.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.
- package/README.md +2599 -574
- package/dist/calculators/index.d.ts +433 -0
- package/dist/calculators/index.js +283 -0
- package/dist/calculators/index.js.map +1 -0
- package/dist/core/index.d.ts +314 -0
- package/dist/core/index.js +1166 -0
- package/dist/core/index.js.map +1 -0
- package/dist/employee-identity-DXhgOgXE.d.ts +473 -0
- package/dist/employee.factory-BlZqhiCk.d.ts +189 -0
- package/dist/idempotency-Cw2CWicb.d.ts +52 -0
- package/dist/index.d.ts +902 -0
- package/dist/index.js +9108 -0
- package/dist/index.js.map +1 -0
- package/dist/jurisdiction/index.d.ts +660 -0
- package/dist/jurisdiction/index.js +533 -0
- package/dist/jurisdiction/index.js.map +1 -0
- package/dist/payroll.d.ts +429 -0
- package/dist/payroll.js +5192 -0
- package/dist/payroll.js.map +1 -0
- package/dist/schemas/index.d.ts +3262 -0
- package/dist/schemas/index.js +780 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/services/index.d.ts +582 -0
- package/dist/services/index.js +2172 -0
- package/dist/services/index.js.map +1 -0
- package/dist/shift-compliance/index.d.ts +1171 -0
- package/dist/shift-compliance/index.js +1479 -0
- package/dist/shift-compliance/index.js.map +1 -0
- package/dist/types-BN3K_Uhr.d.ts +1842 -0
- package/dist/utils/index.d.ts +893 -0
- package/dist/utils/index.js +1515 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +72 -37
- package/dist/types/config.d.ts +0 -162
- package/dist/types/core/compensation.manager.d.ts +0 -54
- package/dist/types/core/employment.manager.d.ts +0 -49
- package/dist/types/core/payroll.manager.d.ts +0 -60
- package/dist/types/enums.d.ts +0 -117
- package/dist/types/factories/compensation.factory.d.ts +0 -196
- package/dist/types/factories/employee.factory.d.ts +0 -149
- package/dist/types/factories/payroll.factory.d.ts +0 -319
- package/dist/types/hrm.orchestrator.d.ts +0 -47
- package/dist/types/index.d.ts +0 -20
- package/dist/types/init.d.ts +0 -30
- package/dist/types/models/payroll-record.model.d.ts +0 -3
- package/dist/types/plugins/employee.plugin.d.ts +0 -2
- package/dist/types/schemas/employment.schema.d.ts +0 -959
- package/dist/types/services/compensation.service.d.ts +0 -94
- package/dist/types/services/employee.service.d.ts +0 -28
- package/dist/types/services/payroll.service.d.ts +0 -30
- package/dist/types/utils/calculation.utils.d.ts +0 -26
- package/dist/types/utils/date.utils.d.ts +0 -35
- package/dist/types/utils/logger.d.ts +0 -12
- package/dist/types/utils/query-builders.d.ts +0 -83
- package/dist/types/utils/validation.utils.d.ts +0 -33
- package/payroll.d.ts +0 -241
- 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 -413
- package/src/hrm.orchestrator.js +0 -139
- package/src/index.js +0 -172
- package/src/init.js +0 -62
- package/src/models/payroll-record.model.js +0 -126
- package/src/plugins/employee.plugin.js +0 -164
- 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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,902 @@
|
|
|
1
|
+
export { Payroll, PayrollBuilder, createPayrollInstance } from './payroll.js';
|
|
2
|
+
import { O as ObjectIdLike, aM as PayrollBreakdown, aF as LeaveType, aY as LeaveRequestStatus, aR as TaxType, aS as TaxStatus, z as HRMConfig, D as DeepPartial, I as Department, F as EmploymentType, aZ as OrgRole, aJ as LeaveInitConfig, a_ as HttpError, a$ as ErrorCode, aw as AttendanceInput, y as LeaveRequestDocument, v as TaxWithholdingDocument } from './types-BN3K_Uhr.js';
|
|
3
|
+
export { bm as AccrueLeaveOptions, j as AddAllowanceParams, l as AddDeductionParams, N as Allowance, bf as AllowanceType, A as AnyDocument, aP as AnyModel, V as BankDetails, bp as BulkPayrollProgress, B as BulkPayrollResult, X as Compensation, aO as CompensationBreakdownResult, b2 as DataRetentionConfig, Q as Deduction, bg as DeductionType, E as EmployeeDocument, bv as EmployeeHiredEvent, b7 as EmployeeIdMode, h as EmployeeIdentityMode, bo as EmployeeOperationParams, aK as EmployeeStatus, aW as EmployeeValidationResult, b5 as EmploymentConfig, bd as EmploymentHistoryEntry, bx as EventPayload, bu as EventPayloadBase, u as ExportPayrollParams, b1 as FilterQuery, G as GetPendingTaxParams, bi as HRMTransactionCategory, H as HireEmployeeParams, aH as LeaveBalance, bl as LeaveHistoryFilters, aI as LeaveSummaryResult, L as ListEmployeesParams, C as Logger, M as MarkTaxPaidParams, b0 as Nullable, g as OperationContext, aT as PayPeriodInfo, K as PaymentFrequency, aN as PaymentMethod, b3 as PayrollConfig, bc as PayrollCorrection, bz as PayrollEmployee, bt as PayrollEvent, r as PayrollHistoryParams, b as PayrollInitConfig, a as PayrollInstance, aL as PayrollPeriod, bq as PayrollPlugin, P as PayrollRecordDocument, bb as PayrollStats, aX as PayrollStatus, s as PayrollSummaryParams, t as PayrollSummaryResult, br as PluginFunction, bs as PluginType, q as ProcessBulkPayrollParams, o as ProcessSalaryParams, p as ProcessSalaryResult, by as QueryOptions, R as ReHireEmployeeParams, k as RemoveAllowanceParams, m as RemoveDeductionParams, bj as RequestLeaveInput, bn as ResetAnnualLeaveOptions, bk as ReviewLeaveRequestInput, ba as RoleMappingConfig, bh as SalaryBand, b9 as SalaryBandRange, b4 as SalaryConfig, bw as SalaryProcessedEvent, S as SingleTenantConfig, b8 as TaxBracket, aV as TaxCalculationResult, bB as TaxSummaryByType, w as TaxSummaryParams, x as TaxSummaryResult, T as TerminateEmployeeParams, Y as TerminationReason, n as UpdateBankDetailsParams, U as UpdateEmploymentParams, i as UpdateSalaryParams, be as UserReference, b6 as ValidationConfig, W as WebhookConfig, f as WebhookDelivery, ag as WebhookManager, bA as WithPayroll, J as WorkSchedule, aG as WorkingDaysOptions } from './types-BN3K_Uhr.js';
|
|
4
|
+
import { ITransaction, ITransactionCreateInput } from '@classytic/shared-types';
|
|
5
|
+
export { I as IdempotencyManager, a as IdempotentResult, g as generatePayrollIdempotencyKey } from './idempotency-Cw2CWicb.js';
|
|
6
|
+
export { allowanceSchema, applyEmployeeIndexes, applyLeaveRequestIndexes, applyPayrollRecordIndexes, applyTaxWithholdingIndexes, bankDetailsSchema, compensationSchema, createEmployeeSchema, createLeaveRequestSchema, createPayrollRecordSchema, createTaxWithholdingSchema, deductionSchema, employmentFields, employmentHistorySchema, leaveBalanceFields, leaveBalanceSchema, leaveRequestFields, leaveRequestIndexes, payrollStatsSchema, taxWithholdingFields, taxWithholdingIndexes, workScheduleSchema } from './schemas/index.js';
|
|
7
|
+
import mongoose__default, { Schema, Model } from 'mongoose';
|
|
8
|
+
export { C as CreateEmployeeParams, a as EmployeeBuilder, b as EmployeeData, E as EmployeeFactory, T as TerminationData, c as createEmployee } from './employee.factory-BlZqhiCk.js';
|
|
9
|
+
export { C as ContainerLike, a as DEFAULT_CARRY_OVER, D as DEFAULT_LEAVE_ALLOCATIONS, z as EmployeeIdType, A as EmployeeQueryFilter, R as ResolveOrganizationIdParams, S as SecureEmployeeLookupOptions, l as accrueLeaveToBalance, k as calculateCarryOver, c as calculateLeaveDays, f as calculateUnpaidLeaveDeduction, s as detectEmployeeIdType, n as employeeExistsSecure, m as findEmployeeSecure, o as findEmployeesSecure, y as formatEmployeeId, d as getAvailableDays, g as getLeaveBalance, b as getLeaveBalances, e as getLeaveSummary, j as getUnpaidLeaveDays, h as hasLeaveBalance, i as initializeLeaveBalances, x as isObjectIdEmployeeId, w as isStringEmployeeId, u as normalizeEmployeeId, p as proRateAllocation, r as requireOrganizationId, q as resolveOrganizationId, t as tryResolveOrganizationId, v as validateOrganizationId } from './employee-identity-DXhgOgXE.js';
|
|
10
|
+
export { AttendanceDeductionInput, AttendanceDeductionResult, ProRatingInput, ProRatingResult, ProcessedAllowance, ProcessedDeduction, SalaryCalculationInput, applyProRating, calculateAttendanceDeduction, calculateDailyRate, calculateHourlyRate, calculatePartialDayDeduction, calculateProRating, calculateSalaryBreakdown, calculateTotalAttendanceDeduction, shouldProRate } from './calculators/index.js';
|
|
11
|
+
export { AttendancePolicy, AttendancePolicyBuilder, AttendancePolicyDocument, AttendancePolicyModel, AttendancePolicySchema, AttendancePolicySchemaDefinition, CalculateShiftComplianceInput, ClockRoundingPolicy, ClockRoundingPolicyBuilder, ClockRoundingPolicySchema, ClockRoundingPolicySchemaDefinition, DEFAULT_ATTENDANCE_POLICY, EarlyDeparturePenaltyResult, EarlyDeparturePolicy, EarlyDeparturePolicySchema, EarlyDeparturePolicySchemaDefinition, EarlyOccurrence, HEALTHCARE_POLICY, HOSPITALITY_POLICY, LateArrivalPolicy, LateArrivalPolicySchema, LateArrivalPolicySchemaDefinition, LateOccurrence, LatePenaltyResult, LatePolicyBuilder, MANUFACTURING_POLICY, MaxPenaltiesPerPeriod, MaxPenaltiesSchema, MaxPenaltiesSchemaDefinition, NightShiftDifferential, NightShiftDifferentialSchema, NightShiftDifferentialSchemaDefinition, OFFICE_POLICY, OvertimeBonusResult, OvertimeMode, OvertimeOccurrence, OvertimePolicy, OvertimePolicyBuilder, OvertimePolicySchema, OvertimePolicySchemaDefinition, PenaltyMode, PenaltyOverride, PenaltyTier, PenaltyTierSchema, PenaltyTierSchemaDefinition, RETAIL_POLICY, ResetPeriod, RoundingMode, ShiftComplianceData, ShiftComplianceResult, ShiftDifferentialResult, TieredPenaltyBuilder, WeekendPremium, WeekendPremiumSchema, WeekendPremiumSchemaDefinition, calculateDailyOvertime, calculateFlatPenalty, calculateLatePenalty, calculateMonthlyOvertime, calculateNightShiftDifferential, calculateOvertimeBonus, calculatePerMinutePenalty, calculatePercentagePenalty, calculateShiftCompliance, calculateTieredPenalty, calculateWeekendPremium, calculateWeeklyOvertime, createClockRoundingPolicyBuilder, createLatePolicyBuilder, createOvertimePolicyBuilder, createPolicyFromPreset } from './shift-compliance/index.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Transaction Interface
|
|
15
|
+
* @classytic/payroll
|
|
16
|
+
*
|
|
17
|
+
* Payroll uses the unified transaction interface from @classytic/shared-types
|
|
18
|
+
* so revenue and payroll share a single cashflow event model.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Core transaction interface expected by payroll package
|
|
23
|
+
* Apps must provide a Transaction model with AT LEAST these fields
|
|
24
|
+
*/
|
|
25
|
+
type IPayrollTransaction = ITransaction;
|
|
26
|
+
/**
|
|
27
|
+
* Transaction write input (what payroll package creates)
|
|
28
|
+
*/
|
|
29
|
+
type IPayrollTransactionCreateInput = ITransactionCreateInput;
|
|
30
|
+
/**
|
|
31
|
+
* Type guard to check if object is a Transaction
|
|
32
|
+
*/
|
|
33
|
+
declare function isPayrollTransaction(obj: unknown): obj is IPayrollTransaction;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @classytic/payroll - Transaction Factory
|
|
37
|
+
*
|
|
38
|
+
* Pure functions for building transaction objects aligned with @classytic/shared-types.
|
|
39
|
+
* Ensures consistency with revenue package for unified cashflow.
|
|
40
|
+
*
|
|
41
|
+
* @packageDocumentation
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Input for creating a payroll transaction
|
|
46
|
+
*/
|
|
47
|
+
interface CreatePayrollTransactionInput {
|
|
48
|
+
organizationId: ObjectIdLike;
|
|
49
|
+
employee: {
|
|
50
|
+
_id: ObjectIdLike;
|
|
51
|
+
userId?: ObjectIdLike | {
|
|
52
|
+
_id: ObjectIdLike;
|
|
53
|
+
name?: string;
|
|
54
|
+
} | null;
|
|
55
|
+
employeeId: string;
|
|
56
|
+
email?: string;
|
|
57
|
+
compensation: {
|
|
58
|
+
currency: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
payrollRecord: {
|
|
62
|
+
_id: ObjectIdLike;
|
|
63
|
+
};
|
|
64
|
+
breakdown: PayrollBreakdown;
|
|
65
|
+
period: {
|
|
66
|
+
month: number;
|
|
67
|
+
year: number;
|
|
68
|
+
};
|
|
69
|
+
paymentDate: Date;
|
|
70
|
+
paymentMethod?: string;
|
|
71
|
+
processedBy?: ObjectIdLike;
|
|
72
|
+
idempotencyKey?: string;
|
|
73
|
+
jurisdiction?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Input for creating a tax payment transaction
|
|
77
|
+
*/
|
|
78
|
+
interface CreateTaxPaymentTransactionInput {
|
|
79
|
+
organizationId: ObjectIdLike;
|
|
80
|
+
totalAmount: number;
|
|
81
|
+
currency: string;
|
|
82
|
+
referenceNumber?: string;
|
|
83
|
+
notes?: string;
|
|
84
|
+
withholdingIds: ObjectIdLike[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create payroll transaction aligned with @classytic/shared-types
|
|
88
|
+
*
|
|
89
|
+
* This is the SINGLE SOURCE OF TRUTH for payroll transaction structure.
|
|
90
|
+
* Aligns with revenue package for unified cashflow.
|
|
91
|
+
*
|
|
92
|
+
* @param input - Payroll transaction parameters
|
|
93
|
+
* @returns Transaction data ready for DB creation (ITransactionCreateInput)
|
|
94
|
+
*
|
|
95
|
+
* @pure This function has no side effects
|
|
96
|
+
*/
|
|
97
|
+
declare function createPayrollTransaction(input: CreatePayrollTransactionInput): ITransactionCreateInput;
|
|
98
|
+
/**
|
|
99
|
+
* Create tax payment transaction aligned with @classytic/shared-types
|
|
100
|
+
*
|
|
101
|
+
* For government tax payments (withholding remittance).
|
|
102
|
+
*
|
|
103
|
+
* @param input - Tax payment parameters
|
|
104
|
+
* @returns Transaction data ready for DB creation (ITransactionCreateInput)
|
|
105
|
+
*
|
|
106
|
+
* @pure This function has no side effects
|
|
107
|
+
*/
|
|
108
|
+
declare function createTaxPaymentTransaction(input: CreateTaxPaymentTransactionInput): ITransactionCreateInput;
|
|
109
|
+
/**
|
|
110
|
+
* Transaction Factory class (for builder pattern if needed)
|
|
111
|
+
*/
|
|
112
|
+
declare class TransactionFactory {
|
|
113
|
+
static createPayrollTransaction: typeof createPayrollTransaction;
|
|
114
|
+
static createTaxPaymentTransaction: typeof createTaxPaymentTransaction;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare const EMPLOYMENT_TYPE: {
|
|
118
|
+
readonly FULL_TIME: "full_time";
|
|
119
|
+
readonly PART_TIME: "part_time";
|
|
120
|
+
readonly CONTRACT: "contract";
|
|
121
|
+
readonly INTERN: "intern";
|
|
122
|
+
readonly CONSULTANT: "consultant";
|
|
123
|
+
};
|
|
124
|
+
declare const EMPLOYEE_STATUS: {
|
|
125
|
+
readonly ACTIVE: "active";
|
|
126
|
+
readonly ON_LEAVE: "on_leave";
|
|
127
|
+
readonly SUSPENDED: "suspended";
|
|
128
|
+
readonly TERMINATED: "terminated";
|
|
129
|
+
};
|
|
130
|
+
declare const DEPARTMENT: {
|
|
131
|
+
readonly MANAGEMENT: "management";
|
|
132
|
+
readonly TRAINING: "training";
|
|
133
|
+
readonly SALES: "sales";
|
|
134
|
+
readonly OPERATIONS: "operations";
|
|
135
|
+
readonly SUPPORT: "support";
|
|
136
|
+
readonly HR: "hr";
|
|
137
|
+
readonly MAINTENANCE: "maintenance";
|
|
138
|
+
readonly MARKETING: "marketing";
|
|
139
|
+
readonly FINANCE: "finance";
|
|
140
|
+
readonly IT: "it";
|
|
141
|
+
};
|
|
142
|
+
declare const PAYMENT_FREQUENCY: {
|
|
143
|
+
readonly MONTHLY: "monthly";
|
|
144
|
+
readonly BI_WEEKLY: "bi_weekly";
|
|
145
|
+
readonly WEEKLY: "weekly";
|
|
146
|
+
readonly HOURLY: "hourly";
|
|
147
|
+
readonly DAILY: "daily";
|
|
148
|
+
};
|
|
149
|
+
declare const ALLOWANCE_TYPE: {
|
|
150
|
+
readonly HOUSING: "housing";
|
|
151
|
+
readonly TRANSPORT: "transport";
|
|
152
|
+
readonly MEAL: "meal";
|
|
153
|
+
readonly MOBILE: "mobile";
|
|
154
|
+
readonly MEDICAL: "medical";
|
|
155
|
+
readonly EDUCATION: "education";
|
|
156
|
+
readonly BONUS: "bonus";
|
|
157
|
+
readonly OTHER: "other";
|
|
158
|
+
};
|
|
159
|
+
declare const DEDUCTION_TYPE: {
|
|
160
|
+
readonly TAX: "tax";
|
|
161
|
+
readonly LOAN: "loan";
|
|
162
|
+
readonly ADVANCE: "advance";
|
|
163
|
+
readonly PROVIDENT_FUND: "provident_fund";
|
|
164
|
+
readonly INSURANCE: "insurance";
|
|
165
|
+
readonly ABSENCE: "absence";
|
|
166
|
+
readonly OTHER: "other";
|
|
167
|
+
};
|
|
168
|
+
declare const PAYROLL_STATUS: {
|
|
169
|
+
readonly PENDING: "pending";
|
|
170
|
+
readonly PROCESSING: "processing";
|
|
171
|
+
readonly PAID: "paid";
|
|
172
|
+
readonly FAILED: "failed";
|
|
173
|
+
readonly CANCELLED: "cancelled";
|
|
174
|
+
};
|
|
175
|
+
declare const TERMINATION_REASON: {
|
|
176
|
+
readonly RESIGNATION: "resignation";
|
|
177
|
+
readonly RETIREMENT: "retirement";
|
|
178
|
+
readonly TERMINATION: "termination";
|
|
179
|
+
readonly CONTRACT_END: "contract_end";
|
|
180
|
+
readonly MUTUAL_AGREEMENT: "mutual_agreement";
|
|
181
|
+
readonly OTHER: "other";
|
|
182
|
+
};
|
|
183
|
+
declare const LEAVE_TYPE: {
|
|
184
|
+
readonly ANNUAL: "annual";
|
|
185
|
+
readonly SICK: "sick";
|
|
186
|
+
readonly UNPAID: "unpaid";
|
|
187
|
+
readonly MATERNITY: "maternity";
|
|
188
|
+
readonly PATERNITY: "paternity";
|
|
189
|
+
readonly BEREAVEMENT: "bereavement";
|
|
190
|
+
readonly COMPENSATORY: "compensatory";
|
|
191
|
+
readonly OTHER: "other";
|
|
192
|
+
};
|
|
193
|
+
declare function isValidLeaveType(value: string): value is LeaveType;
|
|
194
|
+
declare function isPaidLeaveType(type: LeaveType): boolean;
|
|
195
|
+
declare const LEAVE_REQUEST_STATUS: {
|
|
196
|
+
readonly PENDING: "pending";
|
|
197
|
+
readonly APPROVED: "approved";
|
|
198
|
+
readonly REJECTED: "rejected";
|
|
199
|
+
readonly CANCELLED: "cancelled";
|
|
200
|
+
};
|
|
201
|
+
declare function isValidLeaveRequestStatus(value: string): value is LeaveRequestStatus;
|
|
202
|
+
declare function isPendingLeaveStatus(status: LeaveRequestStatus): boolean;
|
|
203
|
+
declare function isApprovedLeaveStatus(status: LeaveRequestStatus): boolean;
|
|
204
|
+
declare const TAX_TYPE: {
|
|
205
|
+
readonly INCOME_TAX: "income_tax";
|
|
206
|
+
readonly SOCIAL_SECURITY: "social_security";
|
|
207
|
+
readonly HEALTH_INSURANCE: "health_insurance";
|
|
208
|
+
readonly PENSION: "pension";
|
|
209
|
+
readonly EMPLOYMENT_INSURANCE: "employment_insurance";
|
|
210
|
+
readonly LOCAL_TAX: "local_tax";
|
|
211
|
+
readonly OTHER: "other";
|
|
212
|
+
};
|
|
213
|
+
declare const TAX_TYPE_VALUES: ("other" | "income_tax" | "social_security" | "health_insurance" | "pension" | "employment_insurance" | "local_tax")[];
|
|
214
|
+
declare function isValidTaxType(value: string): value is TaxType;
|
|
215
|
+
declare const TAX_STATUS: {
|
|
216
|
+
readonly PENDING: "pending";
|
|
217
|
+
readonly SUBMITTED: "submitted";
|
|
218
|
+
readonly PAID: "paid";
|
|
219
|
+
};
|
|
220
|
+
declare const TAX_STATUS_VALUES: ("pending" | "paid" | "submitted")[];
|
|
221
|
+
declare function isValidTaxStatus(value: string): value is TaxStatus;
|
|
222
|
+
declare function isPendingTaxStatus(status: TaxStatus): boolean;
|
|
223
|
+
declare function isPaidTaxStatus(status: TaxStatus): boolean;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @classytic/payroll - Configuration
|
|
227
|
+
*
|
|
228
|
+
* Centralized configuration with type safety
|
|
229
|
+
* Configurable defaults for different use cases
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
declare const HRM_CONFIG: HRMConfig;
|
|
233
|
+
/**
|
|
234
|
+
* Determine the appropriate organization role for an employee
|
|
235
|
+
*/
|
|
236
|
+
declare function determineOrgRole(employmentData: {
|
|
237
|
+
department?: Department | string;
|
|
238
|
+
type?: EmploymentType | string;
|
|
239
|
+
position?: string;
|
|
240
|
+
}): OrgRole;
|
|
241
|
+
/**
|
|
242
|
+
* Merge configuration with defaults
|
|
243
|
+
*/
|
|
244
|
+
declare function mergeConfig(customConfig: Partial<HRMConfig> | DeepPartial<HRMConfig> | undefined): HRMConfig;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @classytic/payroll - Employee Plugin
|
|
248
|
+
*
|
|
249
|
+
* Mongoose plugin that adds HRM methods and virtuals to Employee schema
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
interface EmployeePluginOptions {
|
|
253
|
+
/** Require bank details for salary payment */
|
|
254
|
+
requireBankDetails?: boolean;
|
|
255
|
+
/** Field name for compensation */
|
|
256
|
+
compensationField?: string;
|
|
257
|
+
/** Field name for status */
|
|
258
|
+
statusField?: string;
|
|
259
|
+
/** Enable auto salary calculation on save */
|
|
260
|
+
autoCalculateSalary?: boolean;
|
|
261
|
+
/** Create indexes on schema (default: false) */
|
|
262
|
+
createIndexes?: boolean;
|
|
263
|
+
/** Enable leave management methods (default: false) */
|
|
264
|
+
enableLeave?: boolean;
|
|
265
|
+
/** Leave configuration */
|
|
266
|
+
leaveConfig?: LeaveInitConfig;
|
|
267
|
+
/** Field name for leave balances (default: 'leaveBalances') */
|
|
268
|
+
leaveBalancesField?: string;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Mongoose plugin that adds HRM functionality to Employee schema
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* const employeeSchema = new Schema({
|
|
275
|
+
* ...employmentFields,
|
|
276
|
+
* // Custom fields
|
|
277
|
+
* });
|
|
278
|
+
*
|
|
279
|
+
* employeeSchema.plugin(employeePlugin);
|
|
280
|
+
*/
|
|
281
|
+
declare function employeePlugin(schema: Schema, options?: EmployeePluginOptions): void;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @classytic/payroll - Error Handling
|
|
285
|
+
*
|
|
286
|
+
* Custom error classes with error codes and HTTP status
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
declare class PayrollError extends Error implements HttpError {
|
|
290
|
+
readonly code: ErrorCode;
|
|
291
|
+
readonly status: number;
|
|
292
|
+
readonly context: Record<string, unknown>;
|
|
293
|
+
readonly timestamp: Date;
|
|
294
|
+
/**
|
|
295
|
+
* Create a PayrollError.
|
|
296
|
+
*
|
|
297
|
+
* Supports BOTH constructor styles for backwards compatibility:
|
|
298
|
+
* - new PayrollError(message, code?, status?, context?)
|
|
299
|
+
* - new PayrollError(code, status, message, context?)
|
|
300
|
+
*/
|
|
301
|
+
constructor(messageOrCode: string | ErrorCode, codeOrStatus?: ErrorCode | number, statusOrMessage?: number | string, context?: Record<string, unknown>);
|
|
302
|
+
/**
|
|
303
|
+
* Convert error to JSON for API responses (ClockIn-compatible shape)
|
|
304
|
+
*/
|
|
305
|
+
toJSON(): Record<string, unknown>;
|
|
306
|
+
/**
|
|
307
|
+
* Check if error is operational (expected) vs programmer error
|
|
308
|
+
*/
|
|
309
|
+
isOperational(): boolean;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Not initialized error
|
|
313
|
+
*/
|
|
314
|
+
declare class NotInitializedError extends PayrollError {
|
|
315
|
+
constructor(message?: string);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Employee not found error
|
|
319
|
+
*/
|
|
320
|
+
declare class EmployeeNotFoundError extends PayrollError {
|
|
321
|
+
constructor(employeeId?: string, context?: Record<string, unknown>);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Invalid employee error
|
|
325
|
+
*/
|
|
326
|
+
declare class InvalidEmployeeError extends PayrollError {
|
|
327
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Duplicate payroll error
|
|
331
|
+
*/
|
|
332
|
+
declare class DuplicatePayrollError extends PayrollError {
|
|
333
|
+
constructor(employeeId: string, month: number, year: number, context?: Record<string, unknown>);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Validation error
|
|
337
|
+
*/
|
|
338
|
+
declare class ValidationError extends PayrollError {
|
|
339
|
+
readonly errors: string[];
|
|
340
|
+
constructor(errors: string | string[], context?: Record<string, unknown>);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Employee terminated error
|
|
344
|
+
*/
|
|
345
|
+
declare class EmployeeTerminatedError extends PayrollError {
|
|
346
|
+
constructor(employeeId?: string, context?: Record<string, unknown>);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Already processed error
|
|
350
|
+
*/
|
|
351
|
+
declare class AlreadyProcessedError extends PayrollError {
|
|
352
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Not eligible error
|
|
356
|
+
*/
|
|
357
|
+
declare class NotEligibleError extends PayrollError {
|
|
358
|
+
constructor(message: string, context?: Record<string, unknown>);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Create error from code
|
|
362
|
+
*/
|
|
363
|
+
declare function createError(code: ErrorCode, message: string, context?: Record<string, unknown>): PayrollError;
|
|
364
|
+
/**
|
|
365
|
+
* Check if error is PayrollError
|
|
366
|
+
*/
|
|
367
|
+
declare function isPayrollError(error: unknown): error is PayrollError;
|
|
368
|
+
/**
|
|
369
|
+
* Extract error info for logging
|
|
370
|
+
*/
|
|
371
|
+
declare function extractErrorInfo(error: unknown): {
|
|
372
|
+
code: string;
|
|
373
|
+
status: number;
|
|
374
|
+
message: string;
|
|
375
|
+
context?: Record<string, unknown>;
|
|
376
|
+
};
|
|
377
|
+
/**
|
|
378
|
+
* Convert unknown error to PayrollError
|
|
379
|
+
*/
|
|
380
|
+
declare function toPayrollError(error: unknown): PayrollError;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* @classytic/payroll - Attendance Integration
|
|
384
|
+
*
|
|
385
|
+
* Native integration with @classytic/clockin.
|
|
386
|
+
* ClockIn is an optional peer dependency for attendance-based deductions.
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Get attendance for payroll calculation
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```typescript
|
|
394
|
+
* import { getAttendance } from '@classytic/payroll';
|
|
395
|
+
*
|
|
396
|
+
* const attendance = await getAttendance(Attendance, {
|
|
397
|
+
* organizationId: org._id,
|
|
398
|
+
* employeeId: emp._id,
|
|
399
|
+
* month: 3,
|
|
400
|
+
* year: 2024,
|
|
401
|
+
* expectedDays: 22,
|
|
402
|
+
* });
|
|
403
|
+
*
|
|
404
|
+
* await payroll.processSalary({ employeeId, month: 3, year: 2024, attendance });
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
declare function getAttendance(AttendanceModel: Model<unknown>, params: {
|
|
408
|
+
organizationId: ObjectIdLike;
|
|
409
|
+
employeeId: ObjectIdLike;
|
|
410
|
+
month: number;
|
|
411
|
+
year: number;
|
|
412
|
+
expectedDays: number;
|
|
413
|
+
}): Promise<(AttendanceInput & {
|
|
414
|
+
absentDays: number;
|
|
415
|
+
overtimeDays: number;
|
|
416
|
+
}) | null>;
|
|
417
|
+
/**
|
|
418
|
+
* Get attendance for multiple employees (efficient batch operation)
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const attendanceMap = await batchGetAttendance(Attendance, {
|
|
423
|
+
* organizationId: org._id,
|
|
424
|
+
* employeeIds: [emp1._id, emp2._id, emp3._id],
|
|
425
|
+
* month: 3,
|
|
426
|
+
* year: 2024,
|
|
427
|
+
* expectedDays: 22,
|
|
428
|
+
* });
|
|
429
|
+
*
|
|
430
|
+
* const emp1Attendance = attendanceMap.get(emp1._id.toString());
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
declare function batchGetAttendance(AttendanceModel: Model<unknown>, params: {
|
|
434
|
+
organizationId: ObjectIdLike;
|
|
435
|
+
employeeIds: ObjectIdLike[];
|
|
436
|
+
month: number;
|
|
437
|
+
year: number;
|
|
438
|
+
expectedDays: number;
|
|
439
|
+
}): Promise<Map<string, AttendanceInput>>;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* @classytic/payroll - Holiday Management
|
|
443
|
+
*
|
|
444
|
+
* Simple holiday storage and retrieval.
|
|
445
|
+
* ONE way to manage holidays - no confusion.
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Holiday document
|
|
450
|
+
*/
|
|
451
|
+
interface Holiday {
|
|
452
|
+
organizationId?: any;
|
|
453
|
+
date: Date;
|
|
454
|
+
name: string;
|
|
455
|
+
type: 'public' | 'company' | 'religious';
|
|
456
|
+
paid: boolean;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Create holiday schema
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```typescript
|
|
463
|
+
* import { createHolidaySchema } from '@classytic/payroll';
|
|
464
|
+
*
|
|
465
|
+
* // Multi-tenant
|
|
466
|
+
* const Holiday = model('Holiday', createHolidaySchema());
|
|
467
|
+
*
|
|
468
|
+
* // Single-tenant
|
|
469
|
+
* const Holiday = model('Holiday', createHolidaySchema({ singleTenant: true }));
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
declare function createHolidaySchema(options?: {
|
|
473
|
+
singleTenant?: boolean;
|
|
474
|
+
}): Schema;
|
|
475
|
+
/**
|
|
476
|
+
* Get holidays for a period
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* const holidays = await getHolidays(Holiday, {
|
|
481
|
+
* organizationId: org._id, // optional for single-tenant
|
|
482
|
+
* startDate: new Date('2024-03-01'),
|
|
483
|
+
* endDate: new Date('2024-03-31'),
|
|
484
|
+
* });
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
declare function getHolidays(HolidayModel: Model<any>, params: {
|
|
488
|
+
organizationId?: any;
|
|
489
|
+
startDate: Date;
|
|
490
|
+
endDate: Date;
|
|
491
|
+
}): Promise<Date[]>;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* @classytic/payroll - LeaveRequest Model
|
|
495
|
+
*
|
|
496
|
+
* Mongoose schema for leave requests with TTL support
|
|
497
|
+
*/
|
|
498
|
+
|
|
499
|
+
declare const leaveRequestSchema: mongoose__default.Schema<any, mongoose__default.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
500
|
+
timestamps: true;
|
|
501
|
+
}, {
|
|
502
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
503
|
+
status: "pending" | "cancelled" | "approved" | "rejected";
|
|
504
|
+
type: "other" | "annual" | "sick" | "unpaid" | "maternity" | "paternity" | "bereavement" | "compensatory";
|
|
505
|
+
metadata: any;
|
|
506
|
+
startDate: NativeDate;
|
|
507
|
+
endDate: NativeDate;
|
|
508
|
+
days: number;
|
|
509
|
+
halfDay: boolean;
|
|
510
|
+
attachments: string[];
|
|
511
|
+
reason?: string | null | undefined;
|
|
512
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
513
|
+
organizationId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
514
|
+
reviewedBy?: mongoose__default.Types.ObjectId | null | undefined;
|
|
515
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
516
|
+
reviewNotes?: string | null | undefined;
|
|
517
|
+
} & mongoose__default.DefaultTimestampProps, mongoose__default.Document<unknown, {}, {
|
|
518
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
519
|
+
status: "pending" | "cancelled" | "approved" | "rejected";
|
|
520
|
+
type: "other" | "annual" | "sick" | "unpaid" | "maternity" | "paternity" | "bereavement" | "compensatory";
|
|
521
|
+
metadata: any;
|
|
522
|
+
startDate: NativeDate;
|
|
523
|
+
endDate: NativeDate;
|
|
524
|
+
days: number;
|
|
525
|
+
halfDay: boolean;
|
|
526
|
+
attachments: string[];
|
|
527
|
+
reason?: string | null | undefined;
|
|
528
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
529
|
+
organizationId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
530
|
+
reviewedBy?: mongoose__default.Types.ObjectId | null | undefined;
|
|
531
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
532
|
+
reviewNotes?: string | null | undefined;
|
|
533
|
+
} & mongoose__default.DefaultTimestampProps, {
|
|
534
|
+
id: string;
|
|
535
|
+
}, mongoose__default.ResolveSchemaOptions<{
|
|
536
|
+
timestamps: true;
|
|
537
|
+
}>> & Omit<{
|
|
538
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
539
|
+
status: "pending" | "cancelled" | "approved" | "rejected";
|
|
540
|
+
type: "other" | "annual" | "sick" | "unpaid" | "maternity" | "paternity" | "bereavement" | "compensatory";
|
|
541
|
+
metadata: any;
|
|
542
|
+
startDate: NativeDate;
|
|
543
|
+
endDate: NativeDate;
|
|
544
|
+
days: number;
|
|
545
|
+
halfDay: boolean;
|
|
546
|
+
attachments: string[];
|
|
547
|
+
reason?: string | null | undefined;
|
|
548
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
549
|
+
organizationId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
550
|
+
reviewedBy?: mongoose__default.Types.ObjectId | null | undefined;
|
|
551
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
552
|
+
reviewNotes?: string | null | undefined;
|
|
553
|
+
} & mongoose__default.DefaultTimestampProps & {
|
|
554
|
+
_id: mongoose__default.Types.ObjectId;
|
|
555
|
+
} & {
|
|
556
|
+
__v: number;
|
|
557
|
+
}, "id"> & {
|
|
558
|
+
id: string;
|
|
559
|
+
}, {
|
|
560
|
+
[path: string]: mongoose__default.SchemaDefinitionProperty<undefined, any, any>;
|
|
561
|
+
} | {
|
|
562
|
+
[x: string]: mongoose__default.SchemaDefinitionProperty<any, any, mongoose__default.Document<unknown, {}, {
|
|
563
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
564
|
+
status: "pending" | "cancelled" | "approved" | "rejected";
|
|
565
|
+
type: "other" | "annual" | "sick" | "unpaid" | "maternity" | "paternity" | "bereavement" | "compensatory";
|
|
566
|
+
metadata: any;
|
|
567
|
+
startDate: NativeDate;
|
|
568
|
+
endDate: NativeDate;
|
|
569
|
+
days: number;
|
|
570
|
+
halfDay: boolean;
|
|
571
|
+
attachments: string[];
|
|
572
|
+
reason?: string | null | undefined;
|
|
573
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
574
|
+
organizationId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
575
|
+
reviewedBy?: mongoose__default.Types.ObjectId | null | undefined;
|
|
576
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
577
|
+
reviewNotes?: string | null | undefined;
|
|
578
|
+
} & mongoose__default.DefaultTimestampProps, {
|
|
579
|
+
id: string;
|
|
580
|
+
}, mongoose__default.ResolveSchemaOptions<{
|
|
581
|
+
timestamps: true;
|
|
582
|
+
}>> & Omit<{
|
|
583
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
584
|
+
status: "pending" | "cancelled" | "approved" | "rejected";
|
|
585
|
+
type: "other" | "annual" | "sick" | "unpaid" | "maternity" | "paternity" | "bereavement" | "compensatory";
|
|
586
|
+
metadata: any;
|
|
587
|
+
startDate: NativeDate;
|
|
588
|
+
endDate: NativeDate;
|
|
589
|
+
days: number;
|
|
590
|
+
halfDay: boolean;
|
|
591
|
+
attachments: string[];
|
|
592
|
+
reason?: string | null | undefined;
|
|
593
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
594
|
+
organizationId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
595
|
+
reviewedBy?: mongoose__default.Types.ObjectId | null | undefined;
|
|
596
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
597
|
+
reviewNotes?: string | null | undefined;
|
|
598
|
+
} & mongoose__default.DefaultTimestampProps & {
|
|
599
|
+
_id: mongoose__default.Types.ObjectId;
|
|
600
|
+
} & {
|
|
601
|
+
__v: number;
|
|
602
|
+
}, "id"> & {
|
|
603
|
+
id: string;
|
|
604
|
+
}> | undefined;
|
|
605
|
+
}, {
|
|
606
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
607
|
+
status: "pending" | "cancelled" | "approved" | "rejected";
|
|
608
|
+
type: "other" | "annual" | "sick" | "unpaid" | "maternity" | "paternity" | "bereavement" | "compensatory";
|
|
609
|
+
metadata: any;
|
|
610
|
+
startDate: NativeDate;
|
|
611
|
+
endDate: NativeDate;
|
|
612
|
+
days: number;
|
|
613
|
+
halfDay: boolean;
|
|
614
|
+
attachments: string[];
|
|
615
|
+
reason?: string | null | undefined;
|
|
616
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
617
|
+
organizationId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
618
|
+
reviewedBy?: mongoose__default.Types.ObjectId | null | undefined;
|
|
619
|
+
reviewedAt?: NativeDate | null | undefined;
|
|
620
|
+
reviewNotes?: string | null | undefined;
|
|
621
|
+
createdAt: NativeDate;
|
|
622
|
+
updatedAt: NativeDate;
|
|
623
|
+
} & {
|
|
624
|
+
_id: mongoose__default.Types.ObjectId;
|
|
625
|
+
} & {
|
|
626
|
+
__v: number;
|
|
627
|
+
}>;
|
|
628
|
+
interface LeaveRequestModel extends Model<LeaveRequestDocument> {
|
|
629
|
+
findByEmployee(employeeId: mongoose__default.Types.ObjectId, options?: {
|
|
630
|
+
status?: LeaveRequestStatus;
|
|
631
|
+
year?: number;
|
|
632
|
+
limit?: number;
|
|
633
|
+
}): ReturnType<Model<LeaveRequestDocument>['find']>;
|
|
634
|
+
findPendingByOrganization(organizationId?: mongoose__default.Types.ObjectId): ReturnType<Model<LeaveRequestDocument>['find']>;
|
|
635
|
+
findByPeriod(organizationId: mongoose__default.Types.ObjectId | undefined, startDate: Date, endDate: Date, options?: {
|
|
636
|
+
status?: LeaveRequestStatus;
|
|
637
|
+
type?: LeaveType;
|
|
638
|
+
}): ReturnType<Model<LeaveRequestDocument>['find']>;
|
|
639
|
+
getLeaveStats(employeeId: mongoose__default.Types.ObjectId, year: number): Promise<Array<{
|
|
640
|
+
_id: LeaveType;
|
|
641
|
+
totalDays: number;
|
|
642
|
+
count: number;
|
|
643
|
+
}>>;
|
|
644
|
+
getOrganizationSummary(organizationId: mongoose__default.Types.ObjectId | undefined, year: number): Promise<Array<{
|
|
645
|
+
_id: {
|
|
646
|
+
status: LeaveRequestStatus;
|
|
647
|
+
type: LeaveType;
|
|
648
|
+
};
|
|
649
|
+
totalDays: number;
|
|
650
|
+
count: number;
|
|
651
|
+
}>>;
|
|
652
|
+
findOverlapping(employeeId: mongoose__default.Types.ObjectId, startDate: Date, endDate: Date, excludeRequestId?: mongoose__default.Types.ObjectId): ReturnType<Model<LeaveRequestDocument>['find']>;
|
|
653
|
+
hasOverlap(employeeId: mongoose__default.Types.ObjectId, startDate: Date, endDate: Date, excludeRequestId?: mongoose__default.Types.ObjectId): Promise<boolean>;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Get or create LeaveRequest model
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* const LeaveRequest = getLeaveRequestModel();
|
|
660
|
+
*
|
|
661
|
+
* // With custom connection
|
|
662
|
+
* const LeaveRequest = getLeaveRequestModel(customConnection);
|
|
663
|
+
*/
|
|
664
|
+
declare function getLeaveRequestModel(connection?: mongoose__default.Connection): LeaveRequestModel;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @classytic/payroll - TaxWithholding Model
|
|
668
|
+
*
|
|
669
|
+
* Mongoose schema for tax withholding tracking with aggregation support
|
|
670
|
+
*/
|
|
671
|
+
|
|
672
|
+
declare const taxWithholdingSchema: mongoose__default.Schema<any, mongoose__default.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
673
|
+
timestamps: true;
|
|
674
|
+
}, {
|
|
675
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
676
|
+
amount: number;
|
|
677
|
+
status: "pending" | "paid" | "submitted";
|
|
678
|
+
organizationId: mongoose__default.Types.ObjectId;
|
|
679
|
+
currency: string;
|
|
680
|
+
payrollRecordId: mongoose__default.Types.ObjectId;
|
|
681
|
+
metadata: any;
|
|
682
|
+
transactionId: mongoose__default.Types.ObjectId;
|
|
683
|
+
taxableAmount: number;
|
|
684
|
+
taxType: "other" | "income_tax" | "social_security" | "health_insurance" | "pension" | "employment_insurance" | "local_tax";
|
|
685
|
+
taxRate: number;
|
|
686
|
+
period?: {
|
|
687
|
+
month: number;
|
|
688
|
+
year: number;
|
|
689
|
+
startDate: NativeDate;
|
|
690
|
+
endDate: NativeDate;
|
|
691
|
+
payDate: NativeDate;
|
|
692
|
+
} | null | undefined;
|
|
693
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
694
|
+
referenceNumber?: string | null | undefined;
|
|
695
|
+
notes?: string | null | undefined;
|
|
696
|
+
paidAt?: NativeDate | null | undefined;
|
|
697
|
+
submittedAt?: NativeDate | null | undefined;
|
|
698
|
+
governmentTransactionId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
699
|
+
} & mongoose__default.DefaultTimestampProps, mongoose__default.Document<unknown, {}, {
|
|
700
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
701
|
+
amount: number;
|
|
702
|
+
status: "pending" | "paid" | "submitted";
|
|
703
|
+
organizationId: mongoose__default.Types.ObjectId;
|
|
704
|
+
currency: string;
|
|
705
|
+
payrollRecordId: mongoose__default.Types.ObjectId;
|
|
706
|
+
metadata: any;
|
|
707
|
+
transactionId: mongoose__default.Types.ObjectId;
|
|
708
|
+
taxableAmount: number;
|
|
709
|
+
taxType: "other" | "income_tax" | "social_security" | "health_insurance" | "pension" | "employment_insurance" | "local_tax";
|
|
710
|
+
taxRate: number;
|
|
711
|
+
period?: {
|
|
712
|
+
month: number;
|
|
713
|
+
year: number;
|
|
714
|
+
startDate: NativeDate;
|
|
715
|
+
endDate: NativeDate;
|
|
716
|
+
payDate: NativeDate;
|
|
717
|
+
} | null | undefined;
|
|
718
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
719
|
+
referenceNumber?: string | null | undefined;
|
|
720
|
+
notes?: string | null | undefined;
|
|
721
|
+
paidAt?: NativeDate | null | undefined;
|
|
722
|
+
submittedAt?: NativeDate | null | undefined;
|
|
723
|
+
governmentTransactionId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
724
|
+
} & mongoose__default.DefaultTimestampProps, {
|
|
725
|
+
id: string;
|
|
726
|
+
}, mongoose__default.ResolveSchemaOptions<{
|
|
727
|
+
timestamps: true;
|
|
728
|
+
}>> & Omit<{
|
|
729
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
730
|
+
amount: number;
|
|
731
|
+
status: "pending" | "paid" | "submitted";
|
|
732
|
+
organizationId: mongoose__default.Types.ObjectId;
|
|
733
|
+
currency: string;
|
|
734
|
+
payrollRecordId: mongoose__default.Types.ObjectId;
|
|
735
|
+
metadata: any;
|
|
736
|
+
transactionId: mongoose__default.Types.ObjectId;
|
|
737
|
+
taxableAmount: number;
|
|
738
|
+
taxType: "other" | "income_tax" | "social_security" | "health_insurance" | "pension" | "employment_insurance" | "local_tax";
|
|
739
|
+
taxRate: number;
|
|
740
|
+
period?: {
|
|
741
|
+
month: number;
|
|
742
|
+
year: number;
|
|
743
|
+
startDate: NativeDate;
|
|
744
|
+
endDate: NativeDate;
|
|
745
|
+
payDate: NativeDate;
|
|
746
|
+
} | null | undefined;
|
|
747
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
748
|
+
referenceNumber?: string | null | undefined;
|
|
749
|
+
notes?: string | null | undefined;
|
|
750
|
+
paidAt?: NativeDate | null | undefined;
|
|
751
|
+
submittedAt?: NativeDate | null | undefined;
|
|
752
|
+
governmentTransactionId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
753
|
+
} & mongoose__default.DefaultTimestampProps & {
|
|
754
|
+
_id: mongoose__default.Types.ObjectId;
|
|
755
|
+
} & {
|
|
756
|
+
__v: number;
|
|
757
|
+
}, "id"> & {
|
|
758
|
+
id: string;
|
|
759
|
+
}, {
|
|
760
|
+
[path: string]: mongoose__default.SchemaDefinitionProperty<undefined, any, any>;
|
|
761
|
+
} | {
|
|
762
|
+
[x: string]: mongoose__default.SchemaDefinitionProperty<any, any, mongoose__default.Document<unknown, {}, {
|
|
763
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
764
|
+
amount: number;
|
|
765
|
+
status: "pending" | "paid" | "submitted";
|
|
766
|
+
organizationId: mongoose__default.Types.ObjectId;
|
|
767
|
+
currency: string;
|
|
768
|
+
payrollRecordId: mongoose__default.Types.ObjectId;
|
|
769
|
+
metadata: any;
|
|
770
|
+
transactionId: mongoose__default.Types.ObjectId;
|
|
771
|
+
taxableAmount: number;
|
|
772
|
+
taxType: "other" | "income_tax" | "social_security" | "health_insurance" | "pension" | "employment_insurance" | "local_tax";
|
|
773
|
+
taxRate: number;
|
|
774
|
+
period?: {
|
|
775
|
+
month: number;
|
|
776
|
+
year: number;
|
|
777
|
+
startDate: NativeDate;
|
|
778
|
+
endDate: NativeDate;
|
|
779
|
+
payDate: NativeDate;
|
|
780
|
+
} | null | undefined;
|
|
781
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
782
|
+
referenceNumber?: string | null | undefined;
|
|
783
|
+
notes?: string | null | undefined;
|
|
784
|
+
paidAt?: NativeDate | null | undefined;
|
|
785
|
+
submittedAt?: NativeDate | null | undefined;
|
|
786
|
+
governmentTransactionId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
787
|
+
} & mongoose__default.DefaultTimestampProps, {
|
|
788
|
+
id: string;
|
|
789
|
+
}, mongoose__default.ResolveSchemaOptions<{
|
|
790
|
+
timestamps: true;
|
|
791
|
+
}>> & Omit<{
|
|
792
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
793
|
+
amount: number;
|
|
794
|
+
status: "pending" | "paid" | "submitted";
|
|
795
|
+
organizationId: mongoose__default.Types.ObjectId;
|
|
796
|
+
currency: string;
|
|
797
|
+
payrollRecordId: mongoose__default.Types.ObjectId;
|
|
798
|
+
metadata: any;
|
|
799
|
+
transactionId: mongoose__default.Types.ObjectId;
|
|
800
|
+
taxableAmount: number;
|
|
801
|
+
taxType: "other" | "income_tax" | "social_security" | "health_insurance" | "pension" | "employment_insurance" | "local_tax";
|
|
802
|
+
taxRate: number;
|
|
803
|
+
period?: {
|
|
804
|
+
month: number;
|
|
805
|
+
year: number;
|
|
806
|
+
startDate: NativeDate;
|
|
807
|
+
endDate: NativeDate;
|
|
808
|
+
payDate: NativeDate;
|
|
809
|
+
} | null | undefined;
|
|
810
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
811
|
+
referenceNumber?: string | null | undefined;
|
|
812
|
+
notes?: string | null | undefined;
|
|
813
|
+
paidAt?: NativeDate | null | undefined;
|
|
814
|
+
submittedAt?: NativeDate | null | undefined;
|
|
815
|
+
governmentTransactionId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
816
|
+
} & mongoose__default.DefaultTimestampProps & {
|
|
817
|
+
_id: mongoose__default.Types.ObjectId;
|
|
818
|
+
} & {
|
|
819
|
+
__v: number;
|
|
820
|
+
}, "id"> & {
|
|
821
|
+
id: string;
|
|
822
|
+
}> | undefined;
|
|
823
|
+
}, {
|
|
824
|
+
employeeId: mongoose__default.Types.ObjectId;
|
|
825
|
+
amount: number;
|
|
826
|
+
status: "pending" | "paid" | "submitted";
|
|
827
|
+
organizationId: mongoose__default.Types.ObjectId;
|
|
828
|
+
currency: string;
|
|
829
|
+
payrollRecordId: mongoose__default.Types.ObjectId;
|
|
830
|
+
metadata: any;
|
|
831
|
+
transactionId: mongoose__default.Types.ObjectId;
|
|
832
|
+
taxableAmount: number;
|
|
833
|
+
taxType: "other" | "income_tax" | "social_security" | "health_insurance" | "pension" | "employment_insurance" | "local_tax";
|
|
834
|
+
taxRate: number;
|
|
835
|
+
period?: {
|
|
836
|
+
month: number;
|
|
837
|
+
year: number;
|
|
838
|
+
startDate: NativeDate;
|
|
839
|
+
endDate: NativeDate;
|
|
840
|
+
payDate: NativeDate;
|
|
841
|
+
} | null | undefined;
|
|
842
|
+
userId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
843
|
+
referenceNumber?: string | null | undefined;
|
|
844
|
+
notes?: string | null | undefined;
|
|
845
|
+
paidAt?: NativeDate | null | undefined;
|
|
846
|
+
submittedAt?: NativeDate | null | undefined;
|
|
847
|
+
governmentTransactionId?: mongoose__default.Types.ObjectId | null | undefined;
|
|
848
|
+
createdAt: NativeDate;
|
|
849
|
+
updatedAt: NativeDate;
|
|
850
|
+
} & {
|
|
851
|
+
_id: mongoose__default.Types.ObjectId;
|
|
852
|
+
} & {
|
|
853
|
+
__v: number;
|
|
854
|
+
}>;
|
|
855
|
+
interface TaxWithholdingModel extends Model<TaxWithholdingDocument> {
|
|
856
|
+
findByPeriod(organizationId: mongoose__default.Types.ObjectId, month: number, year: number): ReturnType<Model<TaxWithholdingDocument>['find']>;
|
|
857
|
+
findByEmployee(employeeId: mongoose__default.Types.ObjectId, options?: {
|
|
858
|
+
year?: number;
|
|
859
|
+
taxType?: TaxType;
|
|
860
|
+
status?: TaxStatus;
|
|
861
|
+
limit?: number;
|
|
862
|
+
}): ReturnType<Model<TaxWithholdingDocument>['find']>;
|
|
863
|
+
findPending(organizationId: mongoose__default.Types.ObjectId, options?: {
|
|
864
|
+
fromMonth?: number;
|
|
865
|
+
fromYear?: number;
|
|
866
|
+
toMonth?: number;
|
|
867
|
+
toYear?: number;
|
|
868
|
+
taxType?: TaxType;
|
|
869
|
+
}): ReturnType<Model<TaxWithholdingDocument>['find']>;
|
|
870
|
+
getSummaryByType(organizationId: mongoose__default.Types.ObjectId, fromPeriod: {
|
|
871
|
+
month: number;
|
|
872
|
+
year: number;
|
|
873
|
+
}, toPeriod: {
|
|
874
|
+
month: number;
|
|
875
|
+
year: number;
|
|
876
|
+
}): Promise<Array<{
|
|
877
|
+
taxType: TaxType;
|
|
878
|
+
totalAmount: number;
|
|
879
|
+
count: number;
|
|
880
|
+
withholdingIds: mongoose__default.Types.ObjectId[];
|
|
881
|
+
}>>;
|
|
882
|
+
getByPayrollRecord(payrollRecordId: mongoose__default.Types.ObjectId): ReturnType<Model<TaxWithholdingDocument>['find']>;
|
|
883
|
+
getTotalByOrganization(organizationId: mongoose__default.Types.ObjectId, options?: {
|
|
884
|
+
status?: TaxStatus;
|
|
885
|
+
year?: number;
|
|
886
|
+
}): Promise<{
|
|
887
|
+
totalAmount: number;
|
|
888
|
+
count: number;
|
|
889
|
+
}>;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Get or create TaxWithholding model
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* const TaxWithholding = getTaxWithholdingModel();
|
|
896
|
+
*
|
|
897
|
+
* // With custom connection
|
|
898
|
+
* const TaxWithholding = getTaxWithholdingModel(customConnection);
|
|
899
|
+
*/
|
|
900
|
+
declare function getTaxWithholdingModel(connection?: mongoose__default.Connection): TaxWithholdingModel;
|
|
901
|
+
|
|
902
|
+
export { ALLOWANCE_TYPE, AlreadyProcessedError, type CreatePayrollTransactionInput, type CreateTaxPaymentTransactionInput, DEDUCTION_TYPE, DEPARTMENT, DeepPartial, Department, DuplicatePayrollError, EMPLOYEE_STATUS, EMPLOYMENT_TYPE, EmployeeNotFoundError, type EmployeePluginOptions, EmployeeTerminatedError, EmploymentType, ErrorCode, HRMConfig, HRM_CONFIG, type Holiday, HttpError, type IPayrollTransaction, type IPayrollTransactionCreateInput, InvalidEmployeeError, LEAVE_REQUEST_STATUS, LEAVE_TYPE, LeaveInitConfig, LeaveRequestDocument, type LeaveRequestModel, LeaveRequestStatus, LeaveType, NotEligibleError, NotInitializedError, ObjectIdLike, OrgRole, PAYMENT_FREQUENCY, PAYROLL_STATUS, PayrollBreakdown, PayrollError, TAX_STATUS, TAX_STATUS_VALUES, TAX_TYPE, TAX_TYPE_VALUES, TERMINATION_REASON, TaxStatus, TaxType, TaxWithholdingDocument, type TaxWithholdingModel, TransactionFactory, ValidationError, batchGetAttendance, createError, createHolidaySchema, createPayrollTransaction, createTaxPaymentTransaction, determineOrgRole, employeePlugin, extractErrorInfo, getAttendance, getHolidays, getLeaveRequestModel, getTaxWithholdingModel, isApprovedLeaveStatus, isPaidLeaveType, isPaidTaxStatus, isPayrollError, isPayrollTransaction, isPendingLeaveStatus, isPendingTaxStatus, isValidLeaveRequestStatus, isValidLeaveType, isValidTaxStatus, isValidTaxType, leaveRequestSchema, mergeConfig, taxWithholdingSchema, toPayrollError };
|