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:
@@ -1,8 +1,8 @@
|
||||
"""HTTP routes for leave wishes.
|
||||
|
||||
Routers stay thin: validate via Pydantic, call the service, map domain errors
|
||||
to HTTP. Business logic (recurrence/parent_mode/goal_override validation,
|
||||
month-day range checks) lives in LeaveWishService. See PLANNING_ENGINE_SPEC.md §4.
|
||||
to HTTP. Business logic (recurrence/parent_mode validation, month-day range
|
||||
checks) lives in LeaveWishService. See PLANNING_ENGINE_SPEC.md §4.
|
||||
"""
|
||||
|
||||
from uuid import UUID
|
||||
@@ -35,13 +35,13 @@ async def create_leave_wish(
|
||||
window_end_month=payload.window_end_month,
|
||||
window_end_day=payload.window_end_day,
|
||||
target_weeks=payload.target_weeks,
|
||||
target_days=payload.target_days,
|
||||
recurrence=payload.recurrence,
|
||||
first_year=payload.first_year,
|
||||
last_year=payload.last_year,
|
||||
priority=payload.priority,
|
||||
parent_mode=payload.parent_mode,
|
||||
parent_personal_data_uuid=payload.parent_personal_data_uuid,
|
||||
goal_override=payload.goal_override,
|
||||
window_mode=payload.window_mode,
|
||||
)
|
||||
except ValidationError as exc:
|
||||
@@ -77,13 +77,13 @@ async def update_leave_wish(
|
||||
window_end_month=payload.window_end_month,
|
||||
window_end_day=payload.window_end_day,
|
||||
target_weeks=payload.target_weeks,
|
||||
target_days=payload.target_days,
|
||||
recurrence=payload.recurrence,
|
||||
first_year=payload.first_year,
|
||||
last_year=payload.last_year,
|
||||
priority=payload.priority,
|
||||
parent_mode=payload.parent_mode,
|
||||
parent_personal_data_uuid=payload.parent_personal_data_uuid,
|
||||
goal_override=payload.goal_override,
|
||||
window_mode=payload.window_mode,
|
||||
_clear_child_id="child_id" in fields_set and payload.child_id is None,
|
||||
_clear_last_year="last_year" in fields_set and payload.last_year is None,
|
||||
@@ -91,10 +91,10 @@ async def update_leave_wish(
|
||||
"parent_personal_data_uuid" in fields_set
|
||||
and payload.parent_personal_data_uuid is None
|
||||
),
|
||||
_clear_goal_override=("goal_override" in fields_set and payload.goal_override is None),
|
||||
_clear_name_message_key=(
|
||||
"name_message_key" in fields_set and payload.name_message_key is None
|
||||
),
|
||||
_clear_target_days="target_days" in fields_set and payload.target_days is None,
|
||||
)
|
||||
except ValidationError as exc:
|
||||
raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc
|
||||
|
||||
Reference in New Issue
Block a user