If provided percentages are inconsistent (e.g., sum of valid categories > 100), diff becomes negative and addEach reduces each category. That can drive individual category percentages negative, producing negative hours-per-day.
How to fix: Add validation:
- Ensure each input pct is between 0 and 100
- Ensure the sum across provided categories is ~100 (or allow variance but clamp)
- After redistribution, clamp at 0 and re-normalize (or throw error).
File: ScheduleHoursDistributor.cls (redistribution section in generateCategoryScheduleExceptions)