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
@@ -45,6 +45,7 @@ class SQLiteLeaveWishRepository(LeaveWishRepository):
else None
),
window_mode=row["window_mode"],
wants_dubbeldag=bool(row["wants_dubbeldag"]),
created_at=datetime.fromisoformat(row["created_at"]),
updated_at=datetime.fromisoformat(row["updated_at"]),
)
@@ -60,8 +61,8 @@ class SQLiteLeaveWishRepository(LeaveWishRepository):
window_start_month, window_start_day, window_end_month, window_end_day,
target_weeks, target_days, recurrence, first_year, last_year,
priority, parent_mode, parent_personal_data_uuid,
window_mode, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
window_mode, wants_dubbeldag, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
str(item.id),
@@ -86,6 +87,7 @@ class SQLiteLeaveWishRepository(LeaveWishRepository):
else None
),
item.window_mode,
int(item.wants_dubbeldag),
item.created_at.isoformat(),
item.updated_at.isoformat(),
),
@@ -117,7 +119,7 @@ class SQLiteLeaveWishRepository(LeaveWishRepository):
window_end_month = ?, window_end_day = ?,
target_weeks = ?, target_days = ?, recurrence = ?, first_year = ?, last_year = ?,
priority = ?, parent_mode = ?, parent_personal_data_uuid = ?,
window_mode = ?, updated_at = ?
window_mode = ?, wants_dubbeldag = ?, updated_at = ?
WHERE id = ?
""",
(
@@ -141,6 +143,7 @@ class SQLiteLeaveWishRepository(LeaveWishRepository):
else None
),
item.window_mode,
int(item.wants_dubbeldag),
item.updated_at.isoformat(),
str(id),
),
@@ -25,7 +25,6 @@ class SQLiteWorkspaceRepository(WorkspaceRepository):
return Workspace(
id=UUID(row["id"]),
name=row["name"],
planning_mode=row["planning_mode"],
created_at=datetime.fromisoformat(row["created_at"]),
)
@@ -33,13 +32,12 @@ class SQLiteWorkspaceRepository(WorkspaceRepository):
item.created_at = item.created_at or datetime.now()
await self._conn.execute(
"""
INSERT INTO workspace (id, name, planning_mode, created_at)
VALUES (?, ?, ?, ?)
INSERT INTO workspace (id, name, created_at)
VALUES (?, ?, ?)
""",
(
str(item.id),
item.name,
item.planning_mode,
item.created_at.isoformat(),
),
)
@@ -53,8 +51,8 @@ class SQLiteWorkspaceRepository(WorkspaceRepository):
async def update(self, id: UUID, item: Workspace) -> Workspace:
cursor = await self._conn.execute(
"UPDATE workspace SET name = ?, planning_mode = ? WHERE id = ?",
(item.name, item.planning_mode, str(id)),
"UPDATE workspace SET name = ? WHERE id = ?",
(item.name, str(id)),
)
await commit(self._conn)
if cursor.rowcount == 0: