namespace WiDAL.Query.Wi { // Standalone, reusable outside WI: any module that rosters/staffs employees for a given // date can join to this same TLEAVE/TLEAVEDETAIL (PayRoll) result instead of re-deriving // it. LEAVESTATUS: 0 Pending, 1 Availed, 2 Final — only 1/2 count as an approved absence; // 0 (Pending) must not auto-mark someone absent before the leave is actually confirmed. public static class EmployeeLeaveLinkQB { // @EmployeeIds is bound via Dapper's IEnumerable parameter expansion (IN @EmployeeIds), // not string concatenation. No tenant/OU filter here — TLEAVE has no TENANTID column // (confirmed from PayRollDAL/Query/TLeave/TLeaveQB.cs's own INSERT column list; it scopes // via OUID only), and this query relies on the caller (WI's roster) only ever passing // EmployeeIds that are already known to belong to the current tenant's own roster. public const string GET_APPROVED_LEAVE_FOR_DATE = @" SELECT D.EMPLOYEEID AS EmployeeId, D.LEAVEDATE AS LeaveDate, D.LEAVESTATUS AS LeaveStatus, D.LEAVETYPEID AS LeaveTypeId FROM TLEAVEDETAIL D INNER JOIN TLEAVE T ON T.LEAVEID = D.LEAVEID WHERE D.EMPLOYEEID IN @EmployeeIds AND D.LEAVEDATE = @LeaveDate AND D.LEAVESTATUS IN (1, 2);"; } }