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:
2026-09-15 20:28:06 +02:00
parent 7f516f2cab
commit cc3ced905e
59 changed files with 1427 additions and 740 deletions
+2 -18
View File
@@ -188,7 +188,6 @@ describe('API response mappers (snake_case → camelCase)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
created_at: '2026-06-14T17:09:47',
updated_at: '2026-06-14T17:09:47',
},
@@ -265,7 +264,6 @@ describe('API response mappers (snake_case → camelCase)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
created_at: '2026-06-14T17:09:47',
updated_at: '2026-06-14T17:09:47',
}
@@ -322,7 +320,6 @@ describe('API response mappers (snake_case → camelCase)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
created_at: '2026-06-14T17:09:47',
updated_at: '2026-06-14T17:09:47',
}
@@ -361,7 +358,7 @@ describe('API response mappers (snake_case → camelCase)', () => {
const rawResponse = {
id: 'ws1',
name: 'My Workspace',
planning_goal: 'max_time' as const,
planning_mode: 'couple' as const,
created_at: '2026-06-14T17:09:47',
}
@@ -375,7 +372,7 @@ describe('API response mappers (snake_case → camelCase)', () => {
expect(result.id).toBe('ws1')
expect(result.name).toBe('My Workspace')
expect(result.planningGoal).toBe('max_time')
expect(result.planningMode).toBe('couple')
expect(result.createdAt).toBe('2026-06-14T17:09:47')
})
})
@@ -666,7 +663,6 @@ describe('endpoint functions (representative coverage)', () => {
json: async () => ({
id: 'ws1',
name: 'Home',
planning_goal: 'balanced',
planning_mode: 'solo',
created_at: '2026-01-01',
}),
@@ -685,7 +681,6 @@ describe('endpoint functions (representative coverage)', () => {
json: async () => ({
id: 'ws1',
name: 'New name',
planning_goal: 'max_money',
planning_mode: 'couple',
created_at: '2026-01-01',
}),
@@ -693,17 +688,14 @@ describe('endpoint functions (representative coverage)', () => {
const result = await api.updateWorkspace('ws1', {
name: 'New name',
planningGoal: 'max_money',
planningMode: 'couple',
})
expect(lastRequest()).toEqual({ url: '/api/workspace/ws1', method: 'PUT' })
expect(lastRequestBody()).toEqual({
name: 'New name',
planning_goal: 'max_money',
planning_mode: 'couple',
})
expect(result.planningGoal).toBe('max_money')
expect(result.planningMode).toBe('couple')
})
@@ -871,7 +863,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
created_at: '2026-01-01',
updated_at: '2026-01-01',
}),
@@ -908,7 +899,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
created_at: '2026-01-01',
updated_at: '2026-01-01',
}),
@@ -944,7 +934,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 2,
parent_mode: 'specific',
parent_personal_data_uuid: 'pd1',
goal_override: 'max_time',
window_mode: 'fixed',
created_at: '2026-01-01',
updated_at: '2026-01-01',
@@ -965,7 +954,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 2,
parentMode: 'specific',
parentPersonalDataUuid: 'pd1',
goalOverride: 'max_time',
})
expect(lastRequestBody()).toEqual({
@@ -982,7 +970,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 2,
parent_mode: 'specific',
parent_personal_data_uuid: 'pd1',
goal_override: 'max_time',
})
})
@@ -1009,7 +996,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
window_mode: 'flexible',
created_at: '2026-01-01',
updated_at: '2026-01-01',
@@ -1053,7 +1039,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
window_mode: 'fixed',
created_at: '2026-01-01',
updated_at: '2026-01-01',
@@ -1095,7 +1080,6 @@ describe('endpoint functions (representative coverage)', () => {
priority: 1,
parent_mode: 'either',
parent_personal_data_uuid: null,
goal_override: null,
window_mode: 'flexible',
created_at: '2026-01-01',
updated_at: '2026-01-01',
-7
View File
@@ -218,7 +218,6 @@ interface RawLeaveWish {
priority: number
parent_mode: 'either' | 'both' | 'specific'
parent_personal_data_uuid: string | null
goal_override: 'max_time' | 'max_money' | 'balanced' | null
window_mode: 'fixed' | 'flexible'
created_at: string | null
updated_at: string | null
@@ -242,7 +241,6 @@ function toLeaveWish(raw: RawLeaveWish): LeaveWish {
priority: raw.priority,
parentMode: raw.parent_mode,
parentPersonalDataUuid: raw.parent_personal_data_uuid,
goalOverride: raw.goal_override,
windowMode: raw.window_mode ?? 'fixed',
createdAt: raw.created_at,
updatedAt: raw.updated_at,
@@ -429,7 +427,6 @@ function toPersonalData(raw: RawPersonalData): PersonalData {
interface RawWorkspace {
id: string
name: string
planning_goal: 'max_time' | 'max_money' | 'balanced'
planning_mode: 'solo' | 'couple'
created_at: string
}
@@ -438,7 +435,6 @@ function toWorkspace(raw: RawWorkspace): Workspace {
return {
id: raw.id,
name: raw.name,
planningGoal: raw.planning_goal,
planningMode: raw.planning_mode,
createdAt: raw.created_at,
}
@@ -632,7 +628,6 @@ export async function updateWorkspace(
method: 'PUT',
body: JSON.stringify({
name: req.name,
planning_goal: req.planningGoal,
planning_mode: req.planningMode,
}),
})) as RawWorkspace
@@ -773,7 +768,6 @@ export async function createLeaveWish(payload: LeaveWishCreateRequest): Promise<
priority: payload.priority ?? 1,
parent_mode: payload.parentMode ?? 'either',
parent_personal_data_uuid: payload.parentPersonalDataUuid ?? null,
goal_override: payload.goalOverride ?? null,
window_mode: payload.windowMode ?? 'fixed',
}),
})) as RawLeaveWish
@@ -801,7 +795,6 @@ export async function updateLeaveWish(
if (payload.parentPersonalDataUuid !== undefined) {
body.parent_personal_data_uuid = payload.parentPersonalDataUuid
}
if (payload.goalOverride !== undefined) body.goal_override = payload.goalOverride
if (payload.windowMode !== undefined) body.window_mode = payload.windowMode
const raw = (await apiFetch(`/leave-wishes/${id}`, {