Missing Periods Benefit Schedule to Pay
This script is designed to identify benefit schedules for a specific employee that might be missing corresponding pay records. It is a diagnostic tool to help determine if an employee's scheduled benefit time has been correctly processed for payment.
Description
The script focuses on a single employee, identified by their FILEKEY. It retrieves all benefit-type schedules (SCHTYPE = 2) that occurred after a system issue began on April 19, 2025, and checks for a matching record in the PAYDESHIST table.
Key functionalities include:
- Employee-Specific: Requires a
FILEKEYto be set for the target employee. - Date-Filtered: Only checks records from April 20, 2025, up to the current date.
- Pay Status: Clearly indicates whether a pay record exists for each benefit schedule.
- Potential Lost Dollars: Calculates the potential financial loss if a pay record is missing.
How to Use
- Set Employee
FILEKEY:- Open the script in your SQL editor.
- Locate the line
DECLARE @FILEKEY INT = 2299;. - Replace
2299with theFILEKEYof the employee you want to investigate.
- Execute the Script:
- Run the script.
- The results will show a list of benefit schedules with their payment status.
- Analyze Results:
- Look for records where
PAY_STATUSis 'NO PAY RECORD'. - The
POTENTIAL_LOST_DOLLARScolumn will show the amount that may need to be paid.
- Look for records where
Download Alternative Formats
📥 Browser Export Format:
- Download Export File - Download this export for external processing
SET NOCOUNT ON;
DECLARE @FILEKEY INT = 2299;
-- Replace with specific employee's FILEKEY
-- Get employee info for date filtering
WITH
EmployeeInfo
AS
(
SELECT
@FILEKEY AS FILEKEY,
e.ACTIVESTATUSEFFDATE,
DATEADD(WEEK, -1,
DATEADD(DAY, -(DATEPART(WEEKDAY, e.ACTIVESTATUSEFFDATE) - 1),
CAST(e.ACTIVESTATUSEFFDATE AS DATE))
) AS FirstValidPeriodStart
FROM EMPLOYEES e
WHERE e.FILEKEY = @FILEKEY
AND e.ACTIVESTATUS = 0
)
-- Show all schedules and their payment status
SELECT
s.FILEKEY,
s.SCHDATE,
s.STARTTIME,
s.ENDTIME,
s.HOURS AS SCHEDULED_HOURS,
CASE
WHEN s.SCHTYPE = 0 THEN 'NORMAL'
WHEN s.SCHTYPE = 1 THEN 'FLEX'
WHEN s.SCHTYPE = 2 THEN 'BENEFIT'
ELSE 'UNKNOWN'
END AS SCHEDULE_TYPE,
s.WG1,
s.WG2,
s.WG3,
s.RATE AS SCHEDULED_RATE,
s.BENEFIT,
s.PATTERN,
s.SCHSTYLE,
s.WG4,
s.WG5,
p.PAYDESNUM,
p.HOURS AS PAID_HOURS,
p.DOLLARS AS PAID_DOLLARS,
p.RATE AS PAID_RATE,
CASE
WHEN p.FILEKEY IS NULL THEN 'NO PAY RECORD'
ELSE 'HAS PAY RECORD'
END AS PAY_STATUS,
CASE
WHEN p.FILEKEY IS NULL THEN s.HOURS * s.RATE
ELSE 0
END AS POTENTIAL_LOST_DOLLARS
FROM EmployeeInfo ei
INNER JOIN SCHEDULES s ON ei.FILEKEY = s.FILEKEY
AND s.SCHDATE >= ei.FirstValidPeriodStart
AND s.SCHDATE > '2025-04-19' -- Only check after the issue started
AND s.SCHDATE <= CAST(GETDATE() AS DATE) -- Only up to today
LEFT JOIN PAYDESHIST p ON s.FILEKEY = p.FILEKEY
AND s.SCHDATE = p.EVENTDATE
WHERE s.FILEKEY = @FILEKEY
ORDER BY s.SCHDATE;
SET NOCOUNT OFF;Content Inventory
- Doc File:
content/docs/utilities/missing_periods_benefit_sch_to_pay.mdx - SQL Script:
SQL/utilities/missing_periods_benefit_sch_to_pay.sql - Browser Export:
public/aod/browser_exports/utilities/missing_periods_benefit_sch_to_pay.browser_export