import type { AccrualPlan, LeaveConsumption, LeaveGrant, LeaveRequest, LeaveType, Schema, } from "../lib/types"; export const basePaidLeaveType = { id: "leave-type-1", key: "PAID_LEAVE", displayName: "Annual Paid Leave", category: "PAID_LEAVE_FULL", requiresBalance: true, drawsFromCompensatoryGrants: null, timeEntryCodeKey: "LEAVE_PAID", isActive: true, // Pre-existing row shape: requestUnit never set (null), treated as RANGE requestUnit: null, createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies LeaveType; export const menstrualLeaveType = { id: "leave-type-2", key: "MENSTRUAL_LEAVE", displayName: "Menstrual Leave", category: "MENSTRUAL", requiresBalance: false, drawsFromCompensatoryGrants: null, timeEntryCodeKey: "LEAVE_MENSTRUAL", isActive: true, requestUnit: null, createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies LeaveType; export const baseAccrualPlan = { id: "accrual-plan-1", leaveTypeKey: basePaidLeaveType.key, accrualMethod: "FRONT_LOAD_TENURE", grantType: "STATUTORY", eligibilityDelayMonths: 0, baseGrantDays: "10", tenureTiers: [ { yearsOfService: 1, grantDays: 11 }, { yearsOfService: 2, grantDays: 12 }, ], annualCapDays: "20", expirationMonths: 24, appliesToEmploymentTypeId: null, grantCondition: null, effectiveStart: new Date("2024-01-01T00:00:00.000Z"), effectiveEnd: null, versionOf: "accrual-plan-1", createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies AccrualPlan; export const baseLeaveGrant = { id: "leave-grant-1", workerId: "worker-1", leaveTypeKey: basePaidLeaveType.key, grantType: "STATUTORY", grantSource: "HIRE", grantedDays: "10", remainingDays: "10", grantedDate: new Date("2024-01-01T00:00:00.000Z"), expirationDate: new Date("2026-01-01T00:00:00.000Z"), expiredAt: null, createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies LeaveGrant; export const baseLeaveRequest = { id: "leave-request-1", workerId: "worker-1", assignmentId: "assignment-1", leaveTypeKey: basePaidLeaveType.key, startDate: new Date("2024-03-01T00:00:00.000Z"), endDate: new Date("2024-03-01T00:00:00.000Z"), reason: "Personal errand", status: "PENDING", resolvedAt: null, resolvedBy: null, targetEntityId: "approval-request-1", createdAt: new Date("2024-02-01T00:00:00.000Z"), updatedAt: new Date("2024-02-01T00:00:00.000Z"), } as const satisfies LeaveRequest; export const approvedLeaveRequest = { id: "leave-request-2", workerId: "worker-1", assignmentId: "assignment-1", leaveTypeKey: basePaidLeaveType.key, startDate: new Date("2024-02-01T00:00:00.000Z"), endDate: new Date("2024-02-01T00:00:00.000Z"), reason: "Family event", status: "APPROVED", resolvedAt: new Date("2024-01-25T00:00:00.000Z"), resolvedBy: "user-1", targetEntityId: "approval-request-2", createdAt: new Date("2024-01-20T00:00:00.000Z"), updatedAt: new Date("2024-01-20T00:00:00.000Z"), } as const satisfies LeaveRequest; export const baseLeaveConsumption = { id: "leave-consumption-1", leaveRequestId: approvedLeaveRequest.id, leaveGrantId: baseLeaveGrant.id, daysConsumed: "1", restoredAt: null, createdAt: new Date("2024-01-25T00:00:00.000Z"), updatedAt: new Date("2024-01-25T00:00:00.000Z"), } as const satisfies LeaveConsumption; // Sooner-expiring, low-balance grant used to exercise FIFO allocation splitting across grants export const soonerExpiringLeaveGrant = { id: "leave-grant-2", workerId: "worker-1", leaveTypeKey: basePaidLeaveType.key, grantType: "STATUTORY", grantSource: "HIRE", grantedDays: "0.5", remainingDays: "0.5", grantedDate: new Date("2023-01-01T00:00:00.000Z"), expirationDate: new Date("2025-06-01T00:00:00.000Z"), expiredAt: null, createdAt: new Date("2023-01-01T00:00:00.000Z"), updatedAt: new Date("2023-01-01T00:00:00.000Z"), } as const satisfies LeaveGrant; // PENDING request that has already reserved a day, for rejectLeave/withdrawLeave restoration tests export const pendingLeaveConsumption = { id: "leave-consumption-2", leaveRequestId: baseLeaveRequest.id, leaveGrantId: baseLeaveGrant.id, daysConsumed: "1", restoredAt: null, createdAt: new Date("2024-02-01T00:00:00.000Z"), updatedAt: new Date("2024-02-01T00:00:00.000Z"), } as const satisfies LeaveConsumption; export const rejectedLeaveRequest = { id: "leave-request-3", workerId: "worker-1", assignmentId: "assignment-1", leaveTypeKey: basePaidLeaveType.key, startDate: new Date("2024-01-15T00:00:00.000Z"), endDate: new Date("2024-01-15T00:00:00.000Z"), reason: "Personal errand", status: "REJECTED", resolvedAt: new Date("2024-01-16T00:00:00.000Z"), resolvedBy: "user-1", targetEntityId: "approval-request-3", createdAt: new Date("2024-01-10T00:00:00.000Z"), updatedAt: new Date("2024-01-10T00:00:00.000Z"), } as const satisfies LeaveRequest; // APPROVED request that already has a cancellation in flight export const cancelPendingLeaveRequest = { id: "leave-request-4", workerId: "worker-1", assignmentId: "assignment-1", leaveTypeKey: basePaidLeaveType.key, startDate: new Date("2024-04-01T00:00:00.000Z"), endDate: new Date("2024-04-01T00:00:00.000Z"), reason: "Family event", status: "CANCEL_PENDING", resolvedAt: new Date("2024-03-25T00:00:00.000Z"), resolvedBy: "user-1", targetEntityId: "approval-request-4", createdAt: new Date("2024-03-20T00:00:00.000Z"), updatedAt: new Date("2024-03-20T00:00:00.000Z"), } as const satisfies LeaveRequest; export const cancelPendingLeaveConsumption = { id: "leave-consumption-3", leaveRequestId: cancelPendingLeaveRequest.id, leaveGrantId: baseLeaveGrant.id, daysConsumed: "1", restoredAt: null, createdAt: new Date("2024-03-25T00:00:00.000Z"), updatedAt: new Date("2024-03-25T00:00:00.000Z"), } as const satisfies LeaveConsumption; // Full tenure tier table (1y through 6y+) for runAnniversaryLeaveGrants tests export const fullTierAccrualPlan = { id: "accrual-plan-2", leaveTypeKey: basePaidLeaveType.key, accrualMethod: "FRONT_LOAD_TENURE", grantType: "STATUTORY", eligibilityDelayMonths: 0, baseGrantDays: "10", tenureTiers: [ { yearsOfService: 1, grantDays: 11 }, { yearsOfService: 2, grantDays: 12 }, { yearsOfService: 3, grantDays: 14 }, { yearsOfService: 4, grantDays: 16 }, { yearsOfService: 5, grantDays: 18 }, { yearsOfService: 6, grantDays: 20 }, ], annualCapDays: "20", expirationMonths: 24, appliesToEmploymentTypeId: null, grantCondition: null, effectiveStart: new Date("2024-01-01T00:00:00.000Z"), effectiveEnd: null, versionOf: "accrual-plan-2", createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies AccrualPlan; // Restricted to the employment-type-1 catalog entry, for the appliesToEmploymentTypeId mismatch test export const fullTimeOnlyAccrualPlan = { id: "accrual-plan-3", leaveTypeKey: basePaidLeaveType.key, accrualMethod: "FRONT_LOAD_TENURE", grantType: "STATUTORY", eligibilityDelayMonths: 0, baseGrantDays: "10", tenureTiers: fullTierAccrualPlan.tenureTiers, annualCapDays: "20", expirationMonths: 24, appliesToEmploymentTypeId: "employment-type-1", grantCondition: null, effectiveStart: new Date("2024-01-01T00:00:00.000Z"), effectiveEnd: null, versionOf: "accrual-plan-3", createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies AccrualPlan; export const specialCategoryLeaveType = { id: "leave-type-3", key: "SPECIAL_LEAVE", displayName: "Special Leave", category: "SPECIAL", requiresBalance: false, drawsFromCompensatoryGrants: null, timeEntryCodeKey: "LEAVE_SPECIAL", isActive: true, requestUnit: null, createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies LeaveType; export const deactivatedLeaveType = { id: "leave-type-4", key: "RETIRED_LEAVE", displayName: "Retired Leave Type", category: "COMPENSATORY", requiresBalance: true, drawsFromCompensatoryGrants: true, timeEntryCodeKey: "LEAVE_COMPENSATORY", isActive: false, requestUnit: null, createdAt: new Date("2024-01-01T00:00:00.000Z"), updatedAt: new Date("2024-01-01T00:00:00.000Z"), } as const satisfies LeaveType;