Files
F-r-ldraledigplannerare/backend/app/repositories/planned_leave_repository.py
T
jacobh2 ac3b6a41d7 Remove a period's days along with the period
Deleting a period left every day it had funded behind. The link from a day
back to its period was set to null the instant the period was deleted, so the
days became untraceable before anything could clean them up, and the next
recalculation had no way to know they no longer belonged to anything. Undo had
the same fault for the same reason: the period went, the days stayed, and a
reload showed them still there.

The days are now removed with the period, before the link can be broken. A day
pinned by hand goes too — pinning keeps the planner from quietly retyping a
day, not from being deleted when you delete the period it belongs to, which is
already how an unplanned band behaves.
2026-09-18 00:23:34 +02:00

46 lines
1.6 KiB
Python

"""Abstract repository for PlannedLeaveDay calendar events."""
from abc import abstractmethod
from datetime import date
from uuid import UUID
from app.entities.planned_leave import PlannedLeaveDay
from app.repositories.base import Repository
class PlannedLeaveRepository(Repository[PlannedLeaveDay]):
@abstractmethod
async def list_by_workspace_child(
self,
workspace_id: UUID,
child_id: UUID,
from_date: date | None = None,
to_date: date | None = None,
) -> list[PlannedLeaveDay]:
"""Return planned days for a workspace+child, optionally within a date range."""
@abstractmethod
async def count_by_parent_type(
self,
personal_data_uuid: UUID,
child_id: UUID,
day_type: str,
from_date: date | None = None,
to_date: date | None = None,
) -> int:
"""Count planned days of a given type for a parent+child pair."""
@abstractmethod
async def count_dubbeldagar(self, child_id: UUID, from_date: date | None = None) -> int:
"""Count dubbeldagar already planned for a child (after from_date)."""
@abstractmethod
async def delete_by_wish(self, wish_id: UUID) -> int:
"""Delete every row attributed to this wish (pinned or not) and return the count deleted.
See `LeaveWishService.delete()`: called before the `leave_wish` row is
removed so the FK's `ON DELETE SET NULL` never fires — by the time
that DELETE runs, no `planned_leave_day` row still references this
wish, so there is nothing left to orphan.
"""