Files
F-r-ldraledigplannerare/backend/app/entities/preschool_planning_days.py
T
jacobh2 0e9b20ec37 Track preschool planning days, partner invites and real vacation forfeiture
Three strands of work that grew together across the same settings screen and
API client, so they land as one change.

Per-year preschool planning days ("studiedagar"): new table, repository
(SQLite + Postgres), service, router and migration 007, plus the hooks and
Settings UI to plan and record them per child and year. Allocation now
reserves the recorded figure for a year where one exists and only falls back
to the child-level estimate otherwise, marking that fallback as assumed.

Partner invitations: workspaces issue and list invitations, registration
accepts an invite token to join the inviter's workspace instead of creating a
personal one, and a /join/:token page plus the settings invite panel drive it.

Vacation forfeiture: tips and the dashboard now distinguish days a parent
genuinely loses from days that merely age, so the warning stops firing on
balances that were never at risk.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 11:22:07 +02:00

38 lines
1.4 KiB
Python

"""Domain entity: PreschoolPlanningDays.
One row per (child, year): how many "förskolans planeringsdagar" (preschool
closure/planning days, e.g. "studiedagar") that child's preschool has for a
given year, and how many were actually taken.
`taken_days` is nullable on purpose: `None` means "not recorded yet", which
must be distinguishable from "recorded, and it was zero" — that distinction
is the whole point of this slice. Before this table existed,
`app/services/allocation_service.py::_preschool_reserve_days` could only
multiply `Child.preschool_planning_days_per_year` (see
`app/entities/child.py`) by the number of years in the planning horizon and
subtract the lump sum from both parents' pools, with no way to know the true
per-year number or how many parental-leave days that assumption actually
cost.
NOTE for whoever wires the allocation engine to this table (tracked as a
follow-up, not done in this change): a (child, year) pair with no row here
means "use `Child.preschool_planning_days_per_year` as the planned figure,
taken unknown" — callers must fall back to that default rather than treating
a missing row as zero days.
"""
from dataclasses import dataclass
from datetime import datetime
from uuid import UUID
@dataclass
class PreschoolPlanningDays:
id: UUID
child_id: UUID
year: int
planned_days: int
taken_days: int | None = None
created_at: datetime | None = None
updated_at: datetime | None = None