Punishments and Rewards: The logic of RetardoManager and BusinessDaysCalculator (Part 4)
Having an automated check-in is wonderful, but the real acid test of an HR system is how it handles exceptions. Or, in English: how it deals with people who are late.
The headache of business days in Mexico
If you use a foreign SaaS, calculating business days is a pain. In Mexico, we have official holidays, "unofficial" holidays (like Day of the Dead), magical long weekends, and days where we simply decide to close the agency.
That's why I created the BusinessDaysCalculator. It's a Drupal service that hooks into a manageable calendar. Before the system decides if someone is late or absent, it queries this service. "Is today September 16th? Oh ok, don't run the penalty script".
RetardoManager: The ruthless judge
This is where friendship ends and code begins.
Our RetardoManager is a mathematical monster. Its job is simple: evaluate the RegistroAsistencia against the user's expected schedule.
But it's not black and white. It has clear rules:
- Tolerance: You get a 15-minute grace period.
- Accumulation: 3 tardies in a calendar month equal one DiaDescontado (Docked Day).
- Exceptions: If the record has a PermisoConGoce (Paid Leave) or EventoScouting entity tied to that same date, the system forgives you automatically.

The beauty of having this custom programmed is that HR no longer has to do end-of-month reconciliations crossing Excel sheets and emails. When payroll day arrives, Drupal simply spits out a JSON with the exact balance of payable days and penalties per employee.
In Chapter 5, the finale of this series, I'll talk about cybersecurity. Because when you deploy a web time clock, the first instinct of the Mexican worker is to hack it. We'll talk about DeviceFingerprint.