Check vacation days against the entitlement before persisting them

Applied batches were validated against the remaining föräldrapenning tiers
but never against semester. That held only while the allocator was the sole
writer, since its ledger spends vacation against a per-year budget. The
calendar is about to let a user force any day to semester and pin it, which
writes straight past that ledger, so nothing would have stopped forty pinned
vacation days against a twenty-five day entitlement.

The check mirrors the allocator's own derivation rather than restating it:
available days are total plus days saved in, and a year with no entered row
falls back to the statutory entitlement instead of reading as zero. The
semesterlagen floor stays out of it, being a bound on what may be carried
forward rather than a cap on what may be spent. Vacation is budgeted per
calendar year, so a period crossing New Year is charged to both.
This commit is contained in:
2026-09-17 18:22:55 +02:00
parent c1aa4ae0b0
commit d06c8c8449
6 changed files with 466 additions and 10 deletions
+6 -1
View File
@@ -298,8 +298,13 @@ async def planning_service(
planned_leave_repo: SQLitePlannedLeaveRepository,
analytics_service: AnalyticsService,
parental_leave_repo: SQLiteParentalLeaveRepository,
vacation_repo: SQLiteVacationDaysRepository,
planning_engine_service: PlanningEngineService,
) -> PlanningService:
return PlanningService(
planned_leave_repo, analytics_service, parental_leave_repo, planning_engine_service
planned_leave_repo,
analytics_service,
parental_leave_repo,
vacation_repo,
planning_engine_service,
)