Workflows & Automation · Data & Caching · Backend· 9 min read
Enterprise policy rule engines: biometric attendance, sandwich rules, and PMS
Designing complex workforce policy engines. Handling sandwich rule leave calculations, geofenced biometric punch-out reconciliation, automated Loss of Pay (LOP), and 3-tier PMS appraisals.
Policy EngineHRMSBiometricsPMSDomain Logic
Enterprise HRMS software cannot rely on simplistic crud forms. Real-world workforce operations are governed by dense statutory policies and enterprise rules. In my HRMS architecture at Tedekstra, three domain engines handle automated workforce logic: the Leave & Sandwich Rule Engine, the Biometric Attendance Engine, and the 3-Tier Performance Management System (PMS).
The sandwich rule leave deduction engine
Under the enterprise 'sandwich rule', if an employee takes leave on Friday and Monday, the intervening weekend days (Saturday and Sunday) are automatically counted as leave days rather than paid weekend holidays. Computing this accurately requires bidirectional calendar scanning across public holidays and company shift calendars.
export function evaluateSandwichRule(
leaveStart: Date,
leaveEnd: Date,
weekendDays: number[] = [0, 6], // Sunday = 0, Saturday = 6
holidayDates: string[] = []
): number {
let totalDeductibleDays = 0;
let currentDate = new Date(leaveStart);
while (currentDate <= leaveEnd) {
const dayOfWeek = currentDate.getDay();
const dateStr = currentDate.toISOString().slice(0, 10);
const isWeekend = weekendDays.includes(dayOfWeek);
const isHoliday = holidayDates.includes(dateStr);
// If sandwich rule is active, intervening holidays and weekends are deducted
if (!isWeekend && !isHoliday) {
totalDeductibleDays++;
} else {
totalDeductibleDays++; // Deducted under strict sandwich policy
}
currentDate.setDate(currentDate.getDate() + 1);
}
return totalDeductibleDays;
}3-tier PMS lifecycle engine
Annual appraisals operate across three gated review tiers: Employee Self-Appraisal with weighted KPI reflections, Manager Evaluation with normalized numerical grading, and Executive HR Calibration. Once HR approves calibration, the system automatically triggers salary revision letters or auto-enrolls underperforming tiers into Performance Improvement Plans (PIP).