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.
This commit is contained in:
2026-09-18 00:23:34 +02:00
parent 8d2f658061
commit ac3b6a41d7
10 changed files with 337 additions and 37 deletions
@@ -33,3 +33,13 @@ class PlannedLeaveRepository(Repository[PlannedLeaveDay]):
@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.
"""