Rework balances around per-parent days left and deduce the partner from FK

Manual entry now takes one parent's sjukpenningnivå, lägstanivå and
dubbeldagar left (plus optional reserved days) and derives the rest in
build_snapshot, shared with the scraper. The scraper also reads the
family panel and exposes a partner deduction; with two parents it is
saved as a 'deduced' snapshot (migration 002). Parent count is the single
source of entitlement: one member gets 480 days and 96 savable at age 4,
two get 240 and 48 each. Workspaces are capped at two parents.

Also lands the in-flight squash of migrations 002–011 into the initial
schema and the removal of planning_mode.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 12:27:29 +02:00
parent 375bc64f2f
commit e4719cb9ae
71 changed files with 5705 additions and 1859 deletions
+15
View File
@@ -51,6 +51,21 @@ class LeaveWish:
# completely unmodified.
window_mode: str = "fixed" # 'fixed' | 'flexible'
# §Decision A (co-leave, 2026-09-18 correction) — dubbeldagar are OPT-IN,
# never automatic, even when `parent_mode == 'both'` and the child is
# still inside the 15-month dubbeldagar window with quota left. Only set
# when the user has explicitly requested them for this wish. NOTE: no
# frontend exposes this yet -- the period editor's dubbeldag checkbox is
# not built, and there is no `wantsDubbeldag` in the TS types, so today
# the flag is only reachable through the API. When that UI lands it must
# show the checkbox only where `WindowOutcome.dubbeldagar_legally_available`
# says they legally could apply -- see allocation_service.py. Defaults to False so every
# existing wish (and every wish that never opts in) gets the new
# PL+vacation co-leave behaviour instead of dubbeldagar. Meaningless
# outside `parent_mode == 'both'` -- `LeaveWishService._validate` rejects
# setting it otherwise.
wants_dubbeldag: bool = False
# Provenance of `name`: when a wish is created from a preset (Sommar,
# Jullov, Höstlov, ...) this holds the i18n message key that produced the
# translated string stored in `name` (e.g. "wishEditor.presetSommar").
+1 -1
View File
@@ -30,7 +30,7 @@ class ParentalLeaveFetch:
personal_data_uuid: UUID
workspace_id: UUID
child_id: UUID
source: str # 'scraped' | 'manual'
source: str # 'scraped' | 'manual' | 'deduced'
fetched_at: datetime
total_days: int
days_used: int
-1
View File
@@ -9,5 +9,4 @@ from uuid import UUID
class Workspace:
id: UUID
name: str
planning_mode: str = "solo" # 'solo' | 'couple' — explicit, not inferred from member count
created_at: datetime | None = None