Files
F-r-ldraledigplannerare/frontend/tests/fixtures/analytics.ts
T
jacobh2 4b802ba0be Give the analytics overview a per-parent, per-year balance series
Each parent projection now carries one entry per calendar year from
birth to the fourth birthday: vacation earned, carried in, planned,
left, carried out and expiring under Semesterlagen's 20-day floor and
5-year carry-over, plus parental-leave days used and left at year end
with the age-4 clamp applied in the birthday year. The overview sums
them into per-year totals. Frontend types, mapper and fixtures follow.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XBRLomdLK9jF7wU7a8AA6H
2026-09-19 19:02:02 +02:00

93 lines
2.0 KiB
TypeScript

/** Shared test fixtures — Dashboard analytics (`GET /api/analytics/overview`). */
import type {
Age4Projection,
ParentalLeaveYearBalance,
ParentYearBalance,
VacationYearBalance,
WorkspaceOverview,
YearTotals,
} from '@/types'
export function makeVacationYearBalance(
overrides: Partial<VacationYearBalance> = {},
): VacationYearBalance {
return {
year: 2025,
earned: 25,
isAssumed: true,
carriedIn: 0,
plannedUse: 0,
left: 25,
carriedOut: 5,
expiring: 0,
...overrides,
}
}
export function makeParentalLeaveYearBalance(
overrides: Partial<ParentalLeaveYearBalance> = {},
): ParentalLeaveYearBalance {
return {
year: 2025,
sjukpenningUsed: 0,
lagstaUsed: 0,
sjukpenningLeft: 390,
lagstaLeft: 90,
...overrides,
}
}
export function makeParentYearBalance(
overrides: Partial<ParentYearBalance> = {},
): ParentYearBalance {
return {
personalDataUuid: 'pd-a',
childId: 'child-1',
year: 2025,
vacation: makeVacationYearBalance(),
parentalLeave: makeParentalLeaveYearBalance(),
...overrides,
}
}
export function makeYearTotals(overrides: Partial<YearTotals> = {}): YearTotals {
return {
year: 2025,
plLeft: 480,
vacationLeft: 25,
...overrides,
}
}
export function makeAge4Projection(overrides: Partial<Age4Projection> = {}): Age4Projection {
return {
personalDataUuid: 'pd-a',
childId: 'child-1',
birthDate: '2025-06-01',
fourthBirthday: '2029-06-01',
totalDays: 240,
daysUsed: 30,
plannedDaysBeforeB4: 10,
projectedLeftAtB4: 200,
savableAfterB4: 96,
expiringAtB4: 60,
savableCapAtB4: 96,
yearBalances: [],
...overrides,
}
}
export function makeWorkspaceOverview(overrides: Partial<WorkspaceOverview> = {}): WorkspaceOverview {
return {
workspaceId: 'ws-1',
childId: 'child-1',
parentProjections: [],
combinedDaysUsed: 30,
combinedDaysLeft: 270,
combinedExpiringAtB4: 100,
yearTotals: [],
...overrides,
}
}