@classytic/payroll 2.0.0 → 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 -253
- 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 +85 -251
- package/dist/core/index.js +286 -91
- package/dist/core/index.js.map +1 -1
- 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 +618 -683
- package/dist/index.js +8336 -3580
- package/dist/index.js.map +1 -1
- 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 +261 -65
- package/dist/payroll.js +4164 -1075
- package/dist/payroll.js.map +1 -1
- package/dist/schemas/index.d.ts +1176 -783
- package/dist/schemas/index.js +368 -28
- package/dist/schemas/index.js.map +1 -1
- package/dist/services/index.d.ts +582 -3
- package/dist/services/index.js +572 -96
- package/dist/services/index.js.map +1 -1
- 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 +22 -2
- package/dist/utils/index.js +470 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +24 -6
- package/dist/index-CTjHlCzz.d.ts +0 -721
- package/dist/plugin-D9mOr3_d.d.ts +0 -333
- package/dist/types-BSYyX2KJ.d.ts +0 -671
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/date.ts","../../src/utils/calculation.ts","../../src/enums.ts","../../src/utils/validation.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ACA,oBAAA;AAAA,EACA,mBAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,wBAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["/**\r\n * @classytic/payroll - Logger\r\n *\r\n * Pluggable logger abstraction\r\n * Defaults to console, can be replaced with pino, winston, etc.\r\n */\r\n\r\nimport type { Logger } from '../types.js';\r\n\r\n// ============================================================================\r\n// Default Logger Implementation\r\n// ============================================================================\r\n\r\nconst createConsoleLogger = (): Logger => ({\r\n info: (message: string, meta?: Record<string, unknown>) => {\r\n if (meta) {\r\n console.log(`[Payroll] INFO: ${message}`, meta);\r\n } else {\r\n console.log(`[Payroll] INFO: ${message}`);\r\n }\r\n },\r\n error: (message: string, meta?: Record<string, unknown>) => {\r\n if (meta) {\r\n console.error(`[Payroll] ERROR: ${message}`, meta);\r\n } else {\r\n console.error(`[Payroll] ERROR: ${message}`);\r\n }\r\n },\r\n warn: (message: string, meta?: Record<string, unknown>) => {\r\n if (meta) {\r\n console.warn(`[Payroll] WARN: ${message}`, meta);\r\n } else {\r\n console.warn(`[Payroll] WARN: ${message}`);\r\n }\r\n },\r\n debug: (message: string, meta?: Record<string, unknown>) => {\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (meta) {\r\n console.log(`[Payroll] DEBUG: ${message}`, meta);\r\n } else {\r\n console.log(`[Payroll] DEBUG: ${message}`);\r\n }\r\n }\r\n },\r\n});\r\n\r\n// ============================================================================\r\n// Logger State\r\n// ============================================================================\r\n\r\nlet currentLogger: Logger = createConsoleLogger();\r\nlet loggingEnabled = true;\r\n\r\n// ============================================================================\r\n// Logger Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Get the current logger instance\r\n */\r\nexport function getLogger(): Logger {\r\n return currentLogger;\r\n}\r\n\r\n/**\r\n * Set a custom logger instance\r\n */\r\nexport function setLogger(logger: Logger): void {\r\n currentLogger = logger;\r\n}\r\n\r\n/**\r\n * Reset to default console logger\r\n */\r\nexport function resetLogger(): void {\r\n currentLogger = createConsoleLogger();\r\n}\r\n\r\n/**\r\n * Create a child logger with prefix\r\n */\r\nexport function createChildLogger(prefix: string): Logger {\r\n const parent = currentLogger;\r\n return {\r\n info: (message: string, meta?: Record<string, unknown>) =>\r\n parent.info(`[${prefix}] ${message}`, meta),\r\n error: (message: string, meta?: Record<string, unknown>) =>\r\n parent.error(`[${prefix}] ${message}`, meta),\r\n warn: (message: string, meta?: Record<string, unknown>) =>\r\n parent.warn(`[${prefix}] ${message}`, meta),\r\n debug: (message: string, meta?: Record<string, unknown>) =>\r\n parent.debug(`[${prefix}] ${message}`, meta),\r\n };\r\n}\r\n\r\n/**\r\n * Create a silent logger (for testing)\r\n */\r\nexport function createSilentLogger(): Logger {\r\n return {\r\n info: () => {},\r\n error: () => {},\r\n warn: () => {},\r\n debug: () => {},\r\n };\r\n}\r\n\r\n/**\r\n * Enable logging globally\r\n */\r\nexport function enableLogging(): void {\r\n loggingEnabled = true;\r\n}\r\n\r\n/**\r\n * Disable logging globally (useful for production)\r\n */\r\nexport function disableLogging(): void {\r\n loggingEnabled = false;\r\n}\r\n\r\n/**\r\n * Check if logging is enabled\r\n */\r\nexport function isLoggingEnabled(): boolean {\r\n return loggingEnabled;\r\n}\r\n\r\n// ============================================================================\r\n// Logger Proxy Object\r\n// ============================================================================\r\n\r\n/**\r\n * Logger proxy that always delegates to currentLogger\r\n * Respects global logging enabled/disabled state\r\n */\r\nexport const logger: Logger = {\r\n info: (message: string, meta?: Record<string, unknown>) => {\r\n if (loggingEnabled) currentLogger.info(message, meta);\r\n },\r\n error: (message: string, meta?: Record<string, unknown>) => {\r\n if (loggingEnabled) currentLogger.error(message, meta);\r\n },\r\n warn: (message: string, meta?: Record<string, unknown>) => {\r\n if (loggingEnabled) currentLogger.warn(message, meta);\r\n },\r\n debug: (message: string, meta?: Record<string, unknown>) => {\r\n if (loggingEnabled) currentLogger.debug(message, meta);\r\n },\r\n};\r\n\r\nexport default logger;\r\n\r\n","/**\r\n * @classytic/payroll - Date Utilities\r\n *\r\n * Pure, composable, testable date operations\r\n * No side effects, no mutations\r\n */\r\n\r\nimport type { PayPeriodInfo, PaymentFrequency } from '../types.js';\r\n\r\n// ============================================================================\r\n// Date Arithmetic\r\n// ============================================================================\r\n\r\n/**\r\n * Add days to a date\r\n */\r\nexport function addDays(date: Date, days: number): Date {\r\n const result = new Date(date);\r\n result.setDate(result.getDate() + days);\r\n return result;\r\n}\r\n\r\n/**\r\n * Add months to a date\r\n */\r\nexport function addMonths(date: Date, months: number): Date {\r\n const result = new Date(date);\r\n result.setMonth(result.getMonth() + months);\r\n return result;\r\n}\r\n\r\n/**\r\n * Add years to a date\r\n */\r\nexport function addYears(date: Date, years: number): Date {\r\n const result = new Date(date);\r\n result.setFullYear(result.getFullYear() + years);\r\n return result;\r\n}\r\n\r\n/**\r\n * Subtract days from a date\r\n */\r\nexport function subDays(date: Date, days: number): Date {\r\n return addDays(date, -days);\r\n}\r\n\r\n/**\r\n * Subtract months from a date\r\n */\r\nexport function subMonths(date: Date, months: number): Date {\r\n return addMonths(date, -months);\r\n}\r\n\r\n// ============================================================================\r\n// Date Boundaries\r\n// ============================================================================\r\n\r\n/**\r\n * Get the start of a month\r\n */\r\nexport function startOfMonth(date: Date): Date {\r\n const result = new Date(date);\r\n result.setDate(1);\r\n result.setHours(0, 0, 0, 0);\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the end of a month\r\n */\r\nexport function endOfMonth(date: Date): Date {\r\n const result = new Date(date);\r\n result.setMonth(result.getMonth() + 1, 0);\r\n result.setHours(23, 59, 59, 999);\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the start of a year\r\n */\r\nexport function startOfYear(date: Date): Date {\r\n const result = new Date(date);\r\n result.setMonth(0, 1);\r\n result.setHours(0, 0, 0, 0);\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the end of a year\r\n */\r\nexport function endOfYear(date: Date): Date {\r\n const result = new Date(date);\r\n result.setMonth(11, 31);\r\n result.setHours(23, 59, 59, 999);\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the start of a day\r\n */\r\nexport function startOfDay(date: Date): Date {\r\n const result = new Date(date);\r\n result.setHours(0, 0, 0, 0);\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the end of a day\r\n */\r\nexport function endOfDay(date: Date): Date {\r\n const result = new Date(date);\r\n result.setHours(23, 59, 59, 999);\r\n return result;\r\n}\r\n\r\n// ============================================================================\r\n// Date Differences\r\n// ============================================================================\r\n\r\n/**\r\n * Calculate difference in days between two dates\r\n */\r\nexport function diffInDays(start: Date, end: Date): number {\r\n return Math.ceil(\r\n (new Date(end).getTime() - new Date(start).getTime()) / (1000 * 60 * 60 * 24)\r\n );\r\n}\r\n\r\n/**\r\n * Calculate difference in months between two dates\r\n */\r\nexport function diffInMonths(start: Date, end: Date): number {\r\n const startDate = new Date(start);\r\n const endDate = new Date(end);\r\n return (\r\n (endDate.getFullYear() - startDate.getFullYear()) * 12 +\r\n (endDate.getMonth() - startDate.getMonth())\r\n );\r\n}\r\n\r\n/**\r\n * Calculate difference in years between two dates\r\n */\r\nexport function diffInYears(start: Date, end: Date): number {\r\n return Math.floor(diffInMonths(start, end) / 12);\r\n}\r\n\r\n// Aliases for backwards compatibility\r\nexport const daysBetween = diffInDays;\r\nexport const monthsBetween = diffInMonths;\r\n\r\n// ============================================================================\r\n// Day Type Checks\r\n// ============================================================================\r\n\r\n/**\r\n * Check if date is a weekday (Mon-Fri)\r\n */\r\nexport function isWeekday(date: Date): boolean {\r\n const day = new Date(date).getDay();\r\n return day >= 1 && day <= 5;\r\n}\r\n\r\n/**\r\n * Check if date is a weekend (Sat-Sun)\r\n */\r\nexport function isWeekend(date: Date): boolean {\r\n const day = new Date(date).getDay();\r\n return day === 0 || day === 6;\r\n}\r\n\r\n/**\r\n * Get day of week (0=Sunday, 6=Saturday)\r\n */\r\nexport function getDayOfWeek(date: Date): number {\r\n return new Date(date).getDay();\r\n}\r\n\r\n/**\r\n * Get day name\r\n */\r\nexport function getDayName(date: Date): string {\r\n const days = [\r\n 'Sunday',\r\n 'Monday',\r\n 'Tuesday',\r\n 'Wednesday',\r\n 'Thursday',\r\n 'Friday',\r\n 'Saturday',\r\n ];\r\n return days[getDayOfWeek(date)];\r\n}\r\n\r\n// ============================================================================\r\n// Pay Period Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Get pay period for a given month and year\r\n */\r\nexport function getPayPeriod(month: number, year: number): PayPeriodInfo {\r\n const startDate = new Date(year, month - 1, 1);\r\n return {\r\n month,\r\n year,\r\n startDate: startOfMonth(startDate),\r\n endDate: endOfMonth(startDate),\r\n };\r\n}\r\n\r\n/**\r\n * Get current pay period\r\n */\r\nexport function getCurrentPeriod(date = new Date()): { year: number; month: number } {\r\n const d = new Date(date);\r\n return {\r\n year: d.getFullYear(),\r\n month: d.getMonth() + 1,\r\n };\r\n}\r\n\r\n/**\r\n * Get working days in a month\r\n */\r\nexport function getWorkingDaysInMonth(year: number, month: number): number {\r\n const start = new Date(year, month - 1, 1);\r\n const end = endOfMonth(start);\r\n let count = 0;\r\n \r\n const current = new Date(start);\r\n while (current <= end) {\r\n if (isWeekday(current)) {\r\n count++;\r\n }\r\n current.setDate(current.getDate() + 1);\r\n }\r\n \r\n return count;\r\n}\r\n\r\n/**\r\n * Get total days in a month\r\n */\r\nexport function getDaysInMonth(year: number, month: number): number {\r\n return new Date(year, month, 0).getDate();\r\n}\r\n\r\n// ============================================================================\r\n// Employment Date Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Calculate probation end date\r\n */\r\nexport function calculateProbationEnd(\r\n hireDate: Date,\r\n probationMonths: number\r\n): Date | null {\r\n if (!probationMonths || probationMonths <= 0) return null;\r\n return addMonths(hireDate, probationMonths);\r\n}\r\n\r\n/**\r\n * Check if employee is on probation\r\n */\r\nexport function isOnProbation(\r\n probationEndDate: Date | null | undefined,\r\n now = new Date()\r\n): boolean {\r\n if (!probationEndDate) return false;\r\n return now < new Date(probationEndDate);\r\n}\r\n\r\n/**\r\n * Calculate years of service\r\n */\r\nexport function calculateYearsOfService(\r\n hireDate: Date,\r\n terminationDate?: Date | null\r\n): number {\r\n const end = terminationDate || new Date();\r\n const days = diffInDays(hireDate, end);\r\n return Math.max(0, Math.floor((days / 365.25) * 10) / 10);\r\n}\r\n\r\n// ============================================================================\r\n// Range Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Check if a date is within a range\r\n */\r\nexport function isDateInRange(date: Date, start: Date, end: Date): boolean {\r\n const checkDate = new Date(date);\r\n return checkDate >= new Date(start) && checkDate <= new Date(end);\r\n}\r\n\r\n/**\r\n * Get date range for a pay period\r\n */\r\nexport function getPayPeriodDateRange(\r\n month: number,\r\n year: number\r\n): { start: Date; end: Date } {\r\n const period = getPayPeriod(month, year);\r\n return { start: period.startDate, end: period.endDate };\r\n}\r\n\r\n// ============================================================================\r\n// Formatting Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Format date for database storage\r\n */\r\nexport function formatDateForDB(date: Date): string {\r\n if (!date) return '';\r\n return new Date(date).toISOString();\r\n}\r\n\r\n/**\r\n * Parse date from database\r\n */\r\nexport function parseDBDate(dateString: string): Date | null {\r\n if (!dateString) return null;\r\n return new Date(dateString);\r\n}\r\n\r\n/**\r\n * Format period as string (e.g., \"01/2025\")\r\n */\r\nexport function formatPeriod({ month, year }: { month: number; year: number }): string {\r\n return `${String(month).padStart(2, '0')}/${year}`;\r\n}\r\n\r\n/**\r\n * Parse period string back to object\r\n */\r\nexport function parsePeriod(periodString: string): { month: number; year: number } {\r\n const [month, year] = periodString.split('/').map(Number);\r\n return { month, year };\r\n}\r\n\r\n/**\r\n * Format month name\r\n */\r\nexport function getMonthName(month: number): string {\r\n const months = [\r\n 'January', 'February', 'March', 'April', 'May', 'June',\r\n 'July', 'August', 'September', 'October', 'November', 'December',\r\n ];\r\n return months[month - 1] || '';\r\n}\r\n\r\n/**\r\n * Format short month name\r\n */\r\nexport function getShortMonthName(month: number): string {\r\n const months = [\r\n 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',\r\n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',\r\n ];\r\n return months[month - 1] || '';\r\n}\r\n\r\n// ============================================================================\r\n// Default Export\r\n// ============================================================================\r\n\r\nexport default {\r\n addDays,\r\n addMonths,\r\n addYears,\r\n subDays,\r\n subMonths,\r\n startOfMonth,\r\n endOfMonth,\r\n startOfYear,\r\n endOfYear,\r\n startOfDay,\r\n endOfDay,\r\n diffInDays,\r\n diffInMonths,\r\n diffInYears,\r\n daysBetween,\r\n monthsBetween,\r\n isWeekday,\r\n isWeekend,\r\n getDayOfWeek,\r\n getDayName,\r\n getPayPeriod,\r\n getCurrentPeriod,\r\n getWorkingDaysInMonth,\r\n getDaysInMonth,\r\n calculateProbationEnd,\r\n isOnProbation,\r\n calculateYearsOfService,\r\n isDateInRange,\r\n getPayPeriodDateRange,\r\n formatDateForDB,\r\n parseDBDate,\r\n formatPeriod,\r\n parsePeriod,\r\n getMonthName,\r\n getShortMonthName,\r\n};\r\n\r\n","/**\r\n * @classytic/payroll - Calculation Utilities\r\n *\r\n * Pure, functional, composable financial calculations\r\n * No side effects, highly testable\r\n */\r\n\r\nimport type {\r\n Allowance,\r\n Deduction,\r\n Compensation,\r\n TaxCalculationResult,\r\n CompensationBreakdownResult,\r\n ProRatingResult,\r\n PayPeriodInfo,\r\n} from '../types.js';\r\nimport { diffInDays } from './date.js';\r\n\r\n// ============================================================================\r\n// Basic Math Operations\r\n// ============================================================================\r\n\r\n/**\r\n * Sum array of numbers\r\n */\r\nexport function sum(numbers: number[]): number {\r\n return numbers.reduce((total, n) => total + n, 0);\r\n}\r\n\r\n/**\r\n * Sum by property\r\n */\r\nexport function sumBy<T>(items: T[], getter: (item: T) => number): number {\r\n return items.reduce((total, item) => total + getter(item), 0);\r\n}\r\n\r\n/**\r\n * Sum allowances\r\n */\r\nexport function sumAllowances(allowances: Array<{ amount: number }>): number {\r\n return sumBy(allowances, (a) => a.amount);\r\n}\r\n\r\n/**\r\n * Sum deductions\r\n */\r\nexport function sumDeductions(deductions: Array<{ amount: number }>): number {\r\n return sumBy(deductions, (d) => d.amount);\r\n}\r\n\r\n/**\r\n * Apply percentage to amount\r\n */\r\nexport function applyPercentage(amount: number, percentage: number): number {\r\n return Math.round(amount * (percentage / 100));\r\n}\r\n\r\n/**\r\n * Calculate percentage of total\r\n */\r\nexport function calculatePercentage(part: number, total: number): number {\r\n return total > 0 ? Math.round((part / total) * 100) : 0;\r\n}\r\n\r\n/**\r\n * Round to decimal places\r\n */\r\nexport function roundTo(value: number, decimals = 2): number {\r\n const factor = Math.pow(10, decimals);\r\n return Math.round(value * factor) / factor;\r\n}\r\n\r\n// ============================================================================\r\n// Salary Calculations\r\n// ============================================================================\r\n\r\n/**\r\n * Calculate gross salary from base and allowances\r\n */\r\nexport function calculateGross(\r\n baseAmount: number,\r\n allowances: Array<{ amount: number }>\r\n): number {\r\n return baseAmount + sumAllowances(allowances);\r\n}\r\n\r\n/**\r\n * Calculate net salary from gross and deductions\r\n */\r\nexport function calculateNet(\r\n gross: number,\r\n deductions: Array<{ amount: number }>\r\n): number {\r\n return Math.max(0, gross - sumDeductions(deductions));\r\n}\r\n\r\n/**\r\n * Calculate total compensation\r\n */\r\nexport function calculateTotalCompensation(\r\n baseAmount: number,\r\n allowances: Array<{ amount: number }>,\r\n deductions: Array<{ amount: number }>\r\n): { gross: number; net: number; deductions: number } {\r\n const gross = calculateGross(baseAmount, allowances);\r\n const totalDeductions = sumDeductions(deductions);\r\n const net = calculateNet(gross, deductions);\r\n return { gross, net, deductions: totalDeductions };\r\n}\r\n\r\n// ============================================================================\r\n// Allowance & Deduction Calculation\r\n// ============================================================================\r\n\r\n/**\r\n * Calculate allowance amount (handles percentage-based)\r\n */\r\nexport function calculateAllowanceAmount(\r\n allowance: Pick<Allowance, 'amount' | 'isPercentage' | 'value'>,\r\n baseAmount: number\r\n): number {\r\n if (allowance.isPercentage && allowance.value !== undefined) {\r\n return applyPercentage(baseAmount, allowance.value);\r\n }\r\n return allowance.amount;\r\n}\r\n\r\n/**\r\n * Calculate deduction amount (handles percentage-based)\r\n */\r\nexport function calculateDeductionAmount(\r\n deduction: Pick<Deduction, 'amount' | 'isPercentage' | 'value'>,\r\n baseAmount: number\r\n): number {\r\n if (deduction.isPercentage && deduction.value !== undefined) {\r\n return applyPercentage(baseAmount, deduction.value);\r\n }\r\n return deduction.amount;\r\n}\r\n\r\n/**\r\n * Calculate all allowances with their actual amounts\r\n */\r\nexport function calculateAllowances(\r\n allowances: Allowance[],\r\n baseAmount: number\r\n): Array<Allowance & { calculatedAmount: number }> {\r\n return allowances.map((allowance) => ({\r\n ...allowance,\r\n calculatedAmount: calculateAllowanceAmount(allowance, baseAmount),\r\n }));\r\n}\r\n\r\n/**\r\n * Calculate all deductions with their actual amounts\r\n */\r\nexport function calculateDeductions(\r\n deductions: Deduction[],\r\n baseAmount: number\r\n): Array<Deduction & { calculatedAmount: number }> {\r\n return deductions.map((deduction) => ({\r\n ...deduction,\r\n calculatedAmount: calculateDeductionAmount(deduction, baseAmount),\r\n }));\r\n}\r\n\r\n// ============================================================================\r\n// Compensation Breakdown\r\n// ============================================================================\r\n\r\n/**\r\n * Calculate full compensation breakdown\r\n */\r\nexport function calculateCompensationBreakdown(\r\n compensation: Pick<Compensation, 'baseAmount' | 'allowances' | 'deductions'>\r\n): CompensationBreakdownResult {\r\n const { baseAmount, allowances = [], deductions = [] } = compensation;\r\n\r\n const calculatedAllowances = calculateAllowances(allowances, baseAmount);\r\n const calculatedDeductions = calculateDeductions(deductions, baseAmount);\r\n\r\n const grossAmount =\r\n baseAmount + sumBy(calculatedAllowances, (a) => a.calculatedAmount);\r\n const netAmount =\r\n grossAmount - sumBy(calculatedDeductions, (d) => d.calculatedAmount);\r\n\r\n return {\r\n baseAmount,\r\n allowances: calculatedAllowances,\r\n deductions: calculatedDeductions,\r\n grossAmount,\r\n netAmount: Math.max(0, netAmount),\r\n };\r\n}\r\n\r\n// ============================================================================\r\n// Pro-Rating Calculations\r\n// ============================================================================\r\n\r\n/**\r\n * Calculate pro-rating for mid-month hires\r\n */\r\nexport function calculateProRating(\r\n hireDate: Date,\r\n periodStart: Date,\r\n periodEnd: Date\r\n): ProRatingResult {\r\n const totalDays = diffInDays(periodStart, periodEnd) + 1;\r\n\r\n // Hired before period start - no pro-rating\r\n if (hireDate <= periodStart) {\r\n return {\r\n isProRated: false,\r\n totalDays,\r\n actualDays: totalDays,\r\n ratio: 1,\r\n };\r\n }\r\n\r\n // Hired during the period - pro-rate\r\n if (hireDate > periodStart && hireDate <= periodEnd) {\r\n const actualDays = diffInDays(hireDate, periodEnd) + 1;\r\n const ratio = actualDays / totalDays;\r\n\r\n return {\r\n isProRated: true,\r\n totalDays,\r\n actualDays,\r\n ratio,\r\n };\r\n }\r\n\r\n // Hired after period - no work days\r\n return {\r\n isProRated: false,\r\n totalDays,\r\n actualDays: 0,\r\n ratio: 0,\r\n };\r\n}\r\n\r\n/**\r\n * Apply pro-rating to an amount\r\n */\r\nexport function applyProRating(\r\n amount: number,\r\n proRating: ProRatingResult\r\n): number {\r\n return Math.round(amount * proRating.ratio);\r\n}\r\n\r\n/**\r\n * Calculate pro-rated salary\r\n */\r\nexport function calculateProRatedSalary(\r\n baseAmount: number,\r\n hireDate: Date,\r\n period: PayPeriodInfo\r\n): { amount: number; proRating: ProRatingResult } {\r\n const proRating = calculateProRating(hireDate, period.startDate, period.endDate);\r\n const amount = applyProRating(baseAmount, proRating);\r\n return { amount, proRating };\r\n}\r\n\r\n// ============================================================================\r\n// Tax Calculations\r\n// ============================================================================\r\n\r\n/**\r\n * Apply tax brackets to calculate tax\r\n */\r\nexport function applyTaxBrackets(\r\n amount: number,\r\n brackets: Array<{ min: number; max: number; rate: number }>\r\n): number {\r\n let tax = 0;\r\n\r\n for (const bracket of brackets) {\r\n if (amount > bracket.min) {\r\n const taxableAmount = Math.min(amount, bracket.max) - bracket.min;\r\n tax += taxableAmount * bracket.rate;\r\n }\r\n }\r\n\r\n return Math.round(tax);\r\n}\r\n\r\n/**\r\n * Calculate tax with result\r\n */\r\nexport function calculateTax(\r\n amount: number,\r\n brackets: Array<{ min: number; max: number; rate: number }>\r\n): TaxCalculationResult {\r\n const tax = applyTaxBrackets(amount, brackets);\r\n return {\r\n gross: amount,\r\n tax,\r\n net: amount - tax,\r\n };\r\n}\r\n\r\n// ============================================================================\r\n// Functional Composition\r\n// ============================================================================\r\n\r\n/**\r\n * Pipe functions left-to-right\r\n * pipe(f, g, h)(x) === h(g(f(x)))\r\n */\r\nexport function pipe<T>(...fns: Array<(value: T) => T>): (value: T) => T {\r\n return (value: T) => fns.reduce((acc, fn) => fn(acc), value);\r\n}\r\n\r\n/**\r\n * Compose functions right-to-left\r\n * compose(f, g, h)(x) === f(g(h(x)))\r\n */\r\nexport function compose<T>(...fns: Array<(value: T) => T>): (value: T) => T {\r\n return (value: T) => fns.reduceRight((acc, fn) => fn(acc), value);\r\n}\r\n\r\n/**\r\n * Create an allowance calculator factory\r\n */\r\nexport function createAllowanceCalculator(\r\n allowances: Allowance[]\r\n): (baseSalary: number) => Array<Allowance & { calculatedAmount: number }> {\r\n return (baseSalary: number) => calculateAllowances(allowances, baseSalary);\r\n}\r\n\r\n/**\r\n * Create a deduction calculator factory\r\n */\r\nexport function createDeductionCalculator(\r\n deductions: Deduction[]\r\n): (baseSalary: number) => Array<Deduction & { calculatedAmount: number }> {\r\n return (baseSalary: number) => calculateDeductions(deductions, baseSalary);\r\n}\r\n\r\n// ============================================================================\r\n// Overtime Calculations\r\n// ============================================================================\r\n\r\n/**\r\n * Calculate overtime pay\r\n */\r\nexport function calculateOvertime(\r\n hourlyRate: number,\r\n overtimeHours: number,\r\n multiplier = 1.5\r\n): number {\r\n return Math.round(hourlyRate * overtimeHours * multiplier);\r\n}\r\n\r\n/**\r\n * Calculate hourly rate from monthly salary\r\n */\r\nexport function calculateHourlyRate(\r\n monthlySalary: number,\r\n hoursPerMonth = 176 // 44 hours/week * 4 weeks\r\n): number {\r\n return Math.round(monthlySalary / hoursPerMonth);\r\n}\r\n\r\n/**\r\n * Calculate daily rate from monthly salary\r\n */\r\nexport function calculateDailyRate(\r\n monthlySalary: number,\r\n daysPerMonth = 22\r\n): number {\r\n return Math.round(monthlySalary / daysPerMonth);\r\n}\r\n\r\n// ============================================================================\r\n// Default Export\r\n// ============================================================================\r\n\r\nexport default {\r\n sum,\r\n sumBy,\r\n sumAllowances,\r\n sumDeductions,\r\n applyPercentage,\r\n calculatePercentage,\r\n roundTo,\r\n calculateGross,\r\n calculateNet,\r\n calculateTotalCompensation,\r\n calculateAllowanceAmount,\r\n calculateDeductionAmount,\r\n calculateAllowances,\r\n calculateDeductions,\r\n calculateCompensationBreakdown,\r\n calculateProRating,\r\n applyProRating,\r\n calculateProRatedSalary,\r\n applyTaxBrackets,\r\n calculateTax,\r\n pipe,\r\n compose,\r\n createAllowanceCalculator,\r\n createDeductionCalculator,\r\n calculateOvertime,\r\n calculateHourlyRate,\r\n calculateDailyRate,\r\n};\r\n\r\n","/**\r\n * @classytic/payroll - Enums\r\n *\r\n * Type-safe enum definitions with const assertions\r\n * Single source of truth for all enum values\r\n */\r\n\r\nimport type {\r\n EmploymentType,\r\n EmployeeStatus,\r\n Department,\r\n PaymentFrequency,\r\n PaymentMethod,\r\n AllowanceType,\r\n DeductionType,\r\n PayrollStatus,\r\n TerminationReason,\r\n HRMTransactionCategory,\r\n SalaryBand,\r\n OrgRole,\r\n} from './types.js';\r\n\r\n// ============================================================================\r\n// Employment Type\r\n// ============================================================================\r\n\r\nexport const EMPLOYMENT_TYPE = {\r\n FULL_TIME: 'full_time',\r\n PART_TIME: 'part_time',\r\n CONTRACT: 'contract',\r\n INTERN: 'intern',\r\n CONSULTANT: 'consultant',\r\n} as const satisfies Record<string, EmploymentType>;\r\n\r\nexport const EMPLOYMENT_TYPE_VALUES = Object.values(EMPLOYMENT_TYPE);\r\n\r\nexport function isValidEmploymentType(value: string): value is EmploymentType {\r\n return EMPLOYMENT_TYPE_VALUES.includes(value as EmploymentType);\r\n}\r\n\r\n// ============================================================================\r\n// Employee Status\r\n// ============================================================================\r\n\r\nexport const EMPLOYEE_STATUS = {\r\n ACTIVE: 'active',\r\n ON_LEAVE: 'on_leave',\r\n SUSPENDED: 'suspended',\r\n TERMINATED: 'terminated',\r\n} as const satisfies Record<string, EmployeeStatus>;\r\n\r\nexport const EMPLOYEE_STATUS_VALUES = Object.values(EMPLOYEE_STATUS);\r\n\r\nexport function isValidEmployeeStatus(value: string): value is EmployeeStatus {\r\n return EMPLOYEE_STATUS_VALUES.includes(value as EmployeeStatus);\r\n}\r\n\r\nexport function isActiveStatus(status: EmployeeStatus): boolean {\r\n return status === EMPLOYEE_STATUS.ACTIVE;\r\n}\r\n\r\nexport function isEmployedStatus(status: EmployeeStatus): boolean {\r\n return status !== EMPLOYEE_STATUS.TERMINATED;\r\n}\r\n\r\nexport function canReceiveSalaryStatus(status: EmployeeStatus): boolean {\r\n return status === EMPLOYEE_STATUS.ACTIVE || status === EMPLOYEE_STATUS.ON_LEAVE;\r\n}\r\n\r\n// ============================================================================\r\n// Department\r\n// ============================================================================\r\n\r\nexport const DEPARTMENT = {\r\n MANAGEMENT: 'management',\r\n TRAINING: 'training',\r\n SALES: 'sales',\r\n OPERATIONS: 'operations',\r\n SUPPORT: 'support',\r\n HR: 'hr',\r\n MAINTENANCE: 'maintenance',\r\n MARKETING: 'marketing',\r\n FINANCE: 'finance',\r\n IT: 'it',\r\n} as const satisfies Record<string, Department>;\r\n\r\nexport const DEPARTMENT_VALUES = Object.values(DEPARTMENT);\r\n\r\nexport function isValidDepartment(value: string): value is Department {\r\n return DEPARTMENT_VALUES.includes(value as Department);\r\n}\r\n\r\n// ============================================================================\r\n// Payment Frequency\r\n// ============================================================================\r\n\r\nexport const PAYMENT_FREQUENCY = {\r\n MONTHLY: 'monthly',\r\n BI_WEEKLY: 'bi_weekly',\r\n WEEKLY: 'weekly',\r\n HOURLY: 'hourly',\r\n DAILY: 'daily',\r\n} as const satisfies Record<string, PaymentFrequency>;\r\n\r\nexport const PAYMENT_FREQUENCY_VALUES = Object.values(PAYMENT_FREQUENCY);\r\n\r\nexport function isValidPaymentFrequency(value: string): value is PaymentFrequency {\r\n return PAYMENT_FREQUENCY_VALUES.includes(value as PaymentFrequency);\r\n}\r\n\r\n// ============================================================================\r\n// Payment Method\r\n// ============================================================================\r\n\r\nexport const PAYMENT_METHOD = {\r\n BANK: 'bank',\r\n CASH: 'cash',\r\n MOBILE: 'mobile',\r\n BKASH: 'bkash',\r\n NAGAD: 'nagad',\r\n ROCKET: 'rocket',\r\n CHECK: 'check',\r\n} as const satisfies Record<string, PaymentMethod>;\r\n\r\nexport const PAYMENT_METHOD_VALUES = Object.values(PAYMENT_METHOD);\r\n\r\nexport function isValidPaymentMethod(value: string): value is PaymentMethod {\r\n return PAYMENT_METHOD_VALUES.includes(value as PaymentMethod);\r\n}\r\n\r\n// ============================================================================\r\n// Allowance Type\r\n// ============================================================================\r\n\r\nexport const ALLOWANCE_TYPE = {\r\n HOUSING: 'housing',\r\n TRANSPORT: 'transport',\r\n MEAL: 'meal',\r\n MOBILE: 'mobile',\r\n MEDICAL: 'medical',\r\n EDUCATION: 'education',\r\n BONUS: 'bonus',\r\n OTHER: 'other',\r\n} as const satisfies Record<string, AllowanceType>;\r\n\r\nexport const ALLOWANCE_TYPE_VALUES = Object.values(ALLOWANCE_TYPE);\r\n\r\nexport function isValidAllowanceType(value: string): value is AllowanceType {\r\n return ALLOWANCE_TYPE_VALUES.includes(value as AllowanceType);\r\n}\r\n\r\n// ============================================================================\r\n// Deduction Type\r\n// ============================================================================\r\n\r\nexport const DEDUCTION_TYPE = {\r\n TAX: 'tax',\r\n LOAN: 'loan',\r\n ADVANCE: 'advance',\r\n PROVIDENT_FUND: 'provident_fund',\r\n INSURANCE: 'insurance',\r\n ABSENCE: 'absence',\r\n OTHER: 'other',\r\n} as const satisfies Record<string, DeductionType>;\r\n\r\nexport const DEDUCTION_TYPE_VALUES = Object.values(DEDUCTION_TYPE);\r\n\r\nexport function isValidDeductionType(value: string): value is DeductionType {\r\n return DEDUCTION_TYPE_VALUES.includes(value as DeductionType);\r\n}\r\n\r\n// ============================================================================\r\n// Payroll Status\r\n// ============================================================================\r\n\r\nexport const PAYROLL_STATUS = {\r\n PENDING: 'pending',\r\n PROCESSING: 'processing',\r\n PAID: 'paid',\r\n FAILED: 'failed',\r\n CANCELLED: 'cancelled',\r\n} as const satisfies Record<string, PayrollStatus>;\r\n\r\nexport const PAYROLL_STATUS_VALUES = Object.values(PAYROLL_STATUS);\r\n\r\nexport function isValidPayrollStatus(value: string): value is PayrollStatus {\r\n return PAYROLL_STATUS_VALUES.includes(value as PayrollStatus);\r\n}\r\n\r\nexport function isCompletedPayrollStatus(status: PayrollStatus): boolean {\r\n return status === PAYROLL_STATUS.PAID;\r\n}\r\n\r\nexport function isPendingPayrollStatus(status: PayrollStatus): boolean {\r\n return status === PAYROLL_STATUS.PENDING || status === PAYROLL_STATUS.PROCESSING;\r\n}\r\n\r\n// ============================================================================\r\n// Termination Reason\r\n// ============================================================================\r\n\r\nexport const TERMINATION_REASON = {\r\n RESIGNATION: 'resignation',\r\n RETIREMENT: 'retirement',\r\n TERMINATION: 'termination',\r\n CONTRACT_END: 'contract_end',\r\n MUTUAL_AGREEMENT: 'mutual_agreement',\r\n OTHER: 'other',\r\n} as const satisfies Record<string, TerminationReason>;\r\n\r\nexport const TERMINATION_REASON_VALUES = Object.values(TERMINATION_REASON);\r\n\r\nexport function isValidTerminationReason(value: string): value is TerminationReason {\r\n return TERMINATION_REASON_VALUES.includes(value as TerminationReason);\r\n}\r\n\r\n// ============================================================================\r\n// HRM Transaction Categories\r\n// ============================================================================\r\n\r\nexport const HRM_TRANSACTION_CATEGORIES = {\r\n SALARY: 'salary',\r\n BONUS: 'bonus',\r\n COMMISSION: 'commission',\r\n OVERTIME: 'overtime',\r\n SEVERANCE: 'severance',\r\n} as const satisfies Record<string, HRMTransactionCategory>;\r\n\r\nexport const HRM_CATEGORY_VALUES = Object.values(HRM_TRANSACTION_CATEGORIES);\r\n\r\nexport function isHRMManagedCategory(category: string): category is HRMTransactionCategory {\r\n return HRM_CATEGORY_VALUES.includes(category as HRMTransactionCategory);\r\n}\r\n\r\n// ============================================================================\r\n// Salary Band\r\n// ============================================================================\r\n\r\nexport const SALARY_BAND = {\r\n INTERN: 'intern',\r\n JUNIOR: 'junior',\r\n MID: 'mid',\r\n SENIOR: 'senior',\r\n LEAD: 'lead',\r\n EXECUTIVE: 'executive',\r\n CUSTOM: 'custom',\r\n} as const satisfies Record<string, SalaryBand>;\r\n\r\nexport const SALARY_BAND_VALUES = Object.values(SALARY_BAND);\r\n\r\nexport function isValidSalaryBand(value: string): value is SalaryBand {\r\n return SALARY_BAND_VALUES.includes(value as SalaryBand);\r\n}\r\n\r\n// ============================================================================\r\n// Organization Role\r\n// ============================================================================\r\n\r\nexport const ORG_ROLE = {\r\n OWNER: 'owner',\r\n MANAGER: 'manager',\r\n TRAINER: 'trainer',\r\n STAFF: 'staff',\r\n INTERN: 'intern',\r\n CONSULTANT: 'consultant',\r\n} as const satisfies Record<string, OrgRole>;\r\n\r\nexport const ORG_ROLE_VALUES = Object.values(ORG_ROLE);\r\n\r\nexport function isValidOrgRole(value: string): value is OrgRole {\r\n return ORG_ROLE_VALUES.includes(value as OrgRole);\r\n}\r\n\r\n// ============================================================================\r\n// Default Export\r\n// ============================================================================\r\n\r\nexport default {\r\n EMPLOYMENT_TYPE,\r\n EMPLOYMENT_TYPE_VALUES,\r\n EMPLOYEE_STATUS,\r\n EMPLOYEE_STATUS_VALUES,\r\n DEPARTMENT,\r\n DEPARTMENT_VALUES,\r\n PAYMENT_FREQUENCY,\r\n PAYMENT_FREQUENCY_VALUES,\r\n PAYMENT_METHOD,\r\n PAYMENT_METHOD_VALUES,\r\n ALLOWANCE_TYPE,\r\n ALLOWANCE_TYPE_VALUES,\r\n DEDUCTION_TYPE,\r\n DEDUCTION_TYPE_VALUES,\r\n PAYROLL_STATUS,\r\n PAYROLL_STATUS_VALUES,\r\n TERMINATION_REASON,\r\n TERMINATION_REASON_VALUES,\r\n HRM_TRANSACTION_CATEGORIES,\r\n HRM_CATEGORY_VALUES,\r\n SALARY_BAND,\r\n SALARY_BAND_VALUES,\r\n ORG_ROLE,\r\n ORG_ROLE_VALUES,\r\n};\r\n\r\n","/**\r\n * @classytic/payroll - Validation Utilities\r\n *\r\n * Fluent, composable, type-safe validation\r\n * Clear semantics and helpful error messages\r\n */\r\n\r\nimport type {\r\n EmployeeStatus,\r\n EmploymentType,\r\n Compensation,\r\n BankDetails,\r\n EmployeeValidationResult,\r\n} from '../types.js';\r\nimport {\r\n EMPLOYEE_STATUS_VALUES,\r\n EMPLOYMENT_TYPE_VALUES,\r\n} from '../enums.js';\r\nimport { diffInMonths } from './date.js';\r\n\r\n// ============================================================================\r\n// Employee Status Validators\r\n// ============================================================================\r\n\r\n/**\r\n * Check if employee is active\r\n */\r\nexport function isActive(employee: { status?: EmployeeStatus }): boolean {\r\n return employee?.status === 'active';\r\n}\r\n\r\n/**\r\n * Check if employee is on leave\r\n */\r\nexport function isOnLeave(employee: { status?: EmployeeStatus }): boolean {\r\n return employee?.status === 'on_leave';\r\n}\r\n\r\n/**\r\n * Check if employee is suspended\r\n */\r\nexport function isSuspended(employee: { status?: EmployeeStatus }): boolean {\r\n return employee?.status === 'suspended';\r\n}\r\n\r\n/**\r\n * Check if employee is terminated\r\n */\r\nexport function isTerminated(employee: { status?: EmployeeStatus }): boolean {\r\n return employee?.status === 'terminated';\r\n}\r\n\r\n/**\r\n * Check if employee is employed (not terminated)\r\n */\r\nexport function isEmployed(employee: { status?: EmployeeStatus }): boolean {\r\n return (\r\n isActive(employee) || isOnLeave(employee) || isSuspended(employee)\r\n );\r\n}\r\n\r\n/**\r\n * Check if employee can receive salary\r\n */\r\nexport function canReceiveSalary(employee: {\r\n status?: EmployeeStatus;\r\n compensation?: { baseAmount?: number };\r\n}): boolean {\r\n return (\r\n (isActive(employee) || isOnLeave(employee)) &&\r\n (employee.compensation?.baseAmount ?? 0) > 0\r\n );\r\n}\r\n\r\n/**\r\n * Check if employment can be updated\r\n */\r\nexport function canUpdateEmployment(employee: { status?: EmployeeStatus }): boolean {\r\n return !isTerminated(employee);\r\n}\r\n\r\n// ============================================================================\r\n// Compensation Validators\r\n// ============================================================================\r\n\r\n/**\r\n * Check if employee has valid compensation\r\n */\r\nexport function hasCompensation(employee: {\r\n compensation?: { baseAmount?: number };\r\n}): boolean {\r\n return (employee.compensation?.baseAmount ?? 0) > 0;\r\n}\r\n\r\n/**\r\n * Check if compensation is valid\r\n */\r\nexport function isValidCompensation(compensation?: Compensation): boolean {\r\n return !!(\r\n compensation?.baseAmount &&\r\n compensation.baseAmount > 0 &&\r\n compensation.frequency &&\r\n compensation.currency\r\n );\r\n}\r\n\r\n/**\r\n * Check if bank details are valid\r\n */\r\nexport function isValidBankDetails(bankDetails?: BankDetails): boolean {\r\n return !!(\r\n bankDetails?.accountNumber &&\r\n bankDetails.bankName &&\r\n bankDetails.accountName\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Probation Validators\r\n// ============================================================================\r\n\r\n/**\r\n * Check if employee is in probation\r\n */\r\nexport function isInProbation(\r\n employee: { probationEndDate?: Date | null },\r\n now = new Date()\r\n): boolean {\r\n if (!employee?.probationEndDate) return false;\r\n return new Date(employee.probationEndDate) > now;\r\n}\r\n\r\n/**\r\n * Check if employee has completed probation\r\n */\r\nexport function hasCompletedProbation(\r\n employee: { probationEndDate?: Date | null },\r\n now = new Date()\r\n): boolean {\r\n if (!employee?.probationEndDate) return true;\r\n return new Date(employee.probationEndDate) <= now;\r\n}\r\n\r\n// ============================================================================\r\n// Eligibility Validators\r\n// ============================================================================\r\n\r\n/**\r\n * Check if employee is eligible for bonus\r\n */\r\nexport function isEligibleForBonus(\r\n employee: { status?: EmployeeStatus; hireDate?: Date },\r\n requiredMonths = 6\r\n): boolean {\r\n if (!isActive(employee) || !employee.hireDate) return false;\r\n const monthsEmployed = diffInMonths(employee.hireDate, new Date());\r\n return monthsEmployed >= requiredMonths;\r\n}\r\n\r\n/**\r\n * Check if employee is eligible for payroll\r\n */\r\nexport function isEligibleForPayroll(employee: {\r\n status?: EmployeeStatus;\r\n compensation?: { baseAmount?: number };\r\n bankDetails?: BankDetails;\r\n}): { eligible: boolean; reasons: string[] } {\r\n const reasons: string[] = [];\r\n\r\n if (!isActive(employee) && !isOnLeave(employee)) {\r\n reasons.push('Employee is not in active or on-leave status');\r\n }\r\n\r\n if (!hasCompensation(employee)) {\r\n reasons.push('Employee has no valid compensation');\r\n }\r\n\r\n return {\r\n eligible: reasons.length === 0,\r\n reasons,\r\n };\r\n}\r\n\r\n// ============================================================================\r\n// Field Validators\r\n// ============================================================================\r\n\r\n/**\r\n * Check if value is required\r\n */\r\nexport function required(fieldName: string): (value: unknown) => string | true {\r\n return (value: unknown) =>\r\n value !== undefined && value !== null && value !== ''\r\n ? true\r\n : `${fieldName} is required`;\r\n}\r\n\r\n/**\r\n * Check minimum value\r\n */\r\nexport function min(\r\n minValue: number,\r\n fieldName: string\r\n): (value: number) => string | true {\r\n return (value: number) =>\r\n value >= minValue ? true : `${fieldName} must be at least ${minValue}`;\r\n}\r\n\r\n/**\r\n * Check maximum value\r\n */\r\nexport function max(\r\n maxValue: number,\r\n fieldName: string\r\n): (value: number) => string | true {\r\n return (value: number) =>\r\n value <= maxValue ? true : `${fieldName} must not exceed ${maxValue}`;\r\n}\r\n\r\n/**\r\n * Check value is in range\r\n */\r\nexport function inRange(\r\n minValue: number,\r\n maxValue: number,\r\n fieldName: string\r\n): (value: number) => string | true {\r\n return (value: number) =>\r\n value >= minValue && value <= maxValue\r\n ? true\r\n : `${fieldName} must be between ${minValue} and ${maxValue}`;\r\n}\r\n\r\n/**\r\n * Check value is positive\r\n */\r\nexport function isPositive(fieldName: string): (value: number) => string | true {\r\n return (value: number) =>\r\n value > 0 ? true : `${fieldName} must be positive`;\r\n}\r\n\r\n/**\r\n * Check value is one of allowed values\r\n */\r\nexport function oneOf<T extends string>(\r\n allowedValues: readonly T[],\r\n fieldName: string\r\n): (value: T) => string | true {\r\n return (value: T) =>\r\n allowedValues.includes(value)\r\n ? true\r\n : `${fieldName} must be one of: ${allowedValues.join(', ')}`;\r\n}\r\n\r\n// ============================================================================\r\n// Enum Validators\r\n// ============================================================================\r\n\r\n/**\r\n * Check if status is valid\r\n */\r\nexport function isValidStatus(value: string): value is EmployeeStatus {\r\n return EMPLOYEE_STATUS_VALUES.includes(value as EmployeeStatus);\r\n}\r\n\r\n/**\r\n * Check if employment type is valid\r\n */\r\nexport function isValidEmploymentType(value: string): value is EmploymentType {\r\n return EMPLOYMENT_TYPE_VALUES.includes(value as EmploymentType);\r\n}\r\n\r\n// ============================================================================\r\n// Composite Validators\r\n// ============================================================================\r\n\r\n/**\r\n * Compose multiple validators\r\n */\r\nexport function composeValidators<T>(\r\n ...validators: Array<(value: T, data?: unknown) => string | true>\r\n): (value: T, data?: unknown) => string | true {\r\n return (value: T, data?: unknown) => {\r\n for (const validator of validators) {\r\n const result = validator(value, data);\r\n if (result !== true) return result;\r\n }\r\n return true;\r\n };\r\n}\r\n\r\n/**\r\n * Create a validator from validation functions\r\n */\r\nexport function createValidator<T extends Record<string, unknown>>(\r\n validationFns: Record<string, (value: unknown, data: T) => string | true>\r\n): (data: T) => EmployeeValidationResult {\r\n return (data: T) => {\r\n const errors: string[] = [];\r\n\r\n for (const [field, validator] of Object.entries(validationFns)) {\r\n const result = validator((data as Record<string, unknown>)[field], data);\r\n if (result !== true) {\r\n errors.push(result);\r\n }\r\n }\r\n\r\n return {\r\n valid: errors.length === 0,\r\n errors,\r\n };\r\n };\r\n}\r\n\r\n/**\r\n * Validate required fields exist\r\n */\r\nexport function hasRequiredFields(\r\n obj: Record<string, unknown>,\r\n fields: string[]\r\n): { valid: boolean; missing: string[] } {\r\n const missing = fields.filter(\r\n (field) => obj[field] === undefined || obj[field] === null\r\n );\r\n return {\r\n valid: missing.length === 0,\r\n missing,\r\n };\r\n}\r\n\r\n// ============================================================================\r\n// Aliases for backwards compatibility\r\n// ============================================================================\r\n\r\nexport const minValue = min;\r\nexport const maxValue = max;\r\nexport const isInRange = inRange;\r\n\r\n// ============================================================================\r\n// Default Export\r\n// ============================================================================\r\n\r\nexport default {\r\n // Status validators\r\n isActive,\r\n isOnLeave,\r\n isSuspended,\r\n isTerminated,\r\n isEmployed,\r\n canReceiveSalary,\r\n canUpdateEmployment,\r\n // Compensation validators\r\n hasCompensation,\r\n isValidCompensation,\r\n isValidBankDetails,\r\n // Probation validators\r\n isInProbation,\r\n hasCompletedProbation,\r\n // Eligibility validators\r\n isEligibleForBonus,\r\n isEligibleForPayroll,\r\n // Field validators\r\n required,\r\n min,\r\n max,\r\n inRange,\r\n isPositive,\r\n oneOf,\r\n // Enum validators\r\n isValidStatus,\r\n isValidEmploymentType,\r\n // Composite validators\r\n composeValidators,\r\n createValidator,\r\n hasRequiredFields,\r\n};\r\n\r\n","/**\r\n * @classytic/payroll - Query Builders\r\n *\r\n * Fluent API for building MongoDB queries\r\n * Type-safe, chainable, beautiful\r\n */\r\n\r\nimport mongoose, { Types } from 'mongoose';\r\nimport type {\r\n ObjectIdLike,\r\n EmployeeStatus,\r\n PayrollStatus,\r\n Department,\r\n EmploymentType,\r\n} from '../types.js';\r\n\r\n// ============================================================================\r\n// ObjectId Helpers\r\n// ============================================================================\r\n\r\n/**\r\n * Convert string or ObjectId to ObjectId\r\n */\r\nexport function toObjectId(id: ObjectIdLike): Types.ObjectId {\r\n if (id instanceof Types.ObjectId) return id;\r\n return new Types.ObjectId(id);\r\n}\r\n\r\n/**\r\n * Safely convert to ObjectId (returns null if invalid)\r\n */\r\nexport function safeToObjectId(id: unknown): Types.ObjectId | null {\r\n if (id instanceof Types.ObjectId) return id;\r\n if (typeof id === 'string' && Types.ObjectId.isValid(id)) {\r\n return new Types.ObjectId(id);\r\n }\r\n return null;\r\n}\r\n\r\n/**\r\n * Check if value is valid ObjectId\r\n */\r\nexport function isValidObjectId(value: unknown): boolean {\r\n if (value instanceof Types.ObjectId) return true;\r\n if (typeof value === 'string') return Types.ObjectId.isValid(value);\r\n return false;\r\n}\r\n\r\n// ============================================================================\r\n// Base Query Builder\r\n// ============================================================================\r\n\r\nexport class QueryBuilder<T extends Record<string, unknown> = Record<string, unknown>> {\r\n protected query: T;\r\n\r\n constructor(initialQuery: T = {} as T) {\r\n this.query = { ...initialQuery };\r\n }\r\n\r\n /**\r\n * Add where condition\r\n */\r\n where<K extends string>(field: K, value: unknown): this {\r\n (this.query as Record<string, unknown>)[field] = value;\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $in condition\r\n */\r\n whereIn<K extends string>(field: K, values: unknown[]): this {\r\n (this.query as Record<string, unknown>)[field] = { $in: values };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $nin condition\r\n */\r\n whereNotIn<K extends string>(field: K, values: unknown[]): this {\r\n (this.query as Record<string, unknown>)[field] = { $nin: values };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $gte condition\r\n */\r\n whereGte<K extends string>(field: K, value: unknown): this {\r\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\r\n (this.query as Record<string, unknown>)[field] = { ...existing, $gte: value };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $lte condition\r\n */\r\n whereLte<K extends string>(field: K, value: unknown): this {\r\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\r\n (this.query as Record<string, unknown>)[field] = { ...existing, $lte: value };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $gt condition\r\n */\r\n whereGt<K extends string>(field: K, value: unknown): this {\r\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\r\n (this.query as Record<string, unknown>)[field] = { ...existing, $gt: value };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $lt condition\r\n */\r\n whereLt<K extends string>(field: K, value: unknown): this {\r\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\r\n (this.query as Record<string, unknown>)[field] = { ...existing, $lt: value };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add between condition\r\n */\r\n whereBetween<K extends string>(field: K, start: unknown, end: unknown): this {\r\n (this.query as Record<string, unknown>)[field] = { $gte: start, $lte: end };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $exists condition\r\n */\r\n whereExists<K extends string>(field: K): this {\r\n (this.query as Record<string, unknown>)[field] = { $exists: true };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $exists: false condition\r\n */\r\n whereNotExists<K extends string>(field: K): this {\r\n (this.query as Record<string, unknown>)[field] = { $exists: false };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add $ne condition\r\n */\r\n whereNot<K extends string>(field: K, value: unknown): this {\r\n (this.query as Record<string, unknown>)[field] = { $ne: value };\r\n return this;\r\n }\r\n\r\n /**\r\n * Add regex condition\r\n */\r\n whereRegex<K extends string>(field: K, pattern: string, flags = 'i'): this {\r\n (this.query as Record<string, unknown>)[field] = { $regex: pattern, $options: flags };\r\n return this;\r\n }\r\n\r\n /**\r\n * Merge another query\r\n */\r\n merge(otherQuery: Record<string, unknown>): this {\r\n this.query = { ...this.query, ...otherQuery } as T;\r\n return this;\r\n }\r\n\r\n /**\r\n * Build and return the query\r\n */\r\n build(): T {\r\n return { ...this.query };\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Employee Query Builder\r\n// ============================================================================\r\n\r\nexport class EmployeeQueryBuilder extends QueryBuilder {\r\n /**\r\n * Filter by organization\r\n */\r\n forOrganization(organizationId: ObjectIdLike): this {\r\n return this.where('organizationId', toObjectId(organizationId));\r\n }\r\n\r\n /**\r\n * Filter by user\r\n */\r\n forUser(userId: ObjectIdLike): this {\r\n return this.where('userId', toObjectId(userId));\r\n }\r\n\r\n /**\r\n * Filter by status(es)\r\n */\r\n withStatus(...statuses: EmployeeStatus[]): this {\r\n if (statuses.length === 1) {\r\n return this.where('status', statuses[0]);\r\n }\r\n return this.whereIn('status', statuses);\r\n }\r\n\r\n /**\r\n * Filter active employees\r\n */\r\n active(): this {\r\n return this.withStatus('active');\r\n }\r\n\r\n /**\r\n * Filter employed employees (not terminated)\r\n */\r\n employed(): this {\r\n return this.whereIn('status', ['active', 'on_leave', 'suspended']);\r\n }\r\n\r\n /**\r\n * Filter terminated employees\r\n */\r\n terminated(): this {\r\n return this.withStatus('terminated');\r\n }\r\n\r\n /**\r\n * Filter by department\r\n */\r\n inDepartment(department: Department | string): this {\r\n return this.where('department', department);\r\n }\r\n\r\n /**\r\n * Filter by position\r\n */\r\n inPosition(position: string): this {\r\n return this.where('position', position);\r\n }\r\n\r\n /**\r\n * Filter by employment type\r\n */\r\n withEmploymentType(type: EmploymentType | string): this {\r\n return this.where('employmentType', type);\r\n }\r\n\r\n /**\r\n * Filter by hire date (after)\r\n */\r\n hiredAfter(date: Date): this {\r\n return this.whereGte('hireDate', date);\r\n }\r\n\r\n /**\r\n * Filter by hire date (before)\r\n */\r\n hiredBefore(date: Date): this {\r\n return this.whereLte('hireDate', date);\r\n }\r\n\r\n /**\r\n * Filter by minimum salary\r\n */\r\n withMinSalary(amount: number): this {\r\n return this.whereGte('compensation.netSalary', amount);\r\n }\r\n\r\n /**\r\n * Filter by maximum salary\r\n */\r\n withMaxSalary(amount: number): this {\r\n return this.whereLte('compensation.netSalary', amount);\r\n }\r\n\r\n /**\r\n * Filter by salary range\r\n */\r\n withSalaryRange(min: number, max: number): this {\r\n return this.whereBetween('compensation.netSalary', min, max);\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Payroll Query Builder\r\n// ============================================================================\r\n\r\nexport class PayrollQueryBuilder extends QueryBuilder {\r\n /**\r\n * Filter by organization\r\n */\r\n forOrganization(organizationId: ObjectIdLike): this {\r\n return this.where('organizationId', toObjectId(organizationId));\r\n }\r\n\r\n /**\r\n * Filter by employee\r\n */\r\n forEmployee(employeeId: ObjectIdLike): this {\r\n return this.where('employeeId', toObjectId(employeeId));\r\n }\r\n\r\n /**\r\n * Filter by period\r\n */\r\n forPeriod(month?: number, year?: number): this {\r\n if (month !== undefined) {\r\n this.where('period.month', month);\r\n }\r\n if (year !== undefined) {\r\n this.where('period.year', year);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Filter by status(es)\r\n */\r\n withStatus(...statuses: PayrollStatus[]): this {\r\n if (statuses.length === 1) {\r\n return this.where('status', statuses[0]);\r\n }\r\n return this.whereIn('status', statuses);\r\n }\r\n\r\n /**\r\n * Filter paid records\r\n */\r\n paid(): this {\r\n return this.withStatus('paid');\r\n }\r\n\r\n /**\r\n * Filter pending records\r\n */\r\n pending(): this {\r\n return this.whereIn('status', ['pending', 'processing']);\r\n }\r\n\r\n /**\r\n * Filter by date range\r\n */\r\n inDateRange(start: Date, end: Date): this {\r\n return this.whereBetween('period.payDate', start, end);\r\n }\r\n\r\n /**\r\n * Filter exported records\r\n */\r\n exported(): this {\r\n return this.where('exported', true);\r\n }\r\n\r\n /**\r\n * Filter not exported records\r\n */\r\n notExported(): this {\r\n return this.where('exported', false);\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Factory Functions\r\n// ============================================================================\r\n\r\n/**\r\n * Create employee query builder\r\n */\r\nexport function employee(): EmployeeQueryBuilder {\r\n return new EmployeeQueryBuilder();\r\n}\r\n\r\n/**\r\n * Create payroll query builder\r\n */\r\nexport function payroll(): PayrollQueryBuilder {\r\n return new PayrollQueryBuilder();\r\n}\r\n\r\n/**\r\n * Create generic query builder\r\n */\r\nexport function createQueryBuilder<T extends Record<string, unknown> = Record<string, unknown>>(\r\n initialQuery?: T\r\n): QueryBuilder<T> {\r\n return new QueryBuilder(initialQuery);\r\n}\r\n\r\n// ============================================================================\r\n// Convenience Query Builders\r\n// ============================================================================\r\n\r\n/**\r\n * Build employee query from options\r\n */\r\nexport function buildEmployeeQuery(options: {\r\n organizationId: ObjectIdLike;\r\n userId?: ObjectIdLike;\r\n statuses?: EmployeeStatus[];\r\n department?: Department | string;\r\n employmentType?: EmploymentType | string;\r\n}): Record<string, unknown> {\r\n const builder = employee().forOrganization(options.organizationId);\r\n\r\n if (options.userId) {\r\n builder.forUser(options.userId);\r\n }\r\n if (options.statuses) {\r\n builder.withStatus(...options.statuses);\r\n }\r\n if (options.department) {\r\n builder.inDepartment(options.department);\r\n }\r\n if (options.employmentType) {\r\n builder.withEmploymentType(options.employmentType);\r\n }\r\n\r\n return builder.build();\r\n}\r\n\r\n/**\r\n * Build payroll query from options\r\n */\r\nexport function buildPayrollQuery(options: {\r\n employeeId?: ObjectIdLike;\r\n organizationId?: ObjectIdLike;\r\n month?: number;\r\n year?: number;\r\n statuses?: PayrollStatus[];\r\n}): Record<string, unknown> {\r\n const builder = payroll();\r\n\r\n if (options.organizationId) {\r\n builder.forOrganization(options.organizationId);\r\n }\r\n if (options.employeeId) {\r\n builder.forEmployee(options.employeeId);\r\n }\r\n if (options.month || options.year) {\r\n builder.forPeriod(options.month, options.year);\r\n }\r\n if (options.statuses) {\r\n builder.withStatus(...options.statuses);\r\n }\r\n\r\n return builder.build();\r\n}\r\n\r\n// ============================================================================\r\n// Aggregation Pipeline Helpers\r\n// ============================================================================\r\n\r\n/**\r\n * Build aggregation pipeline from stages\r\n */\r\nexport function buildAggregationPipeline(\r\n ...stages: Array<Record<string, unknown> | undefined | null>\r\n): Record<string, unknown>[] {\r\n return stages.filter((stage): stage is Record<string, unknown> => !!stage);\r\n}\r\n\r\n/**\r\n * Match stage\r\n */\r\nexport function matchStage(query: Record<string, unknown>): Record<string, unknown> {\r\n return { $match: query };\r\n}\r\n\r\n/**\r\n * Group stage\r\n */\r\nexport function groupStage(\r\n groupBy: string | null,\r\n aggregations: Record<string, unknown>\r\n): Record<string, unknown> {\r\n return {\r\n $group: {\r\n _id: groupBy,\r\n ...aggregations,\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Sort stage\r\n */\r\nexport function sortStage(sortBy: Record<string, 1 | -1>): Record<string, unknown> {\r\n return { $sort: sortBy };\r\n}\r\n\r\n/**\r\n * Limit stage\r\n */\r\nexport function limitStage(limit: number): Record<string, unknown> {\r\n return { $limit: limit };\r\n}\r\n\r\n/**\r\n * Skip stage\r\n */\r\nexport function skipStage(skip: number): Record<string, unknown> {\r\n return { $skip: skip };\r\n}\r\n\r\n/**\r\n * Project stage\r\n */\r\nexport function projectStage(fields: Record<string, unknown>): Record<string, unknown> {\r\n return { $project: fields };\r\n}\r\n\r\n/**\r\n * Lookup stage\r\n */\r\nexport function lookupStage(options: {\r\n from: string;\r\n localField: string;\r\n foreignField: string;\r\n as: string;\r\n}): Record<string, unknown> {\r\n return { $lookup: options };\r\n}\r\n\r\n/**\r\n * Unwind stage\r\n */\r\nexport function unwindStage(\r\n path: string,\r\n options: { preserveNullAndEmptyArrays?: boolean } = {}\r\n): Record<string, unknown> {\r\n return { $unwind: { path, ...options } };\r\n}\r\n\r\n// ============================================================================\r\n// Default Export\r\n// ============================================================================\r\n\r\nexport default {\r\n toObjectId,\r\n safeToObjectId,\r\n isValidObjectId,\r\n QueryBuilder,\r\n EmployeeQueryBuilder,\r\n PayrollQueryBuilder,\r\n employee,\r\n payroll,\r\n createQueryBuilder,\r\n buildEmployeeQuery,\r\n buildPayrollQuery,\r\n buildAggregationPipeline,\r\n matchStage,\r\n groupStage,\r\n sortStage,\r\n limitStage,\r\n skipStage,\r\n projectStage,\r\n lookupStage,\r\n unwindStage,\r\n};\r\n\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logger.ts","../../src/utils/date.ts","../../src/utils/calculation.ts","../../src/enums.ts","../../src/utils/validation.ts","../../src/utils/query-builders.ts","../../src/utils/leave.ts","../../src/errors/index.ts","../../src/utils/employee-lookup.ts","../../src/utils/org-resolution.ts","../../src/utils/employee-identity.ts"],"names":["logger","employee","minValue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AAY;AACzB,IAAA,OAAO,WAAW,UAA0B,CAAA;AAAA,EAC9C;AAEA,EAAA,OAAO,UAAA;AACT;AAQO,SAAS,mBAAmB,KAAA,EAAiC;AAClE,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,gBAAgB,KAAK,CAAA;AAC5D;AAQO,SAAS,qBAAqB,KAAA,EAAuC;AAC1E,EAAA,OAAO,gBAAgB,KAAK,CAAA;AAC9B;AAgBO,SAAS,iBAAiB,UAAA,EAA2C;AAC1E,EAAA,MAAM,MAAA,GAAS,qBAAqB,UAAU,CAAA;AAE9C,EAAA,IAAI,WAAW,UAAA,EAAY;AACzB,IAAA,OAAO,CAAA,IAAA,EAAO,UAAA,CAAW,UAA0B,CAAA,CAAE,UAAU,CAAA,CAAA;AAAA,EACjE;AAEA,EAAA,OAAO,cAAc,UAAU,CAAA,CAAA;AACjC","file":"index.js","sourcesContent":["/**\n * @classytic/payroll - Logger\n *\n * Pluggable logger abstraction\n * Defaults to console, can be replaced with pino, winston, etc.\n */\n\nimport type { Logger } from '../types.js';\n\n// ============================================================================\n// Default Logger Implementation\n// ============================================================================\n\nconst createConsoleLogger = (): Logger => ({\n info: (message: string, meta?: Record<string, unknown>) => {\n if (meta) {\n console.log(`[Payroll] INFO: ${message}`, meta);\n } else {\n console.log(`[Payroll] INFO: ${message}`);\n }\n },\n error: (message: string, meta?: Record<string, unknown>) => {\n if (meta) {\n console.error(`[Payroll] ERROR: ${message}`, meta);\n } else {\n console.error(`[Payroll] ERROR: ${message}`);\n }\n },\n warn: (message: string, meta?: Record<string, unknown>) => {\n if (meta) {\n console.warn(`[Payroll] WARN: ${message}`, meta);\n } else {\n console.warn(`[Payroll] WARN: ${message}`);\n }\n },\n debug: (message: string, meta?: Record<string, unknown>) => {\n if (process.env.NODE_ENV !== 'production') {\n if (meta) {\n console.log(`[Payroll] DEBUG: ${message}`, meta);\n } else {\n console.log(`[Payroll] DEBUG: ${message}`);\n }\n }\n },\n});\n\n// ============================================================================\n// Logger State\n// ============================================================================\n\nlet currentLogger: Logger = createConsoleLogger();\nlet loggingEnabled = true;\n\n// ============================================================================\n// Logger Functions\n// ============================================================================\n\n/**\n * Get the current logger instance\n */\nexport function getLogger(): Logger {\n return currentLogger;\n}\n\n/**\n * Set a custom logger instance\n */\nexport function setLogger(logger: Logger): void {\n currentLogger = logger;\n}\n\n/**\n * Reset to default console logger\n */\nexport function resetLogger(): void {\n currentLogger = createConsoleLogger();\n}\n\n/**\n * Create a child logger with prefix\n */\nexport function createChildLogger(prefix: string): Logger {\n const parent = currentLogger;\n return {\n info: (message: string, meta?: Record<string, unknown>) =>\n parent.info(`[${prefix}] ${message}`, meta),\n error: (message: string, meta?: Record<string, unknown>) =>\n parent.error(`[${prefix}] ${message}`, meta),\n warn: (message: string, meta?: Record<string, unknown>) =>\n parent.warn(`[${prefix}] ${message}`, meta),\n debug: (message: string, meta?: Record<string, unknown>) =>\n parent.debug(`[${prefix}] ${message}`, meta),\n };\n}\n\n/**\n * Create a silent logger (for testing)\n */\nexport function createSilentLogger(): Logger {\n return {\n info: () => {},\n error: () => {},\n warn: () => {},\n debug: () => {},\n };\n}\n\n/**\n * Enable logging globally\n */\nexport function enableLogging(): void {\n loggingEnabled = true;\n}\n\n/**\n * Disable logging globally (useful for production)\n */\nexport function disableLogging(): void {\n loggingEnabled = false;\n}\n\n/**\n * Check if logging is enabled\n */\nexport function isLoggingEnabled(): boolean {\n return loggingEnabled;\n}\n\n// ============================================================================\n// Logger Proxy Object\n// ============================================================================\n\n/**\n * Logger proxy that always delegates to currentLogger\n * Respects global logging enabled/disabled state\n */\nexport const logger: Logger = {\n info: (message: string, meta?: Record<string, unknown>) => {\n if (loggingEnabled) currentLogger.info(message, meta);\n },\n error: (message: string, meta?: Record<string, unknown>) => {\n if (loggingEnabled) currentLogger.error(message, meta);\n },\n warn: (message: string, meta?: Record<string, unknown>) => {\n if (loggingEnabled) currentLogger.warn(message, meta);\n },\n debug: (message: string, meta?: Record<string, unknown>) => {\n if (loggingEnabled) currentLogger.debug(message, meta);\n },\n};\n\nexport default logger;\n\n","/**\n * @classytic/payroll - Date Utilities\n *\n * Pure, composable, testable date operations\n * No side effects, no mutations\n */\n\nimport type { PayPeriodInfo, PaymentFrequency } from '../types.js';\n\n// ============================================================================\n// Date Arithmetic\n// ============================================================================\n\n/**\n * Add days to a date\n */\nexport function addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\n/**\n * Add months to a date\n */\nexport function addMonths(date: Date, months: number): Date {\n const result = new Date(date);\n result.setMonth(result.getMonth() + months);\n return result;\n}\n\n/**\n * Add years to a date\n */\nexport function addYears(date: Date, years: number): Date {\n const result = new Date(date);\n result.setFullYear(result.getFullYear() + years);\n return result;\n}\n\n/**\n * Subtract days from a date\n */\nexport function subDays(date: Date, days: number): Date {\n return addDays(date, -days);\n}\n\n/**\n * Subtract months from a date\n */\nexport function subMonths(date: Date, months: number): Date {\n return addMonths(date, -months);\n}\n\n// ============================================================================\n// Date Boundaries\n// ============================================================================\n\n/**\n * Get the start of a month\n */\nexport function startOfMonth(date: Date): Date {\n const result = new Date(date);\n result.setDate(1);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\n/**\n * Get the end of a month\n */\nexport function endOfMonth(date: Date): Date {\n const result = new Date(date);\n result.setMonth(result.getMonth() + 1, 0);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\n/**\n * Get the start of a year\n */\nexport function startOfYear(date: Date): Date {\n const result = new Date(date);\n result.setMonth(0, 1);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\n/**\n * Get the end of a year\n */\nexport function endOfYear(date: Date): Date {\n const result = new Date(date);\n result.setMonth(11, 31);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\n/**\n * Get the start of a day\n */\nexport function startOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\n/**\n * Get the end of a day\n */\nexport function endOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\n// ============================================================================\n// Date Differences\n// ============================================================================\n\n/**\n * Calculate difference in days between two dates\n */\nexport function diffInDays(start: Date, end: Date): number {\n return Math.ceil(\n (new Date(end).getTime() - new Date(start).getTime()) / (1000 * 60 * 60 * 24)\n );\n}\n\n/**\n * Calculate difference in months between two dates\n */\nexport function diffInMonths(start: Date, end: Date): number {\n const startDate = new Date(start);\n const endDate = new Date(end);\n return (\n (endDate.getFullYear() - startDate.getFullYear()) * 12 +\n (endDate.getMonth() - startDate.getMonth())\n );\n}\n\n/**\n * Calculate difference in years between two dates\n */\nexport function diffInYears(start: Date, end: Date): number {\n return Math.floor(diffInMonths(start, end) / 12);\n}\n\n// Aliases for backwards compatibility\nexport const daysBetween = diffInDays;\nexport const monthsBetween = diffInMonths;\n\n// ============================================================================\n// Day Type Checks\n// ============================================================================\n\n/**\n * Check if date is a weekday (Mon-Fri)\n */\nexport function isWeekday(date: Date): boolean {\n const day = new Date(date).getDay();\n return day >= 1 && day <= 5;\n}\n\n/**\n * Check if date is a weekend (Sat-Sun)\n */\nexport function isWeekend(date: Date): boolean {\n const day = new Date(date).getDay();\n return day === 0 || day === 6;\n}\n\n/**\n * Get day of week (0=Sunday, 6=Saturday)\n */\nexport function getDayOfWeek(date: Date): number {\n return new Date(date).getDay();\n}\n\n/**\n * Get day name\n */\nexport function getDayName(date: Date): string {\n const days = [\n 'Sunday',\n 'Monday',\n 'Tuesday',\n 'Wednesday',\n 'Thursday',\n 'Friday',\n 'Saturday',\n ];\n return days[getDayOfWeek(date)];\n}\n\n// ============================================================================\n// Pay Period Functions\n// ============================================================================\n\n/**\n * Get pay period for a given month and year\n */\nexport function getPayPeriod(month: number, year: number): PayPeriodInfo {\n const startDate = new Date(year, month - 1, 1);\n return {\n month,\n year,\n startDate: startOfMonth(startDate),\n endDate: endOfMonth(startDate),\n };\n}\n\n/**\n * Get current pay period\n */\nexport function getCurrentPeriod(date = new Date()): { year: number; month: number } {\n const d = new Date(date);\n return {\n year: d.getFullYear(),\n month: d.getMonth() + 1,\n };\n}\n\n/**\n * Get working days in a month\n */\nexport function getWorkingDaysInMonth(year: number, month: number): number {\n const start = new Date(year, month - 1, 1);\n const end = endOfMonth(start);\n let count = 0;\n \n const current = new Date(start);\n while (current <= end) {\n if (isWeekday(current)) {\n count++;\n }\n current.setDate(current.getDate() + 1);\n }\n \n return count;\n}\n\n/**\n * Get total days in a month\n */\nexport function getDaysInMonth(year: number, month: number): number {\n return new Date(year, month, 0).getDate();\n}\n\n// ============================================================================\n// Employment Date Functions\n// ============================================================================\n\n/**\n * Calculate probation end date\n */\nexport function calculateProbationEnd(\n hireDate: Date,\n probationMonths: number\n): Date | null {\n if (!probationMonths || probationMonths <= 0) return null;\n return addMonths(hireDate, probationMonths);\n}\n\n/**\n * Check if employee is on probation\n */\nexport function isOnProbation(\n probationEndDate: Date | null | undefined,\n now = new Date()\n): boolean {\n if (!probationEndDate) return false;\n return now < new Date(probationEndDate);\n}\n\n/**\n * Calculate years of service\n */\nexport function calculateYearsOfService(\n hireDate: Date,\n terminationDate?: Date | null\n): number {\n const end = terminationDate || new Date();\n const days = diffInDays(hireDate, end);\n return Math.max(0, Math.floor((days / 365.25) * 10) / 10);\n}\n\n// ============================================================================\n// Range Functions\n// ============================================================================\n\n/**\n * Check if a date is within a range\n */\nexport function isDateInRange(date: Date, start: Date, end: Date): boolean {\n const checkDate = new Date(date);\n return checkDate >= new Date(start) && checkDate <= new Date(end);\n}\n\n/**\n * Get date range for a pay period\n */\nexport function getPayPeriodDateRange(\n month: number,\n year: number\n): { start: Date; end: Date } {\n const period = getPayPeriod(month, year);\n return { start: period.startDate, end: period.endDate };\n}\n\n// ============================================================================\n// Formatting Functions\n// ============================================================================\n\n/**\n * Format date for database storage\n */\nexport function formatDateForDB(date: Date): string {\n if (!date) return '';\n return new Date(date).toISOString();\n}\n\n/**\n * Parse date from database\n */\nexport function parseDBDate(dateString: string): Date | null {\n if (!dateString) return null;\n return new Date(dateString);\n}\n\n/**\n * Format period as string (e.g., \"01/2025\")\n */\nexport function formatPeriod({ month, year }: { month: number; year: number }): string {\n return `${String(month).padStart(2, '0')}/${year}`;\n}\n\n/**\n * Parse period string back to object\n */\nexport function parsePeriod(periodString: string): { month: number; year: number } {\n const [month, year] = periodString.split('/').map(Number);\n return { month, year };\n}\n\n/**\n * Format month name\n */\nexport function getMonthName(month: number): string {\n const months = [\n 'January', 'February', 'March', 'April', 'May', 'June',\n 'July', 'August', 'September', 'October', 'November', 'December',\n ];\n return months[month - 1] || '';\n}\n\n/**\n * Format short month name\n */\nexport function getShortMonthName(month: number): string {\n const months = [\n 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',\n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',\n ];\n return months[month - 1] || '';\n}\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n addDays,\n addMonths,\n addYears,\n subDays,\n subMonths,\n startOfMonth,\n endOfMonth,\n startOfYear,\n endOfYear,\n startOfDay,\n endOfDay,\n diffInDays,\n diffInMonths,\n diffInYears,\n daysBetween,\n monthsBetween,\n isWeekday,\n isWeekend,\n getDayOfWeek,\n getDayName,\n getPayPeriod,\n getCurrentPeriod,\n getWorkingDaysInMonth,\n getDaysInMonth,\n calculateProbationEnd,\n isOnProbation,\n calculateYearsOfService,\n isDateInRange,\n getPayPeriodDateRange,\n formatDateForDB,\n parseDBDate,\n formatPeriod,\n parsePeriod,\n getMonthName,\n getShortMonthName,\n};\n\n","/**\n * @classytic/payroll - Calculation Utilities\n *\n * Pure, functional, composable financial calculations\n * No side effects, highly testable\n */\n\nimport type {\n Allowance,\n Deduction,\n Compensation,\n TaxCalculationResult,\n CompensationBreakdownResult,\n ProRatingResult,\n PayPeriodInfo,\n} from '../types.js';\nimport { diffInDays } from './date.js';\n\n// ============================================================================\n// Basic Math Operations\n// ============================================================================\n\n/**\n * Sum array of numbers\n */\nexport function sum(numbers: number[]): number {\n return numbers.reduce((total, n) => total + n, 0);\n}\n\n/**\n * Sum by property\n */\nexport function sumBy<T>(items: T[], getter: (item: T) => number): number {\n return items.reduce((total, item) => total + getter(item), 0);\n}\n\n/**\n * Sum allowances\n */\nexport function sumAllowances(allowances: Array<{ amount: number }>): number {\n return sumBy(allowances, (a) => a.amount);\n}\n\n/**\n * Sum deductions\n */\nexport function sumDeductions(deductions: Array<{ amount: number }>): number {\n return sumBy(deductions, (d) => d.amount);\n}\n\n/**\n * Apply percentage to amount\n */\nexport function applyPercentage(amount: number, percentage: number): number {\n return Math.round(amount * (percentage / 100));\n}\n\n/**\n * Calculate percentage of total\n */\nexport function calculatePercentage(part: number, total: number): number {\n return total > 0 ? Math.round((part / total) * 100) : 0;\n}\n\n/**\n * Round to decimal places\n */\nexport function roundTo(value: number, decimals = 2): number {\n const factor = Math.pow(10, decimals);\n return Math.round(value * factor) / factor;\n}\n\n// ============================================================================\n// Salary Calculations\n// ============================================================================\n\n/**\n * Calculate gross salary from base and allowances\n */\nexport function calculateGross(\n baseAmount: number,\n allowances: Array<{ amount: number }>\n): number {\n return baseAmount + sumAllowances(allowances);\n}\n\n/**\n * Calculate net salary from gross and deductions\n */\nexport function calculateNet(\n gross: number,\n deductions: Array<{ amount: number }>\n): number {\n return Math.max(0, gross - sumDeductions(deductions));\n}\n\n/**\n * Calculate total compensation\n */\nexport function calculateTotalCompensation(\n baseAmount: number,\n allowances: Array<{ amount: number }>,\n deductions: Array<{ amount: number }>\n): { gross: number; net: number; deductions: number } {\n const gross = calculateGross(baseAmount, allowances);\n const totalDeductions = sumDeductions(deductions);\n const net = calculateNet(gross, deductions);\n return { gross, net, deductions: totalDeductions };\n}\n\n// ============================================================================\n// Allowance & Deduction Calculation\n// ============================================================================\n\n/**\n * Calculate allowance amount (handles percentage-based)\n */\nexport function calculateAllowanceAmount(\n allowance: Pick<Allowance, 'amount' | 'isPercentage' | 'value'>,\n baseAmount: number\n): number {\n if (allowance.isPercentage && allowance.value !== undefined) {\n return applyPercentage(baseAmount, allowance.value);\n }\n return allowance.amount;\n}\n\n/**\n * Calculate deduction amount (handles percentage-based)\n */\nexport function calculateDeductionAmount(\n deduction: Pick<Deduction, 'amount' | 'isPercentage' | 'value'>,\n baseAmount: number\n): number {\n if (deduction.isPercentage && deduction.value !== undefined) {\n return applyPercentage(baseAmount, deduction.value);\n }\n return deduction.amount;\n}\n\n/**\n * Calculate all allowances with their actual amounts\n */\nexport function calculateAllowances(\n allowances: Allowance[],\n baseAmount: number\n): Array<Allowance & { calculatedAmount: number }> {\n return allowances.map((allowance) => ({\n ...allowance,\n calculatedAmount: calculateAllowanceAmount(allowance, baseAmount),\n }));\n}\n\n/**\n * Calculate all deductions with their actual amounts\n */\nexport function calculateDeductions(\n deductions: Deduction[],\n baseAmount: number\n): Array<Deduction & { calculatedAmount: number }> {\n return deductions.map((deduction) => ({\n ...deduction,\n calculatedAmount: calculateDeductionAmount(deduction, baseAmount),\n }));\n}\n\n// ============================================================================\n// Compensation Breakdown\n// ============================================================================\n\n/**\n * Calculate full compensation breakdown\n */\nexport function calculateCompensationBreakdown(\n compensation: Pick<Compensation, 'baseAmount' | 'allowances' | 'deductions'>\n): CompensationBreakdownResult {\n const { baseAmount, allowances = [], deductions = [] } = compensation;\n\n const calculatedAllowances = calculateAllowances(allowances, baseAmount);\n const calculatedDeductions = calculateDeductions(deductions, baseAmount);\n\n const grossAmount =\n baseAmount + sumBy(calculatedAllowances, (a) => a.calculatedAmount);\n const netAmount =\n grossAmount - sumBy(calculatedDeductions, (d) => d.calculatedAmount);\n\n return {\n baseAmount,\n allowances: calculatedAllowances,\n deductions: calculatedDeductions,\n grossAmount,\n netAmount: Math.max(0, netAmount),\n };\n}\n\n// ============================================================================\n// Pro-Rating Calculations\n// ============================================================================\n\n/**\n * Calculate pro-rating for mid-month hires\n */\nexport function calculateProRating(\n hireDate: Date,\n periodStart: Date,\n periodEnd: Date\n): ProRatingResult {\n const totalDays = diffInDays(periodStart, periodEnd) + 1;\n\n // Hired before period start - no pro-rating\n if (hireDate <= periodStart) {\n return {\n isProRated: false,\n totalDays,\n actualDays: totalDays,\n ratio: 1,\n };\n }\n\n // Hired during the period - pro-rate\n if (hireDate > periodStart && hireDate <= periodEnd) {\n const actualDays = diffInDays(hireDate, periodEnd) + 1;\n const ratio = actualDays / totalDays;\n\n return {\n isProRated: true,\n totalDays,\n actualDays,\n ratio,\n };\n }\n\n // Hired after period - no work days\n return {\n isProRated: false,\n totalDays,\n actualDays: 0,\n ratio: 0,\n };\n}\n\n/**\n * Apply pro-rating to an amount\n */\nexport function applyProRating(\n amount: number,\n proRating: ProRatingResult\n): number {\n return Math.round(amount * proRating.ratio);\n}\n\n/**\n * Calculate pro-rated salary\n */\nexport function calculateProRatedSalary(\n baseAmount: number,\n hireDate: Date,\n period: PayPeriodInfo\n): { amount: number; proRating: ProRatingResult } {\n const proRating = calculateProRating(hireDate, period.startDate, period.endDate);\n const amount = applyProRating(baseAmount, proRating);\n return { amount, proRating };\n}\n\n// ============================================================================\n// Tax Calculations\n// ============================================================================\n\n/**\n * Apply tax brackets to calculate tax\n */\nexport function applyTaxBrackets(\n amount: number,\n brackets: Array<{ min: number; max: number; rate: number }>\n): number {\n let tax = 0;\n\n for (const bracket of brackets) {\n if (amount > bracket.min) {\n const taxableAmount = Math.min(amount, bracket.max) - bracket.min;\n tax += taxableAmount * bracket.rate;\n }\n }\n\n return Math.round(tax);\n}\n\n/**\n * Calculate tax with result\n */\nexport function calculateTax(\n amount: number,\n brackets: Array<{ min: number; max: number; rate: number }>\n): TaxCalculationResult {\n const tax = applyTaxBrackets(amount, brackets);\n return {\n gross: amount,\n tax,\n net: amount - tax,\n };\n}\n\n// ============================================================================\n// Functional Composition\n// ============================================================================\n\n/**\n * Pipe functions left-to-right\n * pipe(f, g, h)(x) === h(g(f(x)))\n */\nexport function pipe<T>(...fns: Array<(value: T) => T>): (value: T) => T {\n return (value: T) => fns.reduce((acc, fn) => fn(acc), value);\n}\n\n/**\n * Compose functions right-to-left\n * compose(f, g, h)(x) === f(g(h(x)))\n */\nexport function compose<T>(...fns: Array<(value: T) => T>): (value: T) => T {\n return (value: T) => fns.reduceRight((acc, fn) => fn(acc), value);\n}\n\n/**\n * Create an allowance calculator factory\n */\nexport function createAllowanceCalculator(\n allowances: Allowance[]\n): (baseSalary: number) => Array<Allowance & { calculatedAmount: number }> {\n return (baseSalary: number) => calculateAllowances(allowances, baseSalary);\n}\n\n/**\n * Create a deduction calculator factory\n */\nexport function createDeductionCalculator(\n deductions: Deduction[]\n): (baseSalary: number) => Array<Deduction & { calculatedAmount: number }> {\n return (baseSalary: number) => calculateDeductions(deductions, baseSalary);\n}\n\n// ============================================================================\n// Overtime Calculations\n// ============================================================================\n\n/**\n * Calculate overtime pay\n */\nexport function calculateOvertime(\n hourlyRate: number,\n overtimeHours: number,\n multiplier = 1.5\n): number {\n return Math.round(hourlyRate * overtimeHours * multiplier);\n}\n\n/**\n * Calculate hourly rate from monthly salary\n */\nexport function calculateHourlyRate(\n monthlySalary: number,\n hoursPerMonth = 176 // 44 hours/week * 4 weeks\n): number {\n return Math.round(monthlySalary / hoursPerMonth);\n}\n\n/**\n * Calculate daily rate from monthly salary\n */\nexport function calculateDailyRate(\n monthlySalary: number,\n daysPerMonth = 22\n): number {\n return Math.round(monthlySalary / daysPerMonth);\n}\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n sum,\n sumBy,\n sumAllowances,\n sumDeductions,\n applyPercentage,\n calculatePercentage,\n roundTo,\n calculateGross,\n calculateNet,\n calculateTotalCompensation,\n calculateAllowanceAmount,\n calculateDeductionAmount,\n calculateAllowances,\n calculateDeductions,\n calculateCompensationBreakdown,\n calculateProRating,\n applyProRating,\n calculateProRatedSalary,\n applyTaxBrackets,\n calculateTax,\n pipe,\n compose,\n createAllowanceCalculator,\n createDeductionCalculator,\n calculateOvertime,\n calculateHourlyRate,\n calculateDailyRate,\n};\n\n","/**\n * @classytic/payroll - Enums\n *\n * Type-safe enum definitions with const assertions\n * Single source of truth for all enum values\n */\n\nimport type {\n EmploymentType,\n EmployeeStatus,\n Department,\n PaymentFrequency,\n PaymentMethod,\n AllowanceType,\n DeductionType,\n PayrollStatus,\n TerminationReason,\n SalaryBand,\n} from './types.js';\n\n// ============================================================================\n// Employment Type\n// ============================================================================\n\nexport const EMPLOYMENT_TYPE = {\n FULL_TIME: 'full_time',\n PART_TIME: 'part_time',\n CONTRACT: 'contract',\n INTERN: 'intern',\n CONSULTANT: 'consultant',\n} as const satisfies Record<string, EmploymentType>;\n\nexport const EMPLOYMENT_TYPE_VALUES = Object.values(EMPLOYMENT_TYPE);\n\nexport function isValidEmploymentType(value: string): value is EmploymentType {\n return EMPLOYMENT_TYPE_VALUES.includes(value as EmploymentType);\n}\n\n// ============================================================================\n// Employee Status\n// ============================================================================\n\nexport const EMPLOYEE_STATUS = {\n ACTIVE: 'active',\n ON_LEAVE: 'on_leave',\n SUSPENDED: 'suspended',\n TERMINATED: 'terminated',\n} as const satisfies Record<string, EmployeeStatus>;\n\nexport const EMPLOYEE_STATUS_VALUES = Object.values(EMPLOYEE_STATUS);\n\nexport function isValidEmployeeStatus(value: string): value is EmployeeStatus {\n return EMPLOYEE_STATUS_VALUES.includes(value as EmployeeStatus);\n}\n\nexport function isActiveStatus(status: EmployeeStatus): boolean {\n return status === EMPLOYEE_STATUS.ACTIVE;\n}\n\nexport function isEmployedStatus(status: EmployeeStatus): boolean {\n return status !== EMPLOYEE_STATUS.TERMINATED;\n}\n\nexport function canReceiveSalaryStatus(status: EmployeeStatus): boolean {\n return status === EMPLOYEE_STATUS.ACTIVE || status === EMPLOYEE_STATUS.ON_LEAVE;\n}\n\n// ============================================================================\n// Department\n// ============================================================================\n\nexport const DEPARTMENT = {\n MANAGEMENT: 'management',\n TRAINING: 'training',\n SALES: 'sales',\n OPERATIONS: 'operations',\n SUPPORT: 'support',\n HR: 'hr',\n MAINTENANCE: 'maintenance',\n MARKETING: 'marketing',\n FINANCE: 'finance',\n IT: 'it',\n} as const satisfies Record<string, Department>;\n\nexport const DEPARTMENT_VALUES = Object.values(DEPARTMENT);\n\nexport function isValidDepartment(value: string): value is Department {\n return DEPARTMENT_VALUES.includes(value as Department);\n}\n\n// ============================================================================\n// Payment Frequency\n// ============================================================================\n\nexport const PAYMENT_FREQUENCY = {\n MONTHLY: 'monthly',\n BI_WEEKLY: 'bi_weekly',\n WEEKLY: 'weekly',\n HOURLY: 'hourly',\n DAILY: 'daily',\n} as const satisfies Record<string, PaymentFrequency>;\n\nexport const PAYMENT_FREQUENCY_VALUES = Object.values(PAYMENT_FREQUENCY);\n\nexport function isValidPaymentFrequency(value: string): value is PaymentFrequency {\n return PAYMENT_FREQUENCY_VALUES.includes(value as PaymentFrequency);\n}\n\n// ============================================================================\n// Payment Method\n// ============================================================================\n\nexport const PAYMENT_METHOD = {\n BANK: 'bank',\n CASH: 'cash',\n MOBILE: 'mobile',\n BKASH: 'bkash',\n NAGAD: 'nagad',\n ROCKET: 'rocket',\n CHECK: 'check',\n} as const satisfies Record<string, PaymentMethod>;\n\nexport const PAYMENT_METHOD_VALUES = Object.values(PAYMENT_METHOD);\n\nexport function isValidPaymentMethod(value: string): value is PaymentMethod {\n return PAYMENT_METHOD_VALUES.includes(value as PaymentMethod);\n}\n\n// ============================================================================\n// Allowance Type\n// ============================================================================\n\nexport const ALLOWANCE_TYPE = {\n HOUSING: 'housing',\n TRANSPORT: 'transport',\n MEAL: 'meal',\n MOBILE: 'mobile',\n MEDICAL: 'medical',\n EDUCATION: 'education',\n BONUS: 'bonus',\n OTHER: 'other',\n} as const satisfies Record<string, AllowanceType>;\n\nexport const ALLOWANCE_TYPE_VALUES = Object.values(ALLOWANCE_TYPE);\n\nexport function isValidAllowanceType(value: string): value is AllowanceType {\n return ALLOWANCE_TYPE_VALUES.includes(value as AllowanceType);\n}\n\n// ============================================================================\n// Deduction Type\n// ============================================================================\n\nexport const DEDUCTION_TYPE = {\n TAX: 'tax',\n LOAN: 'loan',\n ADVANCE: 'advance',\n PROVIDENT_FUND: 'provident_fund',\n INSURANCE: 'insurance',\n ABSENCE: 'absence',\n OTHER: 'other',\n} as const satisfies Record<string, DeductionType>;\n\nexport const DEDUCTION_TYPE_VALUES = Object.values(DEDUCTION_TYPE);\n\nexport function isValidDeductionType(value: string): value is DeductionType {\n return DEDUCTION_TYPE_VALUES.includes(value as DeductionType);\n}\n\n// ============================================================================\n// Payroll Status\n// ============================================================================\n\nexport const PAYROLL_STATUS = {\n PENDING: 'pending',\n PROCESSING: 'processing',\n PAID: 'paid',\n FAILED: 'failed',\n CANCELLED: 'cancelled',\n} as const satisfies Record<string, PayrollStatus>;\n\nexport const PAYROLL_STATUS_VALUES = Object.values(PAYROLL_STATUS);\n\nexport function isValidPayrollStatus(value: string): value is PayrollStatus {\n return PAYROLL_STATUS_VALUES.includes(value as PayrollStatus);\n}\n\nexport function isCompletedPayrollStatus(status: PayrollStatus): boolean {\n return status === PAYROLL_STATUS.PAID;\n}\n\nexport function isPendingPayrollStatus(status: PayrollStatus): boolean {\n return status === PAYROLL_STATUS.PENDING || status === PAYROLL_STATUS.PROCESSING;\n}\n\n// ============================================================================\n// Termination Reason\n// ============================================================================\n\nexport const TERMINATION_REASON = {\n RESIGNATION: 'resignation',\n RETIREMENT: 'retirement',\n TERMINATION: 'termination',\n CONTRACT_END: 'contract_end',\n MUTUAL_AGREEMENT: 'mutual_agreement',\n OTHER: 'other',\n} as const satisfies Record<string, TerminationReason>;\n\nexport const TERMINATION_REASON_VALUES = Object.values(TERMINATION_REASON);\n\nexport function isValidTerminationReason(value: string): value is TerminationReason {\n return TERMINATION_REASON_VALUES.includes(value as TerminationReason);\n}\n\n// ============================================================================\n// Salary Band\n// ============================================================================\n\nexport const SALARY_BAND = {\n INTERN: 'intern',\n JUNIOR: 'junior',\n MID: 'mid',\n SENIOR: 'senior',\n LEAD: 'lead',\n EXECUTIVE: 'executive',\n CUSTOM: 'custom',\n} as const satisfies Record<string, SalaryBand>;\n\nexport const SALARY_BAND_VALUES = Object.values(SALARY_BAND);\n\nexport function isValidSalaryBand(value: string): value is SalaryBand {\n return SALARY_BAND_VALUES.includes(value as SalaryBand);\n}\n\n// ============================================================================\n// Leave Type\n// ============================================================================\n\nimport type { LeaveType, LeaveRequestStatus } from './types.js';\n\nexport const LEAVE_TYPE = {\n ANNUAL: 'annual',\n SICK: 'sick',\n UNPAID: 'unpaid',\n MATERNITY: 'maternity',\n PATERNITY: 'paternity',\n BEREAVEMENT: 'bereavement',\n COMPENSATORY: 'compensatory',\n OTHER: 'other',\n} as const satisfies Record<string, LeaveType>;\n\nexport const LEAVE_TYPE_VALUES = Object.values(LEAVE_TYPE);\n\nexport function isValidLeaveType(value: string): value is LeaveType {\n return LEAVE_TYPE_VALUES.includes(value as LeaveType);\n}\n\nexport function isPaidLeaveType(type: LeaveType): boolean {\n return type !== LEAVE_TYPE.UNPAID;\n}\n\n// ============================================================================\n// Leave Request Status\n// ============================================================================\n\nexport const LEAVE_REQUEST_STATUS = {\n PENDING: 'pending',\n APPROVED: 'approved',\n REJECTED: 'rejected',\n CANCELLED: 'cancelled',\n} as const satisfies Record<string, LeaveRequestStatus>;\n\nexport const LEAVE_REQUEST_STATUS_VALUES = Object.values(LEAVE_REQUEST_STATUS);\n\nexport function isValidLeaveRequestStatus(value: string): value is LeaveRequestStatus {\n return LEAVE_REQUEST_STATUS_VALUES.includes(value as LeaveRequestStatus);\n}\n\nexport function isPendingLeaveStatus(status: LeaveRequestStatus): boolean {\n return status === LEAVE_REQUEST_STATUS.PENDING;\n}\n\nexport function isApprovedLeaveStatus(status: LeaveRequestStatus): boolean {\n return status === LEAVE_REQUEST_STATUS.APPROVED;\n}\n\n// ============================================================================\n// Tax Type\n// ============================================================================\n\nexport const TAX_TYPE = {\n INCOME_TAX: 'income_tax',\n SOCIAL_SECURITY: 'social_security',\n HEALTH_INSURANCE: 'health_insurance',\n PENSION: 'pension',\n EMPLOYMENT_INSURANCE: 'employment_insurance',\n LOCAL_TAX: 'local_tax',\n OTHER: 'other',\n} as const satisfies Record<string, import('./types.js').TaxType>;\n\nexport const TAX_TYPE_VALUES = Object.values(TAX_TYPE);\n\nexport function isValidTaxType(value: string): value is import('./types.js').TaxType {\n return TAX_TYPE_VALUES.includes(value as import('./types.js').TaxType);\n}\n\n// ============================================================================\n// Tax Status\n// ============================================================================\n\nexport const TAX_STATUS = {\n PENDING: 'pending',\n SUBMITTED: 'submitted',\n PAID: 'paid',\n} as const satisfies Record<string, import('./types.js').TaxStatus>;\n\nexport const TAX_STATUS_VALUES = Object.values(TAX_STATUS);\n\nexport function isValidTaxStatus(value: string): value is import('./types.js').TaxStatus {\n return TAX_STATUS_VALUES.includes(value as import('./types.js').TaxStatus);\n}\n\nexport function isPendingTaxStatus(status: import('./types.js').TaxStatus): boolean {\n return status === TAX_STATUS.PENDING;\n}\n\nexport function isPaidTaxStatus(status: import('./types.js').TaxStatus): boolean {\n return status === TAX_STATUS.PAID;\n}\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n EMPLOYMENT_TYPE,\n EMPLOYMENT_TYPE_VALUES,\n EMPLOYEE_STATUS,\n EMPLOYEE_STATUS_VALUES,\n DEPARTMENT,\n DEPARTMENT_VALUES,\n PAYMENT_FREQUENCY,\n PAYMENT_FREQUENCY_VALUES,\n PAYMENT_METHOD,\n PAYMENT_METHOD_VALUES,\n ALLOWANCE_TYPE,\n ALLOWANCE_TYPE_VALUES,\n DEDUCTION_TYPE,\n DEDUCTION_TYPE_VALUES,\n PAYROLL_STATUS,\n PAYROLL_STATUS_VALUES,\n TERMINATION_REASON,\n TERMINATION_REASON_VALUES,\n SALARY_BAND,\n SALARY_BAND_VALUES,\n LEAVE_TYPE,\n LEAVE_TYPE_VALUES,\n LEAVE_REQUEST_STATUS,\n LEAVE_REQUEST_STATUS_VALUES,\n TAX_TYPE,\n TAX_TYPE_VALUES,\n TAX_STATUS,\n TAX_STATUS_VALUES,\n};\n","/**\n * @classytic/payroll - Validation Utilities\n *\n * Fluent, composable, type-safe validation\n * Clear semantics and helpful error messages\n */\n\nimport type {\n EmployeeStatus,\n EmploymentType,\n Compensation,\n BankDetails,\n EmployeeValidationResult,\n} from '../types.js';\nimport {\n EMPLOYEE_STATUS_VALUES,\n EMPLOYMENT_TYPE_VALUES,\n} from '../enums.js';\nimport { diffInMonths } from './date.js';\n\n// ============================================================================\n// Employee Status Validators\n// ============================================================================\n\n/**\n * Check if employee is active\n */\nexport function isActive(employee: { status?: EmployeeStatus }): boolean {\n return employee?.status === 'active';\n}\n\n/**\n * Check if employee is on leave\n */\nexport function isOnLeave(employee: { status?: EmployeeStatus }): boolean {\n return employee?.status === 'on_leave';\n}\n\n/**\n * Check if employee is suspended\n */\nexport function isSuspended(employee: { status?: EmployeeStatus }): boolean {\n return employee?.status === 'suspended';\n}\n\n/**\n * Check if employee is terminated\n */\nexport function isTerminated(employee: { status?: EmployeeStatus }): boolean {\n return employee?.status === 'terminated';\n}\n\n/**\n * Check if employee is employed (not terminated)\n */\nexport function isEmployed(employee: { status?: EmployeeStatus }): boolean {\n return (\n isActive(employee) || isOnLeave(employee) || isSuspended(employee)\n );\n}\n\n/**\n * Check if employee can receive salary\n */\nexport function canReceiveSalary(employee: {\n status?: EmployeeStatus;\n compensation?: { baseAmount?: number };\n}): boolean {\n return (\n (isActive(employee) || isOnLeave(employee)) &&\n (employee.compensation?.baseAmount ?? 0) > 0\n );\n}\n\n/**\n * Check if employment can be updated\n */\nexport function canUpdateEmployment(employee: { status?: EmployeeStatus }): boolean {\n return !isTerminated(employee);\n}\n\n// ============================================================================\n// Compensation Validators\n// ============================================================================\n\n/**\n * Check if employee has valid compensation\n */\nexport function hasCompensation(employee: {\n compensation?: { baseAmount?: number };\n}): boolean {\n return (employee.compensation?.baseAmount ?? 0) > 0;\n}\n\n/**\n * Check if compensation is valid\n */\nexport function isValidCompensation(compensation?: Compensation): boolean {\n return !!(\n compensation?.baseAmount &&\n compensation.baseAmount > 0 &&\n compensation.frequency &&\n compensation.currency\n );\n}\n\n/**\n * Check if bank details are valid\n */\nexport function isValidBankDetails(bankDetails?: BankDetails): boolean {\n return !!(\n bankDetails?.accountNumber &&\n bankDetails.bankName &&\n bankDetails.accountName\n );\n}\n\n// ============================================================================\n// Probation Validators\n// ============================================================================\n\n/**\n * Check if employee is in probation\n */\nexport function isInProbation(\n employee: { probationEndDate?: Date | null },\n now = new Date()\n): boolean {\n if (!employee?.probationEndDate) return false;\n return new Date(employee.probationEndDate) > now;\n}\n\n/**\n * Check if employee has completed probation\n */\nexport function hasCompletedProbation(\n employee: { probationEndDate?: Date | null },\n now = new Date()\n): boolean {\n if (!employee?.probationEndDate) return true;\n return new Date(employee.probationEndDate) <= now;\n}\n\n// ============================================================================\n// Eligibility Validators\n// ============================================================================\n\n/**\n * Check if employee is eligible for bonus\n */\nexport function isEligibleForBonus(\n employee: { status?: EmployeeStatus; hireDate?: Date },\n requiredMonths = 6\n): boolean {\n if (!isActive(employee) || !employee.hireDate) return false;\n const monthsEmployed = diffInMonths(employee.hireDate, new Date());\n return monthsEmployed >= requiredMonths;\n}\n\n/**\n * Check if employee is eligible for payroll\n */\nexport function isEligibleForPayroll(employee: {\n status?: EmployeeStatus;\n compensation?: { baseAmount?: number };\n bankDetails?: BankDetails;\n}): { eligible: boolean; reasons: string[] } {\n const reasons: string[] = [];\n\n if (!isActive(employee) && !isOnLeave(employee)) {\n reasons.push('Employee is not in active or on-leave status');\n }\n\n if (!hasCompensation(employee)) {\n reasons.push('Employee has no valid compensation');\n }\n\n return {\n eligible: reasons.length === 0,\n reasons,\n };\n}\n\n// ============================================================================\n// Field Validators\n// ============================================================================\n\n/**\n * Check if value is required\n */\nexport function required(fieldName: string): (value: unknown) => string | true {\n return (value: unknown) =>\n value !== undefined && value !== null && value !== ''\n ? true\n : `${fieldName} is required`;\n}\n\n/**\n * Check minimum value\n */\nexport function min(\n minValue: number,\n fieldName: string\n): (value: number) => string | true {\n return (value: number) =>\n value >= minValue ? true : `${fieldName} must be at least ${minValue}`;\n}\n\n/**\n * Check maximum value\n */\nexport function max(\n maxValue: number,\n fieldName: string\n): (value: number) => string | true {\n return (value: number) =>\n value <= maxValue ? true : `${fieldName} must not exceed ${maxValue}`;\n}\n\n/**\n * Check value is in range\n */\nexport function inRange(\n minValue: number,\n maxValue: number,\n fieldName: string\n): (value: number) => string | true {\n return (value: number) =>\n value >= minValue && value <= maxValue\n ? true\n : `${fieldName} must be between ${minValue} and ${maxValue}`;\n}\n\n/**\n * Check value is positive\n */\nexport function isPositive(fieldName: string): (value: number) => string | true {\n return (value: number) =>\n value > 0 ? true : `${fieldName} must be positive`;\n}\n\n/**\n * Check value is one of allowed values\n */\nexport function oneOf<T extends string>(\n allowedValues: readonly T[],\n fieldName: string\n): (value: T) => string | true {\n return (value: T) =>\n allowedValues.includes(value)\n ? true\n : `${fieldName} must be one of: ${allowedValues.join(', ')}`;\n}\n\n// ============================================================================\n// Enum Validators\n// ============================================================================\n\n/**\n * Check if status is valid\n */\nexport function isValidStatus(value: string): value is EmployeeStatus {\n return EMPLOYEE_STATUS_VALUES.includes(value as EmployeeStatus);\n}\n\n/**\n * Check if employment type is valid\n */\nexport function isValidEmploymentType(value: string): value is EmploymentType {\n return EMPLOYMENT_TYPE_VALUES.includes(value as EmploymentType);\n}\n\n// ============================================================================\n// Composite Validators\n// ============================================================================\n\n/**\n * Compose multiple validators\n */\nexport function composeValidators<T>(\n ...validators: Array<(value: T, data?: unknown) => string | true>\n): (value: T, data?: unknown) => string | true {\n return (value: T, data?: unknown) => {\n for (const validator of validators) {\n const result = validator(value, data);\n if (result !== true) return result;\n }\n return true;\n };\n}\n\n/**\n * Create a validator from validation functions\n */\nexport function createValidator<T extends Record<string, unknown>>(\n validationFns: Record<string, (value: unknown, data: T) => string | true>\n): (data: T) => EmployeeValidationResult {\n return (data: T) => {\n const errors: string[] = [];\n\n for (const [field, validator] of Object.entries(validationFns)) {\n const result = validator((data as Record<string, unknown>)[field], data);\n if (result !== true) {\n errors.push(result);\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n };\n}\n\n/**\n * Validate required fields exist\n */\nexport function hasRequiredFields(\n obj: Record<string, unknown>,\n fields: string[]\n): { valid: boolean; missing: string[] } {\n const missing = fields.filter(\n (field) => obj[field] === undefined || obj[field] === null\n );\n return {\n valid: missing.length === 0,\n missing,\n };\n}\n\n// ============================================================================\n// Aliases for backwards compatibility\n// ============================================================================\n\nexport const minValue = min;\nexport const maxValue = max;\nexport const isInRange = inRange;\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n // Status validators\n isActive,\n isOnLeave,\n isSuspended,\n isTerminated,\n isEmployed,\n canReceiveSalary,\n canUpdateEmployment,\n // Compensation validators\n hasCompensation,\n isValidCompensation,\n isValidBankDetails,\n // Probation validators\n isInProbation,\n hasCompletedProbation,\n // Eligibility validators\n isEligibleForBonus,\n isEligibleForPayroll,\n // Field validators\n required,\n min,\n max,\n inRange,\n isPositive,\n oneOf,\n // Enum validators\n isValidStatus,\n isValidEmploymentType,\n // Composite validators\n composeValidators,\n createValidator,\n hasRequiredFields,\n};\n\n","/**\n * @classytic/payroll - Query Builders\n *\n * Fluent API for building MongoDB queries\n * Type-safe, chainable, beautiful\n */\n\nimport mongoose, { Types } from 'mongoose';\nimport type {\n ObjectIdLike,\n EmployeeStatus,\n PayrollStatus,\n Department,\n EmploymentType,\n} from '../types.js';\n\n// ============================================================================\n// ObjectId Helpers\n// ============================================================================\n\n/**\n * Convert string or ObjectId to ObjectId\n */\nexport function toObjectId(id: ObjectIdLike): Types.ObjectId {\n if (id instanceof Types.ObjectId) return id;\n return new Types.ObjectId(id);\n}\n\n/**\n * Safely convert to ObjectId (returns null if invalid)\n */\nexport function safeToObjectId(id: unknown): Types.ObjectId | null {\n if (id instanceof Types.ObjectId) return id;\n if (typeof id === 'string' && Types.ObjectId.isValid(id)) {\n return new Types.ObjectId(id);\n }\n return null;\n}\n\n/**\n * Check if value is valid ObjectId\n */\nexport function isValidObjectId(value: unknown): boolean {\n if (value instanceof Types.ObjectId) return true;\n if (typeof value === 'string') return Types.ObjectId.isValid(value);\n return false;\n}\n\n// ============================================================================\n// Base Query Builder\n// ============================================================================\n\nexport class QueryBuilder<T extends Record<string, unknown> = Record<string, unknown>> {\n protected query: T;\n\n constructor(initialQuery: T = {} as T) {\n this.query = { ...initialQuery };\n }\n\n /**\n * Add where condition\n */\n where<K extends string>(field: K, value: unknown): this {\n (this.query as Record<string, unknown>)[field] = value;\n return this;\n }\n\n /**\n * Add $in condition\n */\n whereIn<K extends string>(field: K, values: unknown[]): this {\n (this.query as Record<string, unknown>)[field] = { $in: values };\n return this;\n }\n\n /**\n * Add $nin condition\n */\n whereNotIn<K extends string>(field: K, values: unknown[]): this {\n (this.query as Record<string, unknown>)[field] = { $nin: values };\n return this;\n }\n\n /**\n * Add $gte condition\n */\n whereGte<K extends string>(field: K, value: unknown): this {\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\n (this.query as Record<string, unknown>)[field] = { ...existing, $gte: value };\n return this;\n }\n\n /**\n * Add $lte condition\n */\n whereLte<K extends string>(field: K, value: unknown): this {\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\n (this.query as Record<string, unknown>)[field] = { ...existing, $lte: value };\n return this;\n }\n\n /**\n * Add $gt condition\n */\n whereGt<K extends string>(field: K, value: unknown): this {\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\n (this.query as Record<string, unknown>)[field] = { ...existing, $gt: value };\n return this;\n }\n\n /**\n * Add $lt condition\n */\n whereLt<K extends string>(field: K, value: unknown): this {\n const existing = (this.query as Record<string, Record<string, unknown>>)[field] || {};\n (this.query as Record<string, unknown>)[field] = { ...existing, $lt: value };\n return this;\n }\n\n /**\n * Add between condition\n */\n whereBetween<K extends string>(field: K, start: unknown, end: unknown): this {\n (this.query as Record<string, unknown>)[field] = { $gte: start, $lte: end };\n return this;\n }\n\n /**\n * Add $exists condition\n */\n whereExists<K extends string>(field: K): this {\n (this.query as Record<string, unknown>)[field] = { $exists: true };\n return this;\n }\n\n /**\n * Add $exists: false condition\n */\n whereNotExists<K extends string>(field: K): this {\n (this.query as Record<string, unknown>)[field] = { $exists: false };\n return this;\n }\n\n /**\n * Add $ne condition\n */\n whereNot<K extends string>(field: K, value: unknown): this {\n (this.query as Record<string, unknown>)[field] = { $ne: value };\n return this;\n }\n\n /**\n * Add regex condition\n */\n whereRegex<K extends string>(field: K, pattern: string, flags = 'i'): this {\n (this.query as Record<string, unknown>)[field] = { $regex: pattern, $options: flags };\n return this;\n }\n\n /**\n * Merge another query\n */\n merge(otherQuery: Record<string, unknown>): this {\n this.query = { ...this.query, ...otherQuery } as T;\n return this;\n }\n\n /**\n * Build and return the query\n */\n build(): T {\n return { ...this.query };\n }\n}\n\n// ============================================================================\n// Employee Query Builder\n// ============================================================================\n\nexport class EmployeeQueryBuilder extends QueryBuilder {\n /**\n * Filter by organization\n */\n forOrganization(organizationId: ObjectIdLike): this {\n return this.where('organizationId', toObjectId(organizationId));\n }\n\n /**\n * Filter by user\n */\n forUser(userId: ObjectIdLike): this {\n return this.where('userId', toObjectId(userId));\n }\n\n /**\n * Filter by employeeId (human-readable ID)\n */\n forEmployeeId(employeeId: string): this {\n return this.where('employeeId', employeeId);\n }\n\n /**\n * Filter by email (for guest employees)\n */\n forEmail(email: string): this {\n return this.where('email', email.toLowerCase().trim());\n }\n\n /**\n * Filter guest employees (no userId)\n */\n guestEmployees(): this {\n return this.where('userId', null);\n }\n\n /**\n * Filter user-linked employees (has userId)\n */\n userLinkedEmployees(): this {\n return this.where('userId', { $ne: null } as unknown as mongoose.Types.ObjectId);\n }\n\n /**\n * Filter by status(es)\n */\n withStatus(...statuses: EmployeeStatus[]): this {\n if (statuses.length === 1) {\n return this.where('status', statuses[0]);\n }\n return this.whereIn('status', statuses);\n }\n\n /**\n * Filter active employees\n */\n active(): this {\n return this.withStatus('active');\n }\n\n /**\n * Filter employed employees (not terminated)\n */\n employed(): this {\n return this.whereIn('status', ['active', 'on_leave', 'suspended']);\n }\n\n /**\n * Filter terminated employees\n */\n terminated(): this {\n return this.withStatus('terminated');\n }\n\n /**\n * Filter by department\n */\n inDepartment(department: Department | string): this {\n return this.where('department', department);\n }\n\n /**\n * Filter by position\n */\n inPosition(position: string): this {\n return this.where('position', position);\n }\n\n /**\n * Filter by employment type\n */\n withEmploymentType(type: EmploymentType | string): this {\n return this.where('employmentType', type);\n }\n\n /**\n * Filter by hire date (after)\n */\n hiredAfter(date: Date): this {\n return this.whereGte('hireDate', date);\n }\n\n /**\n * Filter by hire date (before)\n */\n hiredBefore(date: Date): this {\n return this.whereLte('hireDate', date);\n }\n\n /**\n * Filter by minimum salary\n */\n withMinSalary(amount: number): this {\n return this.whereGte('compensation.netSalary', amount);\n }\n\n /**\n * Filter by maximum salary\n */\n withMaxSalary(amount: number): this {\n return this.whereLte('compensation.netSalary', amount);\n }\n\n /**\n * Filter by salary range\n */\n withSalaryRange(min: number, max: number): this {\n return this.whereBetween('compensation.netSalary', min, max);\n }\n}\n\n// ============================================================================\n// Payroll Query Builder\n// ============================================================================\n\nexport class PayrollQueryBuilder extends QueryBuilder {\n /**\n * Filter by organization\n */\n forOrganization(organizationId: ObjectIdLike): this {\n return this.where('organizationId', toObjectId(organizationId));\n }\n\n /**\n * Filter by employee\n *\n * Note: PayrollRecord.employeeId is always ObjectId _id\n * If passing a string business ID, resolve to _id first\n */\n forEmployee(employeeId: ObjectIdLike | string): this {\n // For payroll queries, employeeId field is always the ObjectId _id\n // If a string business ID is passed, caller should resolve to _id first\n return this.where('employeeId', toObjectId(employeeId as ObjectIdLike));\n }\n\n /**\n * Filter by period\n */\n forPeriod(month?: number, year?: number): this {\n if (month !== undefined) {\n this.where('period.month', month);\n }\n if (year !== undefined) {\n this.where('period.year', year);\n }\n return this;\n }\n\n /**\n * Filter by status(es)\n */\n withStatus(...statuses: PayrollStatus[]): this {\n if (statuses.length === 1) {\n return this.where('status', statuses[0]);\n }\n return this.whereIn('status', statuses);\n }\n\n /**\n * Filter paid records\n */\n paid(): this {\n return this.withStatus('paid');\n }\n\n /**\n * Filter pending records\n */\n pending(): this {\n return this.whereIn('status', ['pending', 'processing']);\n }\n\n /**\n * Filter by date range\n */\n inDateRange(start: Date, end: Date): this {\n return this.whereBetween('period.payDate', start, end);\n }\n\n /**\n * Filter exported records\n */\n exported(): this {\n return this.where('exported', true);\n }\n\n /**\n * Filter not exported records\n */\n notExported(): this {\n return this.where('exported', false);\n }\n}\n\n// ============================================================================\n// Factory Functions\n// ============================================================================\n\n/**\n * Create employee query builder\n */\nexport function employee(): EmployeeQueryBuilder {\n return new EmployeeQueryBuilder();\n}\n\n/**\n * Create payroll query builder\n */\nexport function payroll(): PayrollQueryBuilder {\n return new PayrollQueryBuilder();\n}\n\n/**\n * Create generic query builder\n */\nexport function createQueryBuilder<T extends Record<string, unknown> = Record<string, unknown>>(\n initialQuery?: T\n): QueryBuilder<T> {\n return new QueryBuilder(initialQuery);\n}\n\n// ============================================================================\n// Convenience Query Builders\n// ============================================================================\n\n/**\n * Build employee query from options\n */\nexport function buildEmployeeQuery(options: {\n organizationId: ObjectIdLike;\n userId?: ObjectIdLike;\n statuses?: EmployeeStatus[];\n department?: Department | string;\n employmentType?: EmploymentType | string;\n}): Record<string, unknown> {\n const builder = employee().forOrganization(options.organizationId);\n\n if (options.userId) {\n builder.forUser(options.userId);\n }\n if (options.statuses) {\n builder.withStatus(...options.statuses);\n }\n if (options.department) {\n builder.inDepartment(options.department);\n }\n if (options.employmentType) {\n builder.withEmploymentType(options.employmentType);\n }\n\n return builder.build();\n}\n\n/**\n * Build payroll query from options\n */\nexport function buildPayrollQuery(options: {\n employeeId?: ObjectIdLike;\n organizationId?: ObjectIdLike;\n month?: number;\n year?: number;\n statuses?: PayrollStatus[];\n}): Record<string, unknown> {\n const builder = payroll();\n\n if (options.organizationId) {\n builder.forOrganization(options.organizationId);\n }\n if (options.employeeId) {\n builder.forEmployee(options.employeeId);\n }\n if (options.month || options.year) {\n builder.forPeriod(options.month, options.year);\n }\n if (options.statuses) {\n builder.withStatus(...options.statuses);\n }\n\n return builder.build();\n}\n\n// ============================================================================\n// Aggregation Pipeline Helpers\n// ============================================================================\n\n/**\n * Build aggregation pipeline from stages\n */\nexport function buildAggregationPipeline(\n ...stages: Array<Record<string, unknown> | undefined | null>\n): Record<string, unknown>[] {\n return stages.filter((stage): stage is Record<string, unknown> => !!stage);\n}\n\n/**\n * Match stage\n */\nexport function matchStage(query: Record<string, unknown>): Record<string, unknown> {\n return { $match: query };\n}\n\n/**\n * Group stage\n */\nexport function groupStage(\n groupBy: string | null,\n aggregations: Record<string, unknown>\n): Record<string, unknown> {\n return {\n $group: {\n _id: groupBy,\n ...aggregations,\n },\n };\n}\n\n/**\n * Sort stage\n */\nexport function sortStage(sortBy: Record<string, 1 | -1>): Record<string, unknown> {\n return { $sort: sortBy };\n}\n\n/**\n * Limit stage\n */\nexport function limitStage(limit: number): Record<string, unknown> {\n return { $limit: limit };\n}\n\n/**\n * Skip stage\n */\nexport function skipStage(skip: number): Record<string, unknown> {\n return { $skip: skip };\n}\n\n/**\n * Project stage\n */\nexport function projectStage(fields: Record<string, unknown>): Record<string, unknown> {\n return { $project: fields };\n}\n\n/**\n * Lookup stage\n */\nexport function lookupStage(options: {\n from: string;\n localField: string;\n foreignField: string;\n as: string;\n}): Record<string, unknown> {\n return { $lookup: options };\n}\n\n/**\n * Unwind stage\n */\nexport function unwindStage(\n path: string,\n options: { preserveNullAndEmptyArrays?: boolean } = {}\n): Record<string, unknown> {\n return { $unwind: { path, ...options } };\n}\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n toObjectId,\n safeToObjectId,\n isValidObjectId,\n QueryBuilder,\n EmployeeQueryBuilder,\n PayrollQueryBuilder,\n employee,\n payroll,\n createQueryBuilder,\n buildEmployeeQuery,\n buildPayrollQuery,\n buildAggregationPipeline,\n matchStage,\n groupStage,\n sortStage,\n limitStage,\n skipStage,\n projectStage,\n lookupStage,\n unwindStage,\n};\n\n","/**\n * @classytic/payroll - Leave Utilities\n *\n * Pure, composable leave calculation functions\n */\n\nimport type {\n LeaveBalance,\n LeaveType,\n LeaveInitConfig,\n LeaveSummaryResult,\n WorkingDaysOptions,\n} from '../types.js';\n\n// ============================================================================\n// Default Configurations\n// ============================================================================\n\n/** Default leave allocations by type (days per year) */\nexport const DEFAULT_LEAVE_ALLOCATIONS: Record<LeaveType, number> = {\n annual: 20,\n sick: 10,\n unpaid: 0, // Unlimited\n maternity: 90,\n paternity: 10,\n bereavement: 5,\n compensatory: 0,\n other: 0,\n};\n\n/** Default carry-over limits by type (days) */\nexport const DEFAULT_CARRY_OVER: Record<LeaveType, number> = {\n annual: 5,\n sick: 0,\n unpaid: 0,\n maternity: 0,\n paternity: 0,\n bereavement: 0,\n compensatory: 5,\n other: 0,\n};\n\n// ============================================================================\n// Working Days Calculation\n// ============================================================================\n\n/**\n * Calculate working days between two dates\n * Excludes weekends and optionally holidays\n *\n * @example\n * // March 2024: Get working days for a week\n * const days = calculateLeaveDays(\n * new Date('2024-03-01'),\n * new Date('2024-03-08'),\n * { holidays: [new Date('2024-03-05')] }\n * );\n */\nexport function calculateLeaveDays(\n startDate: Date,\n endDate: Date,\n options: WorkingDaysOptions = {}\n): number {\n const {\n workingDays = [1, 2, 3, 4, 5], // Mon-Fri by default\n holidays = [],\n includeEndDate = true,\n } = options;\n\n const holidaySet = new Set(holidays.map((d) => new Date(d).toDateString()));\n\n let count = 0;\n const current = new Date(startDate);\n current.setHours(0, 0, 0, 0);\n\n const end = new Date(endDate);\n end.setHours(0, 0, 0, 0);\n\n if (!includeEndDate) {\n end.setDate(end.getDate() - 1);\n }\n\n while (current <= end) {\n const isWorkDay = workingDays.includes(current.getDay());\n const isHoliday = holidaySet.has(current.toDateString());\n\n if (isWorkDay && !isHoliday) {\n count++;\n }\n\n current.setDate(current.getDate() + 1);\n }\n\n return count;\n}\n\n// ============================================================================\n// Balance Checks\n// ============================================================================\n\n/**\n * Check if employee has sufficient leave balance\n *\n * @example\n * if (hasLeaveBalance(employee, 'annual', 5)) {\n * // Can request 5 days annual leave\n * }\n */\nexport function hasLeaveBalance(\n employee: { leaveBalances?: LeaveBalance[] },\n type: LeaveType,\n days: number,\n year = new Date().getFullYear()\n): boolean {\n // Unpaid leave is always allowed\n if (type === 'unpaid') return true;\n\n const balance = getLeaveBalance(employee, type, year);\n if (!balance) return false;\n\n const available =\n balance.allocated + balance.carriedOver - balance.used - balance.pending;\n return available >= days;\n}\n\n/**\n * Get leave balance for a specific type\n */\nexport function getLeaveBalance(\n employee: { leaveBalances?: LeaveBalance[] },\n type: LeaveType,\n year = new Date().getFullYear()\n): LeaveBalance | undefined {\n return employee.leaveBalances?.find((b) => b.type === type && b.year === year);\n}\n\n/**\n * Get all leave balances for a year\n */\nexport function getLeaveBalances(\n employee: { leaveBalances?: LeaveBalance[] },\n year = new Date().getFullYear()\n): LeaveBalance[] {\n return (employee.leaveBalances || []).filter((b) => b.year === year);\n}\n\n/**\n * Calculate available days for a leave type\n */\nexport function getAvailableDays(\n employee: { leaveBalances?: LeaveBalance[] },\n type: LeaveType,\n year = new Date().getFullYear()\n): number {\n // Unpaid leave has no limit\n if (type === 'unpaid') return Infinity;\n\n const balance = getLeaveBalance(employee, type, year);\n if (!balance) return 0;\n\n return Math.max(\n 0,\n balance.allocated + balance.carriedOver - balance.used - balance.pending\n );\n}\n\n// ============================================================================\n// Leave Summary\n// ============================================================================\n\n/**\n * Get comprehensive leave summary for an employee\n *\n * @example\n * const summary = getLeaveSummary(employee, 2024);\n * console.log(`Available: ${summary.totalAvailable} days`);\n * console.log(`Annual: ${summary.byType.annual?.available || 0} days`);\n */\nexport function getLeaveSummary(\n employee: { leaveBalances?: LeaveBalance[] },\n year = new Date().getFullYear()\n): LeaveSummaryResult {\n const balances = getLeaveBalances(employee, year);\n\n const byType = {} as LeaveSummaryResult['byType'];\n let totalAllocated = 0;\n let totalUsed = 0;\n let totalPending = 0;\n\n for (const balance of balances) {\n const available = Math.max(\n 0,\n balance.allocated + balance.carriedOver - balance.used - balance.pending\n );\n byType[balance.type] = {\n allocated: balance.allocated + balance.carriedOver,\n used: balance.used,\n pending: balance.pending,\n available,\n };\n totalAllocated += balance.allocated + balance.carriedOver;\n totalUsed += balance.used;\n totalPending += balance.pending;\n }\n\n return {\n year,\n balances,\n totalAllocated,\n totalUsed,\n totalPending,\n totalAvailable: Math.max(0, totalAllocated - totalUsed - totalPending),\n byType,\n };\n}\n\n// ============================================================================\n// Balance Initialization\n// ============================================================================\n\n/**\n * Initialize leave balances for a new employee\n *\n * @example\n * // Full allocation for employee hired Jan 1st\n * const balances = initializeLeaveBalances(new Date('2024-01-01'));\n *\n * // Pro-rated for mid-year hire\n * const balances = initializeLeaveBalances(new Date('2024-07-01'), {\n * proRateNewHires: true,\n * });\n */\nexport function initializeLeaveBalances(\n hireDate: Date,\n config: LeaveInitConfig = {},\n year = new Date().getFullYear()\n): LeaveBalance[] {\n const {\n defaultAllocations = DEFAULT_LEAVE_ALLOCATIONS,\n proRateNewHires = true,\n fiscalYearStartMonth = 1,\n } = config;\n\n const fiscalYearStart = new Date(year, fiscalYearStartMonth - 1, 1);\n const fiscalYearEnd = new Date(year + 1, fiscalYearStartMonth - 1, 0);\n\n // Calculate proration if hired mid-year\n let prorationRatio = 1;\n if (proRateNewHires && hireDate > fiscalYearStart) {\n const totalDays = diffInDays(fiscalYearStart, fiscalYearEnd);\n const remainingDays = diffInDays(hireDate, fiscalYearEnd);\n prorationRatio = Math.max(0, Math.min(1, remainingDays / totalDays));\n }\n\n const balances: LeaveBalance[] = [];\n\n for (const [type, allocation] of Object.entries(defaultAllocations)) {\n if (allocation > 0) {\n balances.push({\n type: type as LeaveType,\n allocated: Math.round(allocation * prorationRatio),\n used: 0,\n pending: 0,\n carriedOver: 0,\n year,\n });\n }\n }\n\n return balances;\n}\n\n/**\n * Calculate prorated allocation for mid-year hire\n */\nexport function proRateAllocation(\n fullAllocation: number,\n hireDate: Date,\n fiscalYearStartMonth = 1,\n year = new Date().getFullYear()\n): number {\n const fiscalYearStart = new Date(year, fiscalYearStartMonth - 1, 1);\n\n if (hireDate <= fiscalYearStart) {\n return fullAllocation;\n }\n\n const fiscalYearEnd = new Date(year + 1, fiscalYearStartMonth - 1, 0);\n const totalDays = diffInDays(fiscalYearStart, fiscalYearEnd);\n const remainingDays = Math.max(0, diffInDays(hireDate, fiscalYearEnd));\n\n return Math.round((fullAllocation * remainingDays) / totalDays);\n}\n\n// ============================================================================\n// Payroll Integration\n// ============================================================================\n\n/**\n * Calculate unpaid leave deduction for payroll\n *\n * @example\n * const deduction = calculateUnpaidLeaveDeduction(100000, 5, 22);\n * // Daily rate: 100000 / 22 = 4545\n * // Deduction: 4545 * 5 = 22727\n */\nexport function calculateUnpaidLeaveDeduction(\n baseSalary: number,\n unpaidDays: number,\n workingDaysInMonth: number\n): number {\n if (unpaidDays <= 0 || workingDaysInMonth <= 0) return 0;\n\n const dailyRate = baseSalary / workingDaysInMonth;\n return Math.round(dailyRate * unpaidDays);\n}\n\n/**\n * Get total unpaid leave days from a list of leave requests\n */\nexport function getUnpaidLeaveDays(\n leaveRequests: Array<{ type: LeaveType; days: number; status: string }>,\n status = 'approved'\n): number {\n return leaveRequests\n .filter((r) => r.type === 'unpaid' && r.status === status)\n .reduce((sum, r) => sum + r.days, 0);\n}\n\n// ============================================================================\n// Year-End Processing\n// ============================================================================\n\n/**\n * Calculate carry-over balances for year-end\n *\n * Creates new year balances for ALL leave types from the current year.\n * Types with carry-over limits get their unused balance carried forward.\n * Types without carry-over (or 0 limit) start fresh with 0 carriedOver.\n *\n * @example\n * // With default allocations - creates balances for all types\n * const newBalances = calculateCarryOver(employee.leaveBalances, {\n * annual: 5,\n * compensatory: 3,\n * });\n * // Merge with existing (don't replace entirely)\n * employee.leaveBalances.push(...newBalances);\n *\n * // With custom allocations (org-specific entitlements)\n * const newBalances = calculateCarryOver(employee.leaveBalances, {\n * annual: 5,\n * compensatory: 3,\n * }, {\n * annual: 25, // Custom org policy\n * sick: 15,\n * });\n */\nexport function calculateCarryOver(\n balances: LeaveBalance[],\n maxCarryOver: Partial<Record<LeaveType, number>> = DEFAULT_CARRY_OVER,\n newYearAllocations: Partial<Record<LeaveType, number>> = DEFAULT_LEAVE_ALLOCATIONS\n): LeaveBalance[] {\n if (!balances.length) return [];\n\n const currentYear = balances[0].year;\n const newYear = currentYear + 1;\n\n // Process ALL leave types from current year, not just those with carry-over\n return balances.map((balance) => {\n const available =\n balance.allocated + balance.carriedOver - balance.used - balance.pending;\n const maxForType = maxCarryOver[balance.type] ?? 0;\n // Only carry over if max > 0, otherwise start fresh\n const carryOver = maxForType > 0\n ? Math.min(Math.max(0, available), maxForType)\n : 0;\n\n return {\n type: balance.type,\n allocated: newYearAllocations[balance.type] ?? DEFAULT_LEAVE_ALLOCATIONS[balance.type] ?? 0,\n used: 0,\n pending: 0,\n carriedOver: carryOver,\n year: newYear,\n };\n });\n}\n\n/**\n * Add accrued leave to balances\n */\nexport function accrueLeaveToBalance(\n balances: LeaveBalance[],\n type: LeaveType,\n amount: number,\n year = new Date().getFullYear()\n): LeaveBalance[] {\n const existingIdx = balances.findIndex((b) => b.type === type && b.year === year);\n\n if (existingIdx >= 0) {\n balances[existingIdx].allocated += amount;\n } else {\n balances.push({\n type,\n allocated: amount,\n used: 0,\n pending: 0,\n carriedOver: 0,\n year,\n });\n }\n\n return balances;\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Calculate difference in days between two dates\n */\nfunction diffInDays(start: Date, end: Date): number {\n const startDate = new Date(start);\n const endDate = new Date(end);\n startDate.setHours(0, 0, 0, 0);\n endDate.setHours(0, 0, 0, 0);\n return Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));\n}\n\n// ============================================================================\n// Default Export\n// ============================================================================\n\nexport default {\n DEFAULT_LEAVE_ALLOCATIONS,\n DEFAULT_CARRY_OVER,\n calculateLeaveDays,\n hasLeaveBalance,\n getLeaveBalance,\n getLeaveBalances,\n getAvailableDays,\n getLeaveSummary,\n initializeLeaveBalances,\n proRateAllocation,\n calculateUnpaidLeaveDeduction,\n getUnpaidLeaveDays,\n calculateCarryOver,\n accrueLeaveToBalance,\n};\n","/**\n * @classytic/payroll - Error Handling\n *\n * Custom error classes with error codes and HTTP status\n */\n\nimport type { ErrorCode, HttpError } from '../types.js';\n\n// ============================================================================\n// Base Error Class\n// ============================================================================\n\nexport class PayrollError extends Error implements HttpError {\n readonly code: ErrorCode;\n readonly status: number;\n readonly context: Record<string, unknown>;\n readonly timestamp: Date;\n\n /**\n * Create a PayrollError.\n *\n * Supports BOTH constructor styles for backwards compatibility:\n * - new PayrollError(message, code?, status?, context?)\n * - new PayrollError(code, status, message, context?)\n */\n constructor(\n messageOrCode: string | ErrorCode,\n codeOrStatus: ErrorCode | number = 'PAYROLL_ERROR',\n statusOrMessage: number | string = 500,\n context: Record<string, unknown> = {}\n ) {\n const isLegacySignature = typeof messageOrCode === 'string' && typeof codeOrStatus === 'string';\n\n const message = isLegacySignature ? (messageOrCode as string) : (statusOrMessage as string);\n super(message);\n\n this.name = this.constructor.name;\n this.code = isLegacySignature ? (codeOrStatus as ErrorCode) : (messageOrCode as ErrorCode);\n this.status = isLegacySignature ? (statusOrMessage as number) : (codeOrStatus as number);\n this.context = context ?? {};\n this.timestamp = new Date();\n\n // Maintains proper stack trace for where error was thrown\n Error.captureStackTrace?.(this, this.constructor);\n }\n\n /**\n * Convert error to JSON for API responses (ClockIn-compatible shape)\n */\n toJSON(): Record<string, unknown> {\n return {\n error: {\n type: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n context: this.context,\n timestamp: this.timestamp.toISOString(),\n },\n };\n }\n\n /**\n * Check if error is operational (expected) vs programmer error\n */\n isOperational(): boolean {\n return true;\n }\n}\n\n// ============================================================================\n// Specific Error Classes\n// ============================================================================\n\n/**\n * Not initialized error\n */\nexport class NotInitializedError extends PayrollError {\n constructor(message = 'Payroll not initialized. Call Payroll.initialize() first.') {\n super(message, 'NOT_INITIALIZED', 500);\n }\n}\n\n/**\n * Employee not found error\n */\nexport class EmployeeNotFoundError extends PayrollError {\n constructor(employeeId?: string, context?: Record<string, unknown>) {\n super(\n employeeId ? `Employee not found: ${employeeId}` : 'Employee not found',\n 'EMPLOYEE_NOT_FOUND',\n 404,\n context ?? {}\n );\n }\n}\n\n/**\n * Invalid employee error\n */\nexport class InvalidEmployeeError extends PayrollError {\n constructor(message: string, context?: Record<string, unknown>) {\n super(message, 'INVALID_EMPLOYEE', 400, context ?? {});\n }\n}\n\n/**\n * Duplicate payroll error\n */\nexport class DuplicatePayrollError extends PayrollError {\n constructor(\n employeeId: string,\n month: number,\n year: number,\n context?: Record<string, unknown>\n ) {\n super(\n `Payroll already processed for employee ${employeeId} in ${month}/${year}`,\n 'DUPLICATE_PAYROLL',\n 409,\n { employeeId, month, year, ...context }\n );\n }\n}\n\n/**\n * Validation error\n */\nexport class ValidationError extends PayrollError {\n readonly errors: string[];\n\n constructor(errors: string | string[], context?: Record<string, unknown>) {\n const errorArray = Array.isArray(errors) ? errors : [errors];\n super(errorArray.join(', '), 'VALIDATION_ERROR', 400, context ?? {});\n this.errors = errorArray;\n }\n}\n\n/**\n * Employee terminated error\n */\nexport class EmployeeTerminatedError extends PayrollError {\n constructor(employeeId?: string, context?: Record<string, unknown>) {\n super(\n employeeId\n ? `Cannot perform operation on terminated employee: ${employeeId}`\n : 'Cannot perform operation on terminated employee',\n 'EMPLOYEE_TERMINATED',\n 400,\n context ?? {}\n );\n }\n}\n\n/**\n * Already processed error\n */\nexport class AlreadyProcessedError extends PayrollError {\n constructor(message: string, context?: Record<string, unknown>) {\n super(message, 'ALREADY_PROCESSED', 409, context ?? {});\n }\n}\n\n/**\n * Not eligible error\n */\nexport class NotEligibleError extends PayrollError {\n constructor(message: string, context?: Record<string, unknown>) {\n super(message, 'NOT_ELIGIBLE', 400, context ?? {});\n }\n}\n\n// ============================================================================\n// Error Factory\n// ============================================================================\n\n/**\n * Create error from code\n */\nexport function createError(\n code: ErrorCode,\n message: string,\n context?: Record<string, unknown>\n): PayrollError {\n const statusMap: Record<ErrorCode, number> = {\n PAYROLL_ERROR: 500,\n NOT_INITIALIZED: 500,\n EMPLOYEE_NOT_FOUND: 404,\n INVALID_EMPLOYEE: 400,\n DUPLICATE_PAYROLL: 409,\n VALIDATION_ERROR: 400,\n EMPLOYEE_TERMINATED: 400,\n ALREADY_PROCESSED: 409,\n NOT_ELIGIBLE: 400,\n };\n\n return new PayrollError(message, code, statusMap[code] || 500, context ?? {});\n}\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Check if error is PayrollError\n */\nexport function isPayrollError(error: unknown): error is PayrollError {\n return error instanceof PayrollError;\n}\n\n/**\n * Check if error has specific code\n */\nexport function isErrorCode(error: unknown, code: ErrorCode): boolean {\n return isPayrollError(error) && error.code === code;\n}\n\n/**\n * Extract error info for logging\n */\nexport function extractErrorInfo(error: unknown): {\n code: string;\n status: number;\n message: string;\n context?: Record<string, unknown>;\n} {\n if (isPayrollError(error)) {\n return {\n code: error.code,\n status: error.status,\n message: error.message,\n context: error.context,\n };\n }\n\n if (error instanceof Error) {\n return {\n code: 'PAYROLL_ERROR',\n status: 500,\n message: error.message,\n };\n }\n\n return {\n code: 'PAYROLL_ERROR',\n status: 500,\n message: String(error),\n };\n}\n\n// ============================================================================\n// Error Handling Utilities\n// ============================================================================\n\n/**\n * Wrap async function with error handling\n */\nexport function withErrorHandling<T extends (...args: unknown[]) => Promise<unknown>>(\n fn: T,\n errorHandler?: (error: unknown) => void\n): T {\n return (async (...args: Parameters<T>) => {\n try {\n return await fn(...args);\n } catch (error) {\n if (errorHandler) {\n errorHandler(error);\n }\n throw error;\n }\n }) as T;\n}\n\n/**\n * Convert unknown error to PayrollError\n */\nexport function toPayrollError(error: unknown): PayrollError {\n if (isPayrollError(error)) {\n return error;\n }\n\n if (error instanceof Error) {\n return new PayrollError(error.message);\n }\n\n return new PayrollError(String(error));\n}\n\n// ============================================================================\n// Legacy Alias\n// ============================================================================\n\nexport { PayrollError as HRMError };\n\n","/**\n * @classytic/payroll - Secure Employee Lookup\n *\n * Multi-tenant safe employee lookup utilities\n * Enforces organizationId isolation on all queries\n */\n\nimport type { Model } from 'mongoose';\nimport type { EmployeeDocument, ObjectIdLike } from '../types.js';\nimport { toObjectId, isValidObjectId } from './query-builders.js';\nimport { EmployeeNotFoundError } from '../errors/index.js';\n\n/**\n * Employee ID mode for explicit disambiguation\n *\n * Controls how the employeeId parameter is interpreted:\n * - 'auto': Auto-detect via isValidObjectId() (default)\n * - 'objectId': Force treat as MongoDB _id (ObjectId)\n * - 'businessId': Force treat as business employeeId string\n *\n * @since v2.3.0\n */\nexport type EmployeeIdMode = 'auto' | 'objectId' | 'businessId';\n\n/**\n * Lookup options for secure employee queries\n */\nexport interface SecureEmployeeLookupOptions {\n /**\n * Organization ID (required for multi-tenant isolation)\n * Can be omitted only in single-tenant mode with auto-inject\n */\n organizationId?: ObjectIdLike;\n\n /**\n * Employee's Mongoose _id (ObjectId)\n * Use this when you have the database ID\n * Takes priority over employeeId if both are provided\n */\n _id?: ObjectIdLike;\n\n /**\n * Employee identifier (supports both formats):\n * - ObjectId: employee._id (MongoDB document ID)\n * - String: \"EMP-001\" (business identifier)\n *\n * System auto-detects type by default:\n * - If valid ObjectId → queries by _id field\n * - If string → queries by employeeId field\n *\n * Use employeeIdType to override auto-detection if your business\n * employeeIds look like ObjectIds (24 hex characters).\n *\n * Note: If _id parameter is also provided, _id takes priority\n */\n employeeId?: ObjectIdLike | string;\n\n /**\n * Explicit mode hint for employeeId disambiguation\n *\n * - 'auto' (default): Auto-detect via isValidObjectId()\n * - 'objectId': Force treat as MongoDB _id (ObjectId)\n * - 'businessId': Force treat as business employeeId string\n *\n * Use 'businessId' if your employeeIds are 24-hex strings like\n * \"507f1f77bcf86cd799439011\" to prevent ObjectId collision.\n *\n * @default 'auto'\n * @since v2.3.0\n */\n employeeIdMode?: EmployeeIdMode;\n\n /**\n * User ID reference (optional)\n */\n userId?: ObjectIdLike;\n\n /**\n * Email address (optional)\n */\n email?: string;\n\n /**\n * Mongoose session for transactions\n */\n session?: any;\n\n /**\n * Fields to populate\n */\n populate?: string | string[];\n}\n\n/**\n * Securely find an employee by various identifiers\n * ALWAYS enforces organizationId for multi-tenant isolation\n *\n * @param model - Employee model\n * @param options - Lookup options\n * @returns Employee document or throws EmployeeNotFoundError\n *\n * @example\n * // By ObjectId _id\n * const emp = await findEmployeeSecure(Employee, {\n * _id: employee._id,\n * organizationId: org._id\n * });\n *\n * @example\n * // By string employeeId\n * const emp = await findEmployeeSecure(Employee, {\n * employeeId: \"EMP-001\",\n * organizationId: org._id\n * });\n *\n * @example\n * // By 24-hex business employeeId (force businessId mode)\n * const emp = await findEmployeeSecure(Employee, {\n * employeeId: \"507f1f77bcf86cd799439011\", // Looks like ObjectId!\n * employeeIdMode: 'businessId', // Force treat as business ID\n * organizationId: org._id\n * });\n *\n * @example\n * // By userId\n * const emp = await findEmployeeSecure(Employee, {\n * userId: user._id,\n * organizationId: org._id\n * });\n */\nexport async function findEmployeeSecure<T extends EmployeeDocument>(\n model: Model<T>,\n options: SecureEmployeeLookupOptions\n): Promise<T> {\n const {\n organizationId,\n _id,\n employeeId,\n employeeIdMode = 'auto',\n userId,\n email,\n session,\n populate,\n } = options;\n\n // Build query with organizationId isolation\n const query: Record<string, any> = {};\n\n // CRITICAL: Always include organizationId for multi-tenant safety\n if (organizationId) {\n query.organizationId = toObjectId(organizationId);\n }\n\n // Add identifier filters (priority: _id > employeeId > userId > email)\n if (_id) {\n query._id = toObjectId(_id);\n } else if (employeeId !== undefined) {\n // Resolve employeeId mode based on explicit hint or auto-detection\n const shouldTreatAsObjectId =\n employeeIdMode === 'objectId' ||\n (employeeIdMode === 'auto' && isValidObjectId(employeeId));\n\n const shouldTreatAsBusinessId =\n employeeIdMode === 'businessId' ||\n (employeeIdMode === 'auto' && !isValidObjectId(employeeId));\n\n if (shouldTreatAsObjectId) {\n // It's an ObjectId → query by _id field\n query._id = toObjectId(employeeId as ObjectIdLike);\n } else if (shouldTreatAsBusinessId) {\n // It's a string business identifier → query by employeeId field\n query.employeeId = employeeId as string;\n }\n } else if (userId) {\n query.userId = toObjectId(userId);\n } else if (email) {\n query.email = email;\n } else {\n throw new Error(\n 'findEmployeeSecure requires at least one identifier: _id, employeeId, userId, or email'\n );\n }\n\n // Build Mongoose query\n let mongooseQuery = model.findOne(query);\n\n if (session) {\n mongooseQuery = mongooseQuery.session(session);\n }\n\n if (populate) {\n const fields = Array.isArray(populate) ? populate : [populate];\n for (const field of fields) {\n mongooseQuery = mongooseQuery.populate(field);\n }\n }\n\n const employee = await mongooseQuery;\n\n if (!employee) {\n // Provide helpful error message\n const identifier = _id\n ? `_id=${_id}`\n : employeeId\n ? `employeeId=${employeeId}`\n : userId\n ? `userId=${userId}`\n : `email=${email}`;\n\n throw new EmployeeNotFoundError(\n `Employee not found: ${identifier}${organizationId ? ` in organization ${organizationId}` : ''}`\n );\n }\n\n return employee;\n}\n\n/**\n * Check if an employee exists securely (with org isolation)\n *\n * @param model - Employee model\n * @param options - Lookup options\n * @returns true if employee exists, false otherwise\n */\nexport async function employeeExistsSecure<T extends EmployeeDocument>(\n model: Model<T>,\n options: SecureEmployeeLookupOptions\n): Promise<boolean> {\n try {\n await findEmployeeSecure(model, options);\n return true;\n } catch (error) {\n if (error instanceof EmployeeNotFoundError) {\n return false;\n }\n throw error;\n }\n}\n\n/**\n * Find multiple employees securely (with org isolation)\n *\n * @param model - Employee model\n * @param options - Query options\n * @returns Array of employee documents\n */\nexport async function findEmployeesSecure<T extends EmployeeDocument>(\n model: Model<T>,\n options: {\n organizationId: ObjectIdLike;\n filter?: Record<string, any>;\n session?: any;\n limit?: number;\n skip?: number;\n sort?: Record<string, 1 | -1>;\n }\n): Promise<T[]> {\n const { organizationId, filter = {}, session, limit, skip, sort } = options;\n\n // CRITICAL: Always include organizationId\n const query = {\n organizationId: toObjectId(organizationId),\n ...filter,\n };\n\n let mongooseQuery = model.find(query);\n\n if (session) {\n mongooseQuery = mongooseQuery.session(session);\n }\n\n if (limit) {\n mongooseQuery = mongooseQuery.limit(limit);\n }\n\n if (skip) {\n mongooseQuery = mongooseQuery.skip(skip);\n }\n\n if (sort) {\n mongooseQuery = mongooseQuery.sort(sort);\n }\n\n return mongooseQuery;\n}\n\n/**\n * Validate organizationId is provided (unless single-tenant with auto-inject)\n *\n * @param organizationId - Organization ID to validate\n * @param operation - Operation name for error message\n * @throws Error if organizationId is missing\n */\nexport function requireOrganizationId(\n organizationId: ObjectIdLike | undefined,\n operation: string\n): void {\n if (!organizationId) {\n throw new Error(\n `${operation} requires organizationId. ` +\n 'In multi-tenant mode, you must explicitly provide organizationId. ' +\n 'In single-tenant mode, ensure autoInject is enabled in configuration.'\n );\n }\n}\n","/**\n * @classytic/payroll - Organization Resolution Utility\n *\n * Smart organization ID resolution with priority chain:\n * 1. Explicit parameter (highest priority)\n * 2. Context.organizationId (from middleware/auth)\n * 3. Single-tenant config (if autoInject enabled)\n * 4. Error (if none found in multi-tenant mode)\n */\n\nimport type { ObjectIdLike, OperationContext } from '../types.js';\nimport type { Container } from '../core/container.js';\nimport { toObjectId } from './query-builders.js';\nimport { Types } from 'mongoose';\n\n/**\n * Container-like interface for organization resolution\n * Only requires the methods we need, allowing any generic Container type\n */\nexport interface ContainerLike {\n isSingleTenant(): boolean;\n getSingleTenantConfig(): { organizationId?: any; autoInject?: boolean } | null;\n getOrganizationId(): string | null;\n}\n\n/**\n * Organization resolution parameters\n */\nexport interface ResolveOrganizationIdParams {\n /**\n * Explicitly provided organizationId (highest priority)\n */\n explicit?: ObjectIdLike;\n\n /**\n * Operation context with possible organizationId\n */\n context?: OperationContext;\n\n /**\n * Container for single-tenant config access\n * Accepts any Container with any generic types\n */\n container?: ContainerLike;\n\n /**\n * Operation name for error messages\n */\n operation?: string;\n}\n\n/**\n * Smart organization ID resolution\n *\n * Priority Chain:\n * 1. Explicit param (highest)\n * 2. Context.organizationId (middleware/auth)\n * 3. Single-tenant config (if autoInject enabled)\n * 4. Error (if none found)\n *\n * @param params - Resolution parameters\n * @returns Resolved ObjectId\n * @throws Error if organizationId cannot be resolved\n *\n * @example\n * // Explicit param wins\n * const orgId = resolveOrganizationId({\n * explicit: org._id,\n * context: { organizationId: other._id },\n * operation: 'processSalary'\n * });\n * // Returns: org._id\n *\n * @example\n * // Context fallback\n * const orgId = resolveOrganizationId({\n * context: { organizationId: org._id },\n * operation: 'processSalary'\n * });\n * // Returns: org._id from context\n *\n * @example\n * // Single-tenant auto-inject\n * const orgId = resolveOrganizationId({\n * container: singleTenantContainer,\n * operation: 'processSalary'\n * });\n * // Returns: organizationId from container config\n */\nexport function resolveOrganizationId(\n params: ResolveOrganizationIdParams\n): Types.ObjectId {\n const { explicit, context, container, operation } = params;\n\n // 1. Explicit param wins\n if (explicit) {\n return toObjectId(explicit);\n }\n\n // 2. Context from middleware/auth\n if (context?.organizationId) {\n return toObjectId(context.organizationId);\n }\n\n // 3. Single-tenant auto-inject\n if (container?.isSingleTenant()) {\n const singleTenantConfig = container.getSingleTenantConfig();\n if (singleTenantConfig?.autoInject) {\n const orgId = container.getOrganizationId();\n if (orgId) {\n return toObjectId(orgId);\n }\n }\n }\n\n // 4. Error - no organizationId found\n const operationName = operation || 'Operation';\n throw new Error(\n `${operationName} requires organizationId. ` +\n 'Options:\\n' +\n '1. Provide it explicitly in parameters\\n' +\n '2. Pass it via context (from middleware/auth)\\n' +\n '3. Enable single-tenant mode with autoInject: true\\n\\n' +\n 'Example (multi-tenant):\\n' +\n ` await payroll.${operation || 'method'}({ organizationId: org._id, ... });\\n\\n` +\n 'Example (single-tenant):\\n' +\n ' const payroll = createPayrollInstance()\\n' +\n ' .withModels({ ... })\\n' +\n ' .forSingleTenant({ organizationId: myOrg._id, autoInject: true })\\n' +\n ' .build();'\n );\n}\n\n/**\n * Validate that organizationId is present\n *\n * @param organizationId - Organization ID to validate\n * @param operation - Operation name for error message\n * @returns ObjectId if valid\n * @throws Error if organizationId is missing or invalid\n */\nexport function validateOrganizationId(\n organizationId: ObjectIdLike | undefined,\n operation: string\n): Types.ObjectId {\n if (!organizationId) {\n throw new Error(\n `${operation} requires organizationId. ` +\n 'Provide it explicitly, via context, or enable single-tenant mode with autoInject.'\n );\n }\n\n try {\n return toObjectId(organizationId);\n } catch (error) {\n throw new Error(\n `${operation} received invalid organizationId: ${organizationId}. ` +\n 'Must be a valid ObjectId, ObjectId string, or ObjectId-like object.'\n );\n }\n}\n\n/**\n * Try to resolve organizationId without throwing\n *\n * @param params - Resolution parameters\n * @returns ObjectId if resolved, null otherwise\n */\nexport function tryResolveOrganizationId(\n params: ResolveOrganizationIdParams\n): Types.ObjectId | null {\n try {\n return resolveOrganizationId(params);\n } catch {\n return null;\n }\n}\n","/**\n * @classytic/payroll - Employee Identity Helper\n *\n * Dual identity system for employee lookups:\n * - MongoDB ObjectId (_id field)\n * - Business string identifier (employeeId field like \"EMP-001\")\n *\n * Auto-detects identifier type and builds appropriate queries\n */\n\nimport type { ObjectIdLike } from '../types.js';\nimport { Types } from 'mongoose';\nimport { isValidObjectId, toObjectId } from './query-builders.js';\n\n/**\n * Employee identifier type\n */\nexport type EmployeeIdType = 'objectId' | 'string';\n\n/**\n * Employee query filter\n */\nexport interface EmployeeQueryFilter {\n _id?: Types.ObjectId;\n employeeId?: string;\n organizationId: Types.ObjectId;\n}\n\n/**\n * Detect if employeeId is ObjectId or string\n *\n * @param employeeId - Employee identifier (ObjectId or string)\n * @returns 'objectId' if valid ObjectId, 'string' otherwise\n *\n * @example\n * detectEmployeeIdType(employee._id)\n * // Returns: 'objectId'\n *\n * @example\n * detectEmployeeIdType(\"EMP-001\")\n * // Returns: 'string'\n */\nexport function detectEmployeeIdType(\n employeeId: ObjectIdLike | string\n): EmployeeIdType {\n // Check if it's a valid ObjectId\n if (isValidObjectId(employeeId)) {\n return 'objectId';\n }\n\n // Otherwise treat as string business identifier\n return 'string';\n}\n\n/**\n * Build employee query based on identifier type\n *\n * Automatically detects if employeeId is ObjectId or string\n * and builds the appropriate MongoDB query filter.\n *\n * @param employeeId - Employee identifier (ObjectId or string)\n * @param organizationId - Organization ID for multi-tenant isolation\n * @returns Query filter for MongoDB\n *\n * @example\n * // By ObjectId _id\n * const query = buildEmployeeQuery(employee._id, org._id);\n * // Returns: { _id: ObjectId(...), organizationId: ObjectId(...) }\n *\n * @example\n * // By string employeeId\n * const query = buildEmployeeQuery(\"EMP-001\", org._id);\n * // Returns: { employeeId: \"EMP-001\", organizationId: ObjectId(...) }\n */\nexport function buildEmployeeQuery(\n employeeId: ObjectIdLike | string,\n organizationId: Types.ObjectId\n): EmployeeQueryFilter {\n const idType = detectEmployeeIdType(employeeId);\n\n if (idType === 'objectId') {\n return {\n _id: toObjectId(employeeId as ObjectIdLike),\n organizationId,\n };\n }\n\n // String business identifier\n return {\n employeeId: employeeId as string,\n organizationId,\n };\n}\n\n/**\n * Normalize employee identifier to consistent format\n *\n * Converts ObjectIdLike to ObjectId, keeps strings as-is\n *\n * @param employeeId - Employee identifier\n * @returns Normalized ObjectId or string\n */\nexport function normalizeEmployeeId(\n employeeId: ObjectIdLike | string\n): Types.ObjectId | string {\n const idType = detectEmployeeIdType(employeeId);\n\n if (idType === 'objectId') {\n return toObjectId(employeeId as ObjectIdLike);\n }\n\n return employeeId as string;\n}\n\n/**\n * Check if value is a string employee ID (not ObjectId)\n *\n * @param value - Value to check\n * @returns true if string employeeId, false if ObjectId\n */\nexport function isStringEmployeeId(value: unknown): value is string {\n return typeof value === 'string' && !isValidObjectId(value);\n}\n\n/**\n * Check if value is an ObjectId employee identifier\n *\n * @param value - Value to check\n * @returns true if ObjectId, false otherwise\n */\nexport function isObjectIdEmployeeId(value: unknown): value is ObjectIdLike {\n return isValidObjectId(value);\n}\n\n/**\n * Format employee identifier for display\n *\n * @param employeeId - Employee identifier\n * @returns Human-readable string\n *\n * @example\n * formatEmployeeId(employee._id)\n * // Returns: \"_id=507f1f77bcf86cd799439011\"\n *\n * @example\n * formatEmployeeId(\"EMP-001\")\n * // Returns: \"employeeId=EMP-001\"\n */\nexport function formatEmployeeId(employeeId: ObjectIdLike | string): string {\n const idType = detectEmployeeIdType(employeeId);\n\n if (idType === 'objectId') {\n return `_id=${toObjectId(employeeId as ObjectIdLike).toString()}`;\n }\n\n return `employeeId=${employeeId}`;\n}\n"]}
|