Link planned days to their wish, fix the age-4 cap, drop the planning goal
Three changes that together unblock treating a calendar period as one editable object. Migration 008 adds `planned_leave_day.wish_id` (nullable, ON DELETE SET NULL) so a persisted day knows which `leave_wish` produced it, `is_pinned` to mark a day the user hand-edited, and `leave_wish.target_days` so a period drawn on a calendar need not be a whole number of weeks. Apply-time identity still keys on day_type/is_dubbeldag only, so a wish_id-only difference is a metadata update rather than a collision. The age-4 savable ceiling was applying the per-child figure of 96 to each parent's pool, modelling a two-parent family as able to save 192 days past the child's fourth birthday. `resolve_age4_savable_cap` is now the single place that decides 48 (couple with two parents) versus 96 (everyone else), and both AnalyticsService and the allocator read it. Migration 009 drops `workspace.planning_goal` and `leave_wish.goal_override`. The allocator's tier-3 policy collapses to one rule; `salary_type` still branches, since that reflects what a vacation day actually costs a parent rather than a user preference.
This commit is contained in:
@@ -41,10 +41,6 @@ class LeaveWish:
|
||||
parent_mode: str # 'either' | 'both' | 'specific'
|
||||
parent_personal_data_uuid: UUID | None # required when parent_mode == 'specific'
|
||||
|
||||
# Per-window override of workspace planning_goal. Nullable, no UI in v1 —
|
||||
# the field exists now so enabling it later needs no migration.
|
||||
goal_override: str | None = None # 'max_time' | 'max_money' | 'balanced' | None
|
||||
|
||||
# PLANNING_ENGINE_SPEC.md §10.1 — 'fixed' (default): window_start_*/window_end_*
|
||||
# are the exact placement, as above. 'flexible': the SAME four fields instead
|
||||
# describe the BOUNDING RANGE the allocator searches inside for the
|
||||
@@ -65,9 +61,19 @@ class LeaveWish:
|
||||
# revert to one.
|
||||
name_message_key: str | None = None
|
||||
|
||||
# A calendar-drawn period (e.g. dragging a band on the calendar UI) is not
|
||||
# a whole number of weeks. NULL (every row created before this field
|
||||
# existed, and any wish still specified in weeks) falls back to
|
||||
# `target_weeks * 7` — see `target_span_days()`.
|
||||
target_days: int | None = None
|
||||
|
||||
created_at: datetime | None = None
|
||||
updated_at: datetime | None = None
|
||||
|
||||
def target_span_days(self) -> int:
|
||||
"""Wanted duration in days. `target_days` wins when set; otherwise weeks * 7."""
|
||||
return self.target_days if self.target_days is not None else self.target_weeks * 7
|
||||
|
||||
def window_wraps(self) -> bool:
|
||||
"""Whether (end_month, end_day) sorts before (start_month, start_day).
|
||||
|
||||
|
||||
@@ -14,5 +14,13 @@ class PlannedLeaveDay:
|
||||
date: date
|
||||
day_type: str # 'sjukpenning' | 'lagsta' | 'vacation'
|
||||
is_dubbeldag: bool = False # True → counts against the 60-day dubbeldagar quota
|
||||
# Which `LeaveWish` produced this day (nullable: ad-hoc/legacy/unattributable
|
||||
# days have none). Lets the UI click a multi-day band on a calendar and edit
|
||||
# it as one period instead of one day at a time.
|
||||
wish_id: UUID | None = None
|
||||
# True once the user hand-edits this day. A later task makes the allocator
|
||||
# refuse to retype a pinned day on replan; this field only carries that
|
||||
# state through the stack so far.
|
||||
is_pinned: bool = False
|
||||
created_at: datetime | None = None
|
||||
updated_at: datetime | None = None
|
||||
|
||||
@@ -9,6 +9,5 @@ from uuid import UUID
|
||||
class Workspace:
|
||||
id: UUID
|
||||
name: str
|
||||
planning_goal: str = "balanced" # 'max_time' | 'max_money' | 'balanced'
|
||||
planning_mode: str = "solo" # 'solo' | 'couple' — explicit, not inferred from member count
|
||||
created_at: datetime | None = None
|
||||
|
||||
Reference in New Issue
Block a user