Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

feat(vacay): comp/flex leave type (#1074) + configurable-year backend (#737)

Mauricec475e5b04c2b
diff --git a/client/src/components/Vacay/VacayCalendar.tsx b/client/src/components/Vacay/VacayCalendar.tsx
index 971cd4da0..2938cf066 100644
--- a/client/src/components/Vacay/VacayCalendar.tsx
+++ b/client/src/components/Vacay/VacayCalendar.tsx
@@ -5,11 +5,11 @@ import { isWeekend } from './holidays'
import { tripsApi } from '../../api/client'
import VacayMonthCard from './VacayMonthCard'
import type { VacayEntry } from '../../types'
-import { Building2, MousePointer2 } from 'lucide-react'
+import { Building2, MousePointer2, Clock } from 'lucide-react'
type VacayMode = 'vacation' | 'company'
type HoverTip = { date: string; top: number; left: number }
-export type SharedDayMark = { color: string; name: string; fraction?: number; company?: boolean }
+export type SharedDayMark = { color: string; name: string; fraction?: number; company?: boolean; kind?: 'vacation' | 'comp' }
export default function VacayCalendar() {
const { t, locale } = useTranslation()
@@ -18,6 +18,9 @@ export default function VacayCalendar() {
// Half-day is a per-person modifier on the vacation action, not a mode: with it
// on, clicking a day logs (or converts) it as a 0.5 day for the selected person.
const [halfDay, setHalfDay] = useState(false)
+ // Comp/Flex day is a second per-person modifier (#1074), orthogonal to half-day:
+ // with it on, clicking a day logs it as kind='comp' (does not cost the entitlement).
+ const [compDay, setCompDay] = useState(false)
const companyMode = mode === 'company'
const [tripDates, setTripDates] = useState<Set<string>>(new Set())
const [tip, setTip] = useState<HoverTip | null>(null)
@@ -68,7 +71,7 @@ export default function VacayCalendar() {
sharedCalendars.filter(c => !c.hidden).forEach(cal => {
cal.entries.forEach(e => {
if (!map[e.date]) map[e.date] = []
- map[e.date].push({ color: cal.color, name: cal.owner_name, fraction: e.fraction })
+ map[e.date].push({ color: cal.color, name: cal.owner_name, fraction: e.fraction, kind: e.kind })
})
cal.companyHolidays.forEach(h => {
if (!map[h.date]) map[h.date] = []
@@ -90,8 +93,8 @@ export default function VacayCalendar() {
}
if (blockWeekends && isWeekend(dateStr, weekendDays)) return
if (companyHolidaysEnabled && companyHolidaySet.has(dateStr)) return
- await toggleEntry(dateStr, selectedUserId || undefined, halfDay ? 0.5 : 1)
- }, [mode, halfDay, toggleEntry, toggleCompanyHoliday, companyHolidaySet, blockWeekends, weekendDays, companyHolidaysEnabled, selectedUserId])
+ await toggleEntry(dateStr, selectedUserId || undefined, halfDay ? 0.5 : 1, compDay ? 'comp' : 'vacation')
+ }, [mode, halfDay, compDay, toggleEntry, toggleCompanyHoliday, companyHolidaySet, blockWeekends, weekendDays, companyHolidaysEnabled, selectedUserId])
// Cells with a half day or a shared overlay report a hover, so the tooltip
// appears exactly when there's something to explain. Fixed-positioned at the
@@ -109,6 +112,13 @@ export default function VacayCalendar() {
const tipSchool = (Array.isArray(tipHolidayRaw) ? tipHolidayRaw : tipHolidayRaw ? [tipHolidayRaw] : []).filter(h => h.type === 'school_holiday')
const tipDate = tip ? new Intl.DateTimeFormat(locale, { weekday: 'short', day: 'numeric', month: 'long' }).format(new Date(tip.date + 'T00:00:00')) : ''
+ // Label for a day's leave type + fraction (#552/#1074): full/half vacation or comp/flex.
+ const dayTypeLabel = (fraction: number | undefined, kind: string | undefined) => {
+ const half = (fraction ?? 1) === 0.5
+ if (kind === 'comp') return half ? t('vacay.compHalf') : t('vacay.modeComp')
+ return half ? t('vacay.modeHalf') : t('vacay.fullDay')
+ }
+
return (
<div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-[18px]" style={{ paddingBottom: 'calc(var(--bottom-nav-h, 0px) + 80px)' }}>
@@ -145,13 +155,13 @@ export default function VacayCalendar() {
<div style={{ padding: '8px 11px', minWidth: 132 }}>
<div className="capitalize" style={{ fontSize: 10, fontWeight: 700, letterSpacing: '0.02em', color: 'var(--vg-ink3)', marginBottom: 5 }}>{tipDate}</div>
{(tipEntries ?? []).map((e, i) => {
- const isHalf = (e.fraction ?? 1) === 0.5
+ const emphasized = (e.fraction ?? 1) === 0.5 || e.kind === 'comp'
return (
<div key={i} className="flex items-center gap-2" style={{ marginTop: i ? 4 : 0 }}>
<span className="w-2 h-2 rounded-full shrink-0" style={{ background: e.person_color || '#6366f1' }} />
<span style={{ fontSize: 12, fontWeight: 600, color: 'var(--vg-ink)' }}>{e.person_name}</span>
- <span style={{ marginLeft: 'auto', paddingLeft: 12, fontSize: 11, fontWeight: 700, color: isHalf ? 'var(--vg-ink)' : 'var(--vg-ink3)' }}>
- {isHalf ? t('vacay.modeHalf') : t('vacay.fullDay')}
+ <span style={{ marginLeft: 'auto', paddingLeft: 12, fontSize: 11, fontWeight: 700, color: emphasized ? 'var(--vg-ink)' : 'var(--vg-ink3)' }}>
+ {dayTypeLabel(e.fraction, e.kind)}
</span>
</div>
)
@@ -162,7 +172,7 @@ export default function VacayCalendar() {
<span className="w-2 h-2 rounded-full shrink-0" style={{ border: `2px solid ${m.color}` }} />
<span style={{ fontSize: 12, fontWeight: 600, color: 'var(--vg-ink)' }}>{m.name}</span>
<span style={{ marginLeft: 'auto', paddingLeft: 12, fontSize: 11, fontWeight: 700, color: 'var(--vg-ink3)' }}>
- {m.company ? t('vacay.companyHoliday') : (m.fraction ?? 1) === 0.5 ? t('vacay.modeHalf') : t('vacay.fullDay')}
+ {m.company ? t('vacay.companyHoliday') : dayTypeLabel(m.fraction, m.kind)}
</span>
</div>
))}
@@ -213,9 +223,21 @@ export default function VacayCalendar() {
</button>
)}
- {/* Divider — the half-day switch is a modifier, not a mode. */}
+ {/* Divider — comp/flex and half-day are modifiers, not modes. */}
<span className="w-px self-stretch my-0.5" style={{ background: 'var(--vg-line)' }} aria-hidden />
+ <button
+ onClick={() => setCompDay(v => !v)}
+ title={t('vacay.modeCompHint')}
+ aria-pressed={compDay}
+ className="flex items-center gap-1.5 pl-2 pr-2.5 sm:pl-2.5 sm:pr-3 py-1.5 rounded-full text-[11px] sm:text-xs font-semibold transition-[background-color,color] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]"
+ style={compDay
+ ? { background: 'var(--vg-ink)', color: 'var(--vg-bg)' }
+ : { background: 'transparent', color: 'var(--vg-ink3)' }}>
+ <Clock size={13} />
+ {t('vacay.modeComp')}
+ </button>
+
<button
onClick={() => setHalfDay(v => !v)}
title={t('vacay.modeHalfHint')}
diff --git a/client/src/components/Vacay/VacayMonthCard.tsx b/client/src/components/Vacay/VacayMonthCard.tsx
index 4934dafd6..0e8415f8a 100644
--- a/client/src/components/Vacay/VacayMonthCard.tsx
+++ b/client/src/components/Vacay/VacayMonthCard.tsx
@@ -58,6 +58,10 @@ export default function VacayMonthCard({
// Soften the person colour a touch so the filled days don't look overly loud
// against the light glass surface (the raw colour reads very saturated).
const fill = (c?: string) => `color-mix(in srgb, ${pc(c)} 78%, transparent)`
+ // Comp/Flex days (#1074) render as a diagonal hatch of the person colour (Version B),
+ // so a comp segment reads as "reserved but free" — distinct from a solid vacation fill.
+ const hatch = (c?: string) => `repeating-linear-gradient(45deg, ${fill(c)} 0 3px, transparent 3px 6px)`
+ const segFill = (e: VacayEntry) => (e.kind === 'comp' ? hatch(e.person_color) : fill(e.person_color))
const todayStr = useMemo(() => {
const d = new Date()
@@ -120,8 +124,9 @@ export default function VacayMonthCard({
// Cell fill — people win, then company, then holiday (keeps each calendar's own colour).
let background = 'transparent'
- if (dayEntries.length === 1) background = fill(dayEntries[0].person_color)
- else if (dayEntries.length === 2) background = `linear-gradient(135deg, ${fill(dayEntries[0].person_color)} 50%, ${fill(dayEntries[1].person_color)} 50%)`
+ if (dayEntries.length === 1) background = segFill(dayEntries[0])
+ // 2 people render via the diagonal overlay below, so each half can be a solid
+ // vacation fill or a hatched comp fill independently (#1074).
else if (dayEntries.length === 0 && isCompany) background = 'rgba(245,158,11,0.22)'
else if (dayEntries.length === 0 && publicHoliday) background = `color-mix(in srgb, ${publicHoliday.color} 22%, transparent)`
// A plain school-break day gets a soft wash of its calendar colour so a run of
@@ -165,20 +170,27 @@ export default function VacayMonthCard({
if (hasEntries || sharedColors.length > 0 || schoolHolidayMarkers.length > 0) onCellHover?.(null, null)
}}
>
- {/* 3+ people: quadrant overlay at full colour (1 & 2 use the cell background). */}
+ {/* 2 people: diagonal split — each half solid (vacation) or hatched (comp) (#1074). */}
+ {dayEntries.length === 2 && (
+ <div className="absolute inset-0 overflow-hidden" style={{ borderRadius: 10 }}>
+ <div className="absolute inset-0" style={{ background: segFill(dayEntries[0]), clipPath: 'polygon(0 0, 100% 0, 0 100%)' }} />
+ <div className="absolute inset-0" style={{ background: segFill(dayEntries[1]), clipPath: 'polygon(100% 0, 100% 100%, 0 100%)' }} />
+ </div>
+ )}
+ {/* 3+ people: quadrant overlay (1 uses the cell background, 2 the diagonal above). */}
{dayEntries.length === 3 && (
<div className="absolute inset-0 overflow-hidden" style={{ borderRadius: 10 }}>
- <div className="absolute top-0 left-0 w-1/2 h-full" style={{ backgroundColor: fill(dayEntries[0].person_color) }} />
- <div className="absolute top-0 right-0 w-1/2 h-1/2" style={{ backgroundColor: fill(dayEntries[1].person_color) }} />
- <div className="absolute bottom-0 right-0 w-1/2 h-1/2" style={{ backgroundColor: fill(dayEntries[2].person_color) }} />
+ <div className="absolute top-0 left-0 w-1/2 h-full" style={{ background: segFill(dayEntries[0]) }} />
+ <div className="absolute top-0 right-0 w-1/2 h-1/2" style={{ background: segFill(dayEntries[1]) }} />
+ <div className="absolute bottom-0 right-0 w-1/2 h-1/2" style={{ background: segFill(dayEntries[2]) }} />
</div>
)}
{dayEntries.length >= 4 && (
<div className="absolute inset-0 overflow-hidden" style={{ borderRadius: 10 }}>
- <div className="absolute top-0 left-0 w-1/2 h-1/2" style={{ backgroundColor: fill(dayEntries[0].person_color) }} />
- <div className="absolute top-0 right-0 w-1/2 h-1/2" style={{ backgroundColor: fill(dayEntries[1].person_color) }} />
- <div className="absolute bottom-0 left-0 w-1/2 h-1/2" style={{ backgroundColor: fill(dayEntries[2].person_color) }} />
- <div className="absolute bottom-0 right-0 w-1/2 h-1/2" style={{ backgroundColor: fill(dayEntries[3].person_color) }} />
+ <div className="absolute top-0 left-0 w-1/2 h-1/2" style={{ background: segFill(dayEntries[0]) }} />
+ <div className="absolute top-0 right-0 w-1/2 h-1/2" style={{ background: segFill(dayEntries[1]) }} />
+ <div className="absolute bottom-0 left-0 w-1/2 h-1/2" style={{ background: segFill(dayEntries[2]) }} />
+ <div className="absolute bottom-0 right-0 w-1/2 h-1/2" style={{ background: segFill(dayEntries[3]) }} />
</div>
)}
diff --git a/client/src/mobile/screens/vacay/MVacay.tsx b/client/src/mobile/screens/vacay/MVacay.tsx
index a8e243817..907642ce3 100644
--- a/client/src/mobile/screens/vacay/MVacay.tsx
+++ b/client/src/mobile/screens/vacay/MVacay.tsx
@@ -1,4 +1,4 @@
-import { Building2, ChevronLeft, ChevronRight, Eye, Minus, PenLine, Pencil, Plus, Settings2, Share2, ShieldCheck, Trash2, Unlink, UserPlus } from 'lucide-react'
+import { Building2, ChevronLeft, ChevronRight, Clock, Eye, Minus, PenLine, Pencil, Plus, Settings2, Share2, ShieldCheck, Trash2, Unlink, UserPlus } from 'lucide-react'
import type { LucideIcon } from 'lucide-react'
import MSheet from '../../components/MSheet'
import MIconBtn from '../../components/MIconBtn'
@@ -261,8 +261,20 @@ export default function MVacay() {
{t('vacay.modeCompany')}
</button>
)}
- {/* Divider — the half-day switch modifies the selected person's logging, it isn't a mode. */}
+ {/* Divider — comp/flex and half-day modify the selected person's logging, they aren't modes. */}
<span className="mx-[1px] h-5 w-px self-center bg-[color:var(--m-shbr)]" aria-hidden />
+ <button
+ type="button"
+ onClick={() => v.setCompDay(c => !c)}
+ aria-pressed={v.compDay}
+ aria-label={t('vacay.modeComp')}
+ title={t('vacay.modeCompHint')}
+ className={`flex h-9 w-9 flex-none items-center justify-center rounded-full ${
+ v.compDay ? 'bg-m-act text-m-actfg' : 'bg-[color:var(--m-ic)] text-m-muted'
+ }`}
+ >
+ <Clock size={16} strokeWidth={2.2} />
+ </button>
<button
type="button"
onClick={() => v.setHalfDay(h => !h)}
diff --git a/client/src/mobile/screens/vacay/MVacayMonth.tsx b/client/src/mobile/screens/vacay/MVacayMonth.tsx
index 576eb6fb1..d33c25e48 100644
--- a/client/src/mobile/screens/vacay/MVacayMonth.tsx
+++ b/client/src/mobile/screens/vacay/MVacayMonth.tsx
@@ -1,5 +1,5 @@
import { schoolHolidayBand } from '../../../components/Vacay/holidayVisual'
-import { dayVisual, localDateStr, monthLead, type DayVisualContext } from './vacayDayModel'
+import { dayVisual, hatchTint, localDateStr, monthLead, type DayVisualContext } from './vacayDayModel'
interface MVacayMonthProps {
year: number
@@ -45,7 +45,23 @@ export default function MVacayMonth({
}`}
style={{ background: visual.background, color: visual.numColor, boxShadow: visual.boxShadow }}
>
- {day}
+ {/* 2+ people: equal-width segment overlays, each solid (vacation) or hatched (comp) (#1074). */}
+ {visual.segments && visual.segments.length > 1 && (
+ <div className="absolute inset-0 overflow-hidden" style={{ borderRadius: 'inherit' }} aria-hidden>
+ {visual.segments.map((seg, si) => (
+ <div
+ key={si}
+ className="absolute top-0 h-full"
+ style={{
+ left: `${(si * 100) / visual.segments!.length}%`,
+ width: `${100 / visual.segments!.length}%`,
+ background: seg.comp ? hatchTint(seg.color) : seg.color,
+ }}
+ />
+ ))}
+ </div>
+ )}
+ <span className="relative z-[1]">{day}</span>
{tripDates.has(dateStr) && (
<span
aria-hidden
diff --git a/client/src/mobile/screens/vacay/useMVacay.ts b/client/src/mobile/screens/vacay/useMVacay.ts
index 00221e8bf..07b980385 100644
--- a/client/src/mobile/screens/vacay/useMVacay.ts
+++ b/client/src/mobile/screens/vacay/useMVacay.ts
@@ -42,6 +42,8 @@ export function useMVacay() {
const [mode, setMode] = useState<MVacayMode>('vacation')
// Half-day modifier: when on, taps log the selected person's day as 0.5 (#552).
const [halfDay, setHalfDay] = useState(false)
+ // Comp/Flex day modifier (#1074): when on, taps log the day as kind='comp' (free).
+ const [compDay, setCompDay] = useState(false)
const [sheet, setSheet] = useState<MVacaySheet>(null)
const [tripDates, setTripDates] = useState<Set<string>>(new Set())
@@ -155,8 +157,8 @@ export function useMVacay() {
}
if (blockWeekends && isWeekend(dateStr, weekendDays)) return
if (companyHolidaysEnabled && companyHolidaySet.has(dateStr)) return
- await toggleEntry(dateStr, selectedUserId || undefined, halfDay ? 0.5 : 1)
- }, [view, mode, halfDay, companyHolidaysEnabled, blockWeekends, weekendDays, companyHolidaySet, toggleEntry, toggleCompanyHoliday, selectedUserId])
+ await toggleEntry(dateStr, selectedUserId || undefined, halfDay ? 0.5 : 1, compDay ? 'comp' : 'vacation')
+ }, [view, mode, halfDay, compDay, companyHolidaysEnabled, blockWeekends, weekendDays, companyHolidaySet, toggleEntry, toggleCompanyHoliday, selectedUserId])
// Entitlement stepper: never below what is already used this year
// (carried-over days cover the difference when used > entitlement).
@@ -198,7 +200,7 @@ export function useMVacay() {
users, isFused, currentUser,
incomingInvites, acceptInvite, declineInvite,
incomingShares, toggleShareHidden,
- view, month, mode, halfDay, setHalfDay, sheet, setSheet, setMode, setMonth,
+ view, month, mode, halfDay, setHalfDay, compDay, setCompDay, sheet, setSheet, setMode, setMonth,
tripDates, tripDotColor,
blockWeekends, companyHolidaysEnabled, holidaysEnabled, weekStart, weekendDays,
dayCtx, monthNamesShort, monthNameLong,
diff --git a/client/src/mobile/screens/vacay/vacayDayModel.ts b/client/src/mobile/screens/vacay/vacayDayModel.ts
index 3d4d9951b..a0f209056 100644
--- a/client/src/mobile/screens/vacay/vacayDayModel.ts
+++ b/client/src/mobile/screens/vacay/vacayDayModel.ts
@@ -11,6 +11,10 @@ export interface DayVisual {
boxShadow?: string
// At least one person logged this day as a half day (#552) — the cell shows a ½ badge.
half?: boolean
+ // Per-person fill segments for this day (#1074): each carries the person's tint and
+ // whether they logged a comp/flex day (hatched, kind='comp') vs. a vacation day
+ // (solid). Set only when someone is off; the cell renders overlays for 2+ people.
+ segments?: { color: string; comp: boolean }[]
// Colours of the school-holiday calendars covering this day — drawn as a rounded
// accent band under the number, on top of whatever fill the cell already has.
school?: string[]
@@ -72,6 +76,11 @@ export function holidayInk(color: string): string {
return `hsl(${hsl.h} ${s}% 42%)`
}
+/** Diagonal hatch of a tint for comp/flex days (#1074), matching the desktop card. */
+export function hatchTint(color: string): string {
+ return `repeating-linear-gradient(45deg, ${color} 0 2.5px, transparent 2.5px 5px)`
+}
+
/** Hard split background when several persons logged the same day. */
export function splitBackground(colors: string[]): string {
const n = colors.length
@@ -104,11 +113,14 @@ function baseDayVisual(dateStr: string, dayOfWeek: number, ctx: DayVisualContext
}
const entries = ctx.entryMap[dateStr]
if (entries && entries.length > 0) {
- const tints = entries.map(e => personTint(e.person_color || FALLBACK_PERSON_COLOR))
- // The fill still shows WHO is off; half days (#552) keep it and add a corner
- // dot, so a half day never looks like a two-person split. Only set `half` when
- // true so full days keep their exact { background, numColor } shape.
- const visual: DayVisual = { background: tints.length === 1 ? tints[0] : splitBackground(tints), numColor: '#101013' }
+ // The fill still shows WHO is off; half days (#552) keep it and add a corner dot.
+ // Comp/flex days (#1074) hatch their segment. 1 person fills the cell directly
+ // (solid or hatched); several render segment overlays, so the background stays
+ // transparent underneath them.
+ const segments = entries.map(e => ({ color: personTint(e.person_color || FALLBACK_PERSON_COLOR), comp: e.kind === 'comp' }))
+ const single = segments.length === 1
+ const background = single ? (segments[0].comp ? hatchTint(segments[0].color) : segments[0].color) : 'transparent'
+ const visual: DayVisual = { background, numColor: '#101013', segments }
if (entries.some(e => (e.fraction ?? 1) === 0.5)) visual.half = true
return withSchool(visual)
}
diff --git a/client/src/store/vacayStore.ts b/client/src/store/vacayStore.ts
index fcae85df7..035322fa1 100644
--- a/client/src/store/vacayStore.ts
+++ b/client/src/store/vacayStore.ts
@@ -75,7 +75,7 @@ interface VacayApi {
addYear: (year: number) => Promise<VacayYearsResponse>
removeYear: (year: number) => Promise<VacayYearsResponse>
getEntries: (year: number) => Promise<VacayEntriesResponse>
- toggleEntry: (date: string, targetUserId?: number, fraction?: 0.5 | 1) => Promise<unknown>
+ toggleEntry: (date: string, targetUserId?: number, fraction?: 0.5 | 1, kind?: 'vacation' | 'comp') => Promise<unknown>
toggleCompanyHoliday: (date: string) => Promise<unknown>
getStats: (year: number) => Promise<VacayStatsResponse>
updateStats: (year: number, days: number, targetUserId?: number) => Promise<unknown>
@@ -107,7 +107,7 @@ const api: VacayApi = {
addYear: (year) => ax.post('/addons/vacay/years', { year } satisfies VacayAddYearRequest).then((r: AxiosResponse) => r.data),
removeYear: (year) => ax.delete(`/addons/vacay/years/${year}`).then((r: AxiosResponse) => r.data),
getEntries: (year) => ax.get(`/addons/vacay/entries/${year}`).then((r: AxiosResponse) => r.data),
- toggleEntry: (date, targetUserId, fraction) => ax.post('/addons/vacay/entries/toggle', { date, target_user_id: targetUserId, fraction } satisfies VacayToggleEntryRequest).then((r: AxiosResponse) => r.data),
+ toggleEntry: (date, targetUserId, fraction, kind) => ax.post('/addons/vacay/entries/toggle', { date, target_user_id: targetUserId, fraction, kind } satisfies VacayToggleEntryRequest).then((r: AxiosResponse) => r.data),
toggleCompanyHoliday: (date) => ax.post('/addons/vacay/entries/company-holiday', { date } satisfies VacayCompanyHolidayRequest).then((r: AxiosResponse) => r.data),
getStats: (year) => ax.get(`/addons/vacay/stats/${year}`).then((r: AxiosResponse) => r.data),
updateStats: (year, days, targetUserId) => ax.put(`/addons/vacay/stats/${year}`, { vacation_days: days, target_user_id: targetUserId } satisfies VacayUpdateStatsRequest).then((r: AxiosResponse) => r.data),
@@ -199,7 +199,7 @@ interface VacayState {
addYear: (year: number) => Promise<void>
removeYear: (year: number) => Promise<void>
loadEntries: (year?: number) => Promise<void>
- toggleEntry: (date: string, targetUserId?: number, fraction?: 0.5 | 1) => Promise<void>
+ toggleEntry: (date: string, targetUserId?: number, fraction?: 0.5 | 1, kind?: 'vacation' | 'comp') => Promise<void>
toggleCompanyHoliday: (date: string) => Promise<void>
loadStats: (year?: number) => Promise<void>
updateVacationDays: (year: number, days: number, targetUserId?: number) => Promise<void>
@@ -320,26 +320,27 @@ export const useVacayStore = create<VacayState>((set, get) => ({
set({ entries: data.entries, companyHolidays: data.companyHolidays })
},
- toggleEntry: async (date: string, targetUserId?: number, fraction: 0.5 | 1 = 1) => {
+ toggleEntry: async (date: string, targetUserId?: number, fraction: 0.5 | 1 = 1, kind: 'vacation' | 'comp' = 'vacation') => {
// Optimistic: mirror the server's toggle locally so the cell reacts instantly,
- // then reconcile (stats are server-computed). Same fraction clears the day, a
- // different one converts it (full ↔ half); an empty day gets the new entry.
+ // then reconcile (stats are server-computed). Same type AND fraction clears the
+ // day, a different type or fraction converts it (#552/#1074); an empty day gets
+ // the new entry.
const userId = targetUserId ?? useAuthStore.getState().user?.id
const prevEntries = get().entries
const prevStats = get().stats
if (userId != null) {
const existing = prevEntries.find(e => e.date === date && e.user_id === userId)
- if (existing && (existing.fraction ?? 1) === fraction) {
+ if (existing && (existing.fraction ?? 1) === fraction && (existing.kind ?? 'vacation') === kind) {
set({ entries: prevEntries.filter(e => !(e.date === date && e.user_id === userId)) })
} else if (existing) {
- set({ entries: prevEntries.map(e => (e.date === date && e.user_id === userId ? { ...e, fraction } : e)) })
+ set({ entries: prevEntries.map(e => (e.date === date && e.user_id === userId ? { ...e, fraction, kind } : e)) })
} else {
const u = get().users.find(x => x.id === userId)
- set({ entries: [...prevEntries, { date, user_id: userId, fraction, person_color: u?.color || undefined, person_name: u?.username }] })
+ set({ entries: [...prevEntries, { date, user_id: userId, fraction, kind, person_color: u?.color || undefined, person_name: u?.username }] })
}
}
try {
- await api.toggleEntry(date, targetUserId, fraction)
+ await api.toggleEntry(date, targetUserId, fraction, kind)
await get().loadEntries()
await get().loadStats()
} catch (e) {
diff --git a/client/src/types.ts b/client/src/types.ts
index e3cea8172..c34ed7ac3 100644
--- a/client/src/types.ts
+++ b/client/src/types.ts
@@ -307,6 +307,9 @@ export interface VacayEntry {
// Portion of a vacation day this entry counts as: 1 = full day, 0.5 = half
// day (#552). Absent on legacy entries, which are treated as full days.
fraction?: number
+ // Leave type (#1074): 'comp' = flex/comp day (does not touch the entitlement),
+ // 'vacation' (or absent, for legacy entries) = a regular vacation day.
+ kind?: 'vacation' | 'comp'
}
// Vacay per-user stats row as returned by getStats
@@ -321,6 +324,9 @@ export interface VacayStat {
total_available: number
used: number
remaining: number
+ // Comp/flex days used this year (#1074) — informational, not deducted from the
+ // entitlement. Absent on older server builds.
+ comp_used?: number
}
export interface HolidayInfo {
@@ -356,7 +362,7 @@ export interface SharedVacayCalendar {
owner_name: string
color: string
hidden: boolean
- entries: { date: string; fraction?: number }[]
+ entries: { date: string; fraction?: number; kind?: 'vacation' | 'comp' }[]
companyHolidays: { date: string; note?: string }[]
}
diff --git a/server/src/db/migrations.ts b/server/src/db/migrations.ts
index 734f3cfb1..220934be9 100644
--- a/server/src/db/migrations.ts
+++ b/server/src/db/migrations.ts
@@ -3799,6 +3799,28 @@ function runMigrations(db: Database.Database): void {
CREATE INDEX IF NOT EXISTS idx_reservation_travelers_user ON reservation_travelers(user_id);
`);
},
+ // Comp/Flex days (#1074): a vacay entry is either a vacation day (counts toward
+ // the entitlement) or a comp/flex day (kind='comp', costs 0 — flextime/overtime
+ // offset). Orthogonal to fraction, so a half comp day is kind='comp' + fraction=0.5.
+ () => {
+ const hasKind = db.prepare("SELECT 1 FROM pragma_table_info('vacay_entries') WHERE name = 'kind'").get();
+ if (!hasKind) db.exec("ALTER TABLE vacay_entries ADD COLUMN kind TEXT NOT NULL DEFAULT 'vacation'");
+ },
+ // Configurable vacation year (#737): per-user leave-year window. 'calendar' keeps
+ // the Jan 1–Dec 31 default (unchanged for everyone); 'fiscal' starts on a fixed
+ // month/day; 'anniversary' starts on the month/day of the hire date. The year
+ // integer still names a period; the service resolves it to a [start,end) range.
+ () => {
+ db.exec(`
+ CREATE TABLE IF NOT EXISTS vacay_user_settings (
+ user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
+ year_type TEXT NOT NULL DEFAULT 'calendar',
+ year_start_month INTEGER NOT NULL DEFAULT 1,
+ year_start_day INTEGER NOT NULL DEFAULT 1,
+ hire_date TEXT
+ );
+ `);
+ },
];
if (currentVersion < migrations.length) {
diff --git a/server/src/mcp/tools/vacay.ts b/server/src/mcp/tools/vacay.ts
index ba189c587..93eb43272 100644
--- a/server/src/mcp/tools/vacay.ts
+++ b/server/src/mcp/tools/vacay.ts
@@ -254,7 +254,7 @@ export function registerVacayTools(server: McpServer, userId: number, scopes: st
async ({ date }) => {
if (isDemoUser(userId)) return demoDenied();
const planId = getActivePlanId(userId);
- const result = toggleEntry(userId, planId, date, 1, undefined);
+ const result = toggleEntry(userId, planId, date, 1, 'vacation', undefined);
return ok(result);
}
);
diff --git a/server/src/nest/plugins/host/create-rpc-host.ts b/server/src/nest/plugins/host/create-rpc-host.ts
index 6e3633cde..5b6e50301 100644
--- a/server/src/nest/plugins/host/create-rpc-host.ts
+++ b/server/src/nest/plugins/host/create-rpc-host.ts
@@ -695,7 +695,7 @@ export function createRealRpcHost(id: string, granted: ReadonlySet<string>, rout
},
// --- Vacay write: the plan is the ACTING USER's active plan (resolved host-side);
// the service broadcasts to plan users itself. ---
- vacayToggleEntry: (userId, date) => { requireAddon(ADDON_IDS.VACAY, 'vacay'); return vacayToggleEntrySvc(userId, getActivePlanId(userId), date, 1, undefined); },
+ vacayToggleEntry: (userId, date) => { requireAddon(ADDON_IDS.VACAY, 'vacay'); return vacayToggleEntrySvc(userId, getActivePlanId(userId), date, 1, 'vacation', undefined); },
vacayToggleCompanyHoliday: (userId, date, note) => {
requireAddon(ADDON_IDS.VACAY, 'vacay');
return vacayToggleCompanyHolidaySvc(getActivePlanId(userId), date, note, undefined);
diff --git a/server/src/nest/vacay/vacay.controller.ts b/server/src/nest/vacay/vacay.controller.ts
index 59042cedf..3b1c8e82f 100644
--- a/server/src/nest/vacay/vacay.controller.ts
+++ b/server/src/nest/vacay/vacay.controller.ts
@@ -185,7 +185,7 @@ export class VacayController {
@HttpCode(200)
toggleEntry(
@CurrentUser() user: User,
- @Body() body: { date?: string; target_user_id?: number | string; fraction?: number },
+ @Body() body: { date?: string; target_user_id?: number | string; fraction?: number; kind?: string },
@Headers('x-socket-id') socketId?: string,
) {
if (!body.date) {
@@ -200,7 +200,7 @@ export class VacayController {
}
userId = tid;
}
- return this.vacay.toggleEntry(userId, planId, body.date, body.fraction, socketId);
+ return this.vacay.toggleEntry(userId, planId, body.date, body.fraction, body.kind, socketId);
}
@Post('entries/company-holiday')
diff --git a/server/src/nest/vacay/vacay.service.ts b/server/src/nest/vacay/vacay.service.ts
index 98de80ace..178f5ac69 100644
--- a/server/src/nest/vacay/vacay.service.ts
+++ b/server/src/nest/vacay/vacay.service.ts
@@ -86,8 +86,8 @@ export class VacayService {
return svc.getEntries(planId, year);
}
- toggleEntry(userId: number, planId: number, date: string, fraction: unknown, socketId: string | undefined) {
- return svc.toggleEntry(userId, planId, date, fraction, socketId);
+ toggleEntry(userId: number, planId: number, date: string, fraction: unknown, kind: unknown, socketId: string | undefined) {
+ return svc.toggleEntry(userId, planId, date, fraction, kind, socketId);
}
toggleCompanyHoliday(planId: number, date: string, note: string | undefined, socketId: string | undefined) {
diff --git a/server/src/services/vacayService.ts b/server/src/services/vacayService.ts
index 07e36ff08..4c0340156 100644
--- a/server/src/services/vacayService.ts
+++ b/server/src/services/vacayService.ts
@@ -77,10 +77,24 @@ const CACHE_TTL = 24 * 60 * 60 * 1000;
* half day (#552) counts as 0.5 and a full day as 1. Entries predating the
* feature have fraction = 1, so this matches the old COUNT(*) for them.
*/
-function usedDays(userId: number, planId: number, yearPrefix: string): number {
+function usedDays(userId: number, planId: number, year: number): number {
+ // Comp/Flex days (#1074) are free — kind='comp' contributes 0 to the entitlement,
+ // vacation days contribute their fraction. Entries predating the column are
+ // 'vacation' by default. The window (#737) is the user's leave-year period; for
+ // 'calendar' it is Jan 1 – Dec 31, byte-identical to the old date-prefix match.
+ const { start, end } = resolveYearWindow(userId, year);
const row = db.prepare(
- 'SELECT COALESCE(SUM(fraction), 0) AS used FROM vacay_entries WHERE user_id = ? AND plan_id = ? AND date LIKE ?'
- ).get(userId, planId, yearPrefix) as { used: number };
+ "SELECT COALESCE(SUM(CASE WHEN kind = 'comp' THEN 0 ELSE fraction END), 0) AS used FROM vacay_entries WHERE user_id = ? AND plan_id = ? AND date >= ? AND date < ?"
+ ).get(userId, planId, start, end) as { used: number };
+ return row.used;
+}
+
+/** Comp/Flex days (#1074) used in a user's leave-year period — SUM of fractions for kind='comp'. */
+function compUsedDays(userId: number, planId: number, year: number): number {
+ const { start, end } = resolveYearWindow(userId, year);
+ const row = db.prepare(
+ "SELECT COALESCE(SUM(fraction), 0) AS used FROM vacay_entries WHERE user_id = ? AND plan_id = ? AND date >= ? AND date < ? AND kind = 'comp'"
+ ).get(userId, planId, start, end) as { used: number };
return row.used;
}
@@ -89,6 +103,75 @@ function normalizeFraction(value: unknown): number {
return Number(value) === 0.5 ? 0.5 : 1;
}
+/** Coerce an arbitrary input to a supported leave type: comp/flex or vacation (#1074). */
+function normalizeKind(value: unknown): 'vacation' | 'comp' {
+ return value === 'comp' ? 'comp' : 'vacation';
+}
+
+// ---------------------------------------------------------------------------
+// Configurable vacation year (#737)
+// ---------------------------------------------------------------------------
+
+export interface VacayUserSettings {
+ user_id: number;
+ year_type: 'calendar' | 'fiscal' | 'anniversary';
+ year_start_month: number;
+ year_start_day: number;
+ hire_date: string | null;
+}
+
+export function getUserYearSettings(userId: number): VacayUserSettings | undefined {
+ return db.prepare('SELECT * FROM vacay_user_settings WHERE user_id = ?').get(userId) as VacayUserSettings | undefined;
+}
+
+const pad2 = (n: number) => String(n).padStart(2, '0');
+
+/** Coerce an arbitrary input to a supported leave-year type (#737). */
+function normalizeYearType(value: unknown): 'calendar' | 'fiscal' | 'anniversary' {
+ return value === 'fiscal' || value === 'anniversary' ? value : 'calendar';
+}
+
+/**
+ * Resolve a user's leave-year window for a period (#737). The `year` integer names
+ * the period; 'calendar' returns Jan 1 – Dec 31 (the unchanged default, byte-identical
+ * to the old `date LIKE 'YYYY-%'`), 'fiscal' starts on the configured month/day, and
+ * 'anniversary' on the hire date's month/day. Window is [start, end) — start inclusive,
+ * end exclusive. Because periods are consecutive, `year-1` is always the window that
+ * ends where `year`'s begins, so the carry-over chains stay valid unchanged.
+ */
+export function resolveYearWindow(userId: number, year: number): { start: string; end: string } {
+ const s = getUserYearSettings(userId);
+ if (!s || s.year_type === 'calendar') {
+ return { start: `${year}-01-01`, end: `${year + 1}-01-01` };
+ }
+ let month = s.year_start_month || 1;
+ let day = s.year_start_day || 1;
+ if (s.year_type === 'anniversary' && s.hire_date) {
+ const parts = s.hire_date.split('-');
+ month = parseInt(parts[1], 10) || 1;
+ day = parseInt(parts[2], 10) || 1;
+ }
+ return { start: `${year}-${pad2(month)}-${pad2(day)}`, end: `${year + 1}-${pad2(month)}-${pad2(day)}` };
+}
+
+/** Upsert a user's leave-year settings (#737). */
+export function updateUserYearSettings(
+ userId: number,
+ data: { year_type?: unknown; year_start_month?: unknown; year_start_day?: unknown; hire_date?: unknown },
+): VacayUserSettings {
+ const type = normalizeYearType(data.year_type);
+ const month = Math.min(12, Math.max(1, parseInt(String(data.year_start_month ?? 1), 10) || 1));
+ const day = Math.min(31, Math.max(1, parseInt(String(data.year_start_day ?? 1), 10) || 1));
+ const hire = typeof data.hire_date === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(data.hire_date) ? data.hire_date : null;
+ db.prepare(`
+ INSERT INTO vacay_user_settings (user_id, year_type, year_start_month, year_start_day, hire_date)
+ VALUES (?, ?, ?, ?, ?)
+ ON CONFLICT(user_id) DO UPDATE SET year_type = excluded.year_type, year_start_month = excluded.year_start_month,
+ year_start_day = excluded.year_start_day, hire_date = excluded.hire_date
+ `).run(userId, type, month, day, hire);
+ return getUserYearSettings(userId)!;
+}
+
// ---------------------------------------------------------------------------
// Color palette for auto-assign
// ---------------------------------------------------------------------------
@@ -298,7 +381,7 @@ export async function updatePlan(planId: number, body: UpdatePlanBody, socketId:
const yr = years[i].year;
const nextYr = years[i + 1].year;
for (const u of users) {
- const used = usedDays(u.id, planId, `${yr}-%`);
+ const used = usedDays(u.id, planId, yr);
const config = db.prepare('SELECT * FROM vacay_user_years WHERE user_id = ? AND plan_id = ? AND year = ?').get(u.id, planId, yr) as VacayUserYear | undefined;
const total = (config ? config.vacation_days : 30) + (config ? config.carried_over : 0);
const carry = Math.max(0, total - used);
@@ -713,7 +796,7 @@ export function getSharedCalendars(viewerId: number, year: string) {
return { share_id: s.id, owner_id: s.owner_id, owner_name: s.username, color, hidden: !!s.hidden, entries: [], companyHolidays: [] };
}
const entries = db.prepare(
- 'SELECT date, fraction FROM vacay_entries WHERE plan_id = ? AND user_id = ? AND date LIKE ? ORDER BY date'
+ 'SELECT date, fraction, kind FROM vacay_entries WHERE plan_id = ? AND user_id = ? AND date LIKE ? ORDER BY date'
).all(plan.id, s.owner_id, `${year}-%`);
// Company holidays are plan-wide context for "when is this person off";
// only exposed while the owner has the feature enabled, and dates only —
@@ -745,7 +828,7 @@ export function addYear(planId: number, year: number, socketId: string | undefin
if (carryOverEnabled) {
const prevConfig = db.prepare('SELECT * FROM vacay_user_years WHERE user_id = ? AND plan_id = ? AND year = ?').get(u.id, planId, year - 1) as VacayUserYear | undefined;
if (prevConfig) {
- const used = usedDays(u.id, planId, `${year - 1}-%`);
+ const used = usedDays(u.id, planId, year - 1);
const total = prevConfig.vacation_days + prevConfig.carried_over;
carriedOver = Math.max(0, total - used);
}
@@ -776,7 +859,7 @@ export function deleteYear(planId: number, year: number, socketId: string | unde
if (carryOverEnabled && prevYear) {
const prevConfig = db.prepare('SELECT * FROM vacay_user_years WHERE user_id = ? AND plan_id = ? AND year = ?').get(u.id, planId, prevYear.year) as VacayUserYear | undefined;
if (prevConfig) {
- const used = usedDays(u.id, planId, `${prevYear.year}-%`);
+ const used = usedDays(u.id, planId, prevYear.year);
const total = prevConfig.vacation_days + prevConfig.carried_over;
carry = Math.max(0, total - used);
}
@@ -805,24 +888,25 @@ export function getEntries(planId: number, year: string) {
return { entries, companyHolidays };
}
-export function toggleEntry(userId: number, planId: number, date: string, fraction?: unknown, socketId?: string): { action: string; fraction?: number } {
+export function toggleEntry(userId: number, planId: number, date: string, fraction?: unknown, kind?: unknown, socketId?: string): { action: string; fraction?: number; kind?: string } {
const frac = normalizeFraction(fraction);
- const existing = db.prepare('SELECT id, fraction FROM vacay_entries WHERE user_id = ? AND date = ? AND plan_id = ?').get(userId, date, planId) as { id: number; fraction: number } | undefined;
+ const knd = normalizeKind(kind);
+ const existing = db.prepare('SELECT id, fraction, kind FROM vacay_entries WHERE user_id = ? AND date = ? AND plan_id = ?').get(userId, date, planId) as { id: number; fraction: number; kind: string | null } | undefined;
if (existing) {
- // Clicking the same kind of day again clears it; clicking the other kind
- // (full over a half, or vice versa) converts it in place.
- if (existing.fraction === frac) {
+ // Clicking the exact same day again (same type AND same fraction) clears it;
+ // clicking a different type or fraction converts it in place (#552/#1074).
+ if (existing.fraction === frac && (existing.kind || 'vacation') === knd) {
db.prepare('DELETE FROM vacay_entries WHERE id = ?').run(existing.id);
notifyPlanUsers(planId, socketId);
return { action: 'removed' };
}
- db.prepare('UPDATE vacay_entries SET fraction = ? WHERE id = ?').run(frac, existing.id);
+ db.prepare('UPDATE vacay_entries SET fraction = ?, kind = ? WHERE id = ?').run(frac, knd, existing.id);
notifyPlanUsers(planId, socketId);
- return { action: 'updated', fraction: frac };
+ return { action: 'updated', fraction: frac, kind: knd };
}
- db.prepare('INSERT INTO vacay_entries (plan_id, user_id, date, note, fraction) VALUES (?, ?, ?, ?, ?)').run(planId, userId, date, '', frac);
+ db.prepare('INSERT INTO vacay_entries (plan_id, user_id, date, note, fraction, kind) VALUES (?, ?, ?, ?, ?, ?)').run(planId, userId, date, '', frac, knd);
notifyPlanUsers(planId, socketId);
- return { action: 'added', fraction: frac };
+ return { action: 'added', fraction: frac, kind: knd };
}
export function toggleCompanyHoliday(planId: number, date: string, note: string | undefined, socketId: string | undefined): { action: string } {
@@ -849,7 +933,8 @@ export function getStats(planId: number, year: number) {
const users = getPlanUsers(planId);
return users.map(u => {
- const used = usedDays(u.id, planId, `${year}-%`);
+ const used = usedDays(u.id, planId, year);
+ const compUsed = compUsedDays(u.id, planId, year);
const config = db.prepare('SELECT * FROM vacay_user_years WHERE user_id = ? AND plan_id = ? AND year = ?').get(u.id, planId, year) as VacayUserYear | undefined;
const vacationDays = config ? config.vacation_days : 30;
const carriedOver = carryOverEnabled ? (config ? config.carried_over : 0) : 0;
@@ -869,7 +954,7 @@ export function getStats(planId: number, year: number) {
return {
user_id: u.id, person_name: u.username, person_color: colorRow?.color || '#6366f1',
year, vacation_days: vacationDays, carried_over: carriedOver,
- total_available: total, used, remaining,
+ total_available: total, used, remaining, comp_used: compUsed,
};
});
}
diff --git a/shared/src/i18n/ar/vacay.ts b/shared/src/i18n/ar/vacay.ts
index 15c63cc70..0b9f41fba 100644
--- a/shared/src/i18n/ar/vacay.ts
+++ b/shared/src/i18n/ar/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'نصف يوم',
'vacay.modeHalfHint': 'تسجيل أنصاف أيام الإجازة',
'vacay.fullDay': 'يوم كامل',
+ 'vacay.modeComp': 'تعويض / مرن',
+ 'vacay.modeCompHint': 'تسجيل أيام التعويض / الوقت المرن (مجانًا — دون استخدام إجازة)',
+ 'vacay.compHalf': 'نصف يوم تعويضي',
'vacay.entitlement': 'الاستحقاق',
'vacay.entitlementDays': 'الأيام',
'vacay.used': 'المستخدم',
diff --git a/shared/src/i18n/br/vacay.ts b/shared/src/i18n/br/vacay.ts
index 08535a363..c521fbec9 100644
--- a/shared/src/i18n/br/vacay.ts
+++ b/shared/src/i18n/br/vacay.ts
@@ -31,6 +31,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Meio dia',
'vacay.modeHalfHint': 'Registrar meio dia de férias',
'vacay.fullDay': 'Dia inteiro',
+ 'vacay.modeComp': 'Banco de horas',
+ 'vacay.modeCompHint': 'Registrar dias de banco de horas (grátis — sem usar férias)',
+ 'vacay.compHalf': 'Meio dia de banco de horas',
'vacay.entitlement': 'Direito',
'vacay.entitlementDays': 'Dias',
'vacay.used': 'Usados',
diff --git a/shared/src/i18n/ca/vacay.ts b/shared/src/i18n/ca/vacay.ts
index 5e7fc8385..7d918d2e9 100644
--- a/shared/src/i18n/ca/vacay.ts
+++ b/shared/src/i18n/ca/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Mitja jornada',
'vacay.modeHalfHint': 'Registra mitges jornades de vacances',
'vacay.fullDay': 'Jornada completa',
+ 'vacay.modeComp': 'Comp. / Flexi',
+ 'vacay.modeCompHint': 'Registra dies de compensació/flexibilitat (gratis — no gasta vacances)',
+ 'vacay.compHalf': 'Mig dia de compensació',
'vacay.entitlement': 'Dret',
'vacay.entitlementDays': 'Dies',
'vacay.used': 'Utilitzats',
diff --git a/shared/src/i18n/cs/vacay.ts b/shared/src/i18n/cs/vacay.ts
index caf5867e4..f1b6ec0c9 100644
--- a/shared/src/i18n/cs/vacay.ts
+++ b/shared/src/i18n/cs/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Půlden',
'vacay.modeHalfHint': 'Zapsat půldenní dovolenou',
'vacay.fullDay': 'Celý den',
+ 'vacay.modeComp': 'Náhradní volno',
+ 'vacay.modeCompHint': 'Zapsat náhradní / pružné volno (zdarma — bez čerpání dovolené)',
+ 'vacay.compHalf': 'Půlden náhradního volna',
'vacay.entitlement': 'Nárok',
'vacay.entitlementDays': 'Dní',
'vacay.used': 'Vyčerpáno',
diff --git a/shared/src/i18n/de/vacay.ts b/shared/src/i18n/de/vacay.ts
index f0c522539..838a2c498 100644
--- a/shared/src/i18n/de/vacay.ts
+++ b/shared/src/i18n/de/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Halbtag',
'vacay.modeHalfHint': 'Halbe Urlaubstage eintragen',
'vacay.fullDay': 'Ganzer Tag',
+ 'vacay.modeComp': 'Ausgleich',
+ 'vacay.modeCompHint': 'Ausgleichs-/Gleittage eintragen (kostenlos — kein Urlaub)',
+ 'vacay.compHalf': 'Halber Ausgleichstag',
'vacay.entitlement': 'Urlaubsanspruch',
'vacay.entitlementDays': 'Tage',
'vacay.used': 'Weg',
diff --git a/shared/src/i18n/en/vacay.ts b/shared/src/i18n/en/vacay.ts
index 2212bfde5..7106c59c8 100644
--- a/shared/src/i18n/en/vacay.ts
+++ b/shared/src/i18n/en/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Half day',
'vacay.modeHalfHint': 'Log half vacation days',
'vacay.fullDay': 'Full day',
+ 'vacay.modeComp': 'Comp / Flex',
+ 'vacay.modeCompHint': 'Log comp / flex days (free — no vacation used)',
+ 'vacay.compHalf': 'Half comp day',
'vacay.entitlement': 'Entitlement',
'vacay.entitlementDays': 'Days',
'vacay.used': 'Used',
diff --git a/shared/src/i18n/es/vacay.ts b/shared/src/i18n/es/vacay.ts
index 15fdfb033..e81e352f8 100644
--- a/shared/src/i18n/es/vacay.ts
+++ b/shared/src/i18n/es/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Medio día',
'vacay.modeHalfHint': 'Registrar medios días de vacaciones',
'vacay.fullDay': 'Día completo',
+ 'vacay.modeComp': 'Compensación',
+ 'vacay.modeCompHint': 'Registrar días de compensación/flexibles (gratis — sin usar vacaciones)',
+ 'vacay.compHalf': 'Medio día de compensación',
'vacay.entitlement': 'Derecho',
'vacay.entitlementDays': 'Días',
'vacay.used': 'Usados',
diff --git a/shared/src/i18n/fr/vacay.ts b/shared/src/i18n/fr/vacay.ts
index 0a9aab91c..edf3fbfa5 100644
--- a/shared/src/i18n/fr/vacay.ts
+++ b/shared/src/i18n/fr/vacay.ts
@@ -31,6 +31,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Demi-journée',
'vacay.modeHalfHint': 'Enregistrer des demi-journées de congé',
'vacay.fullDay': 'Journée complète',
+ 'vacay.modeComp': 'Récup / RTT',
+ 'vacay.modeCompHint': 'Enregistrer les jours de récupération / RTT (gratuit — aucun congé utilisé)',
+ 'vacay.compHalf': 'Demi-journée de récupération',
'vacay.entitlement': 'Droits',
'vacay.entitlementDays': 'Jours',
'vacay.used': 'Utilisés',
diff --git a/shared/src/i18n/gr/vacay.ts b/shared/src/i18n/gr/vacay.ts
index 26e20959e..0aba93b4a 100644
--- a/shared/src/i18n/gr/vacay.ts
+++ b/shared/src/i18n/gr/vacay.ts
@@ -31,6 +31,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Μισή μέρα',
'vacay.modeHalfHint': 'Καταχώριση μισής ημέρας άδειας',
'vacay.fullDay': 'Ολόκληρη μέρα',
+ 'vacay.modeComp': 'Ρεπό',
+ 'vacay.modeCompHint': 'Καταχώριση ημερών ρεπό/ευέλικτου ωραρίου (δωρεάν — χωρίς χρήση αδείας)',
+ 'vacay.compHalf': 'Μισή μέρα ρεπό',
'vacay.entitlement': 'Δικαίωμα',
'vacay.entitlementDays': 'Ημέρες',
'vacay.used': 'Χρησιμοποιημένες',
diff --git a/shared/src/i18n/hu/vacay.ts b/shared/src/i18n/hu/vacay.ts
index 19c5b04a9..beb595d8f 100644
--- a/shared/src/i18n/hu/vacay.ts
+++ b/shared/src/i18n/hu/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Fél nap',
'vacay.modeHalfHint': 'Fél szabadnapok rögzítése',
'vacay.fullDay': 'Egész nap',
+ 'vacay.modeComp': 'Csúsztatás',
+ 'vacay.modeCompHint': 'Csúsztatás / rugalmas napok rögzítése (ingyenes — nincs szabadságfelhasználás)',
+ 'vacay.compHalf': 'Fél csúsztatásnap',
'vacay.entitlement': 'Szabadságkeret',
'vacay.entitlementDays': 'nap',
'vacay.used': 'Felhasznált',
diff --git a/shared/src/i18n/id/vacay.ts b/shared/src/i18n/id/vacay.ts
index e7271728b..b7420cc96 100644
--- a/shared/src/i18n/id/vacay.ts
+++ b/shared/src/i18n/id/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Setengah hari',
'vacay.modeHalfHint': 'Catat setengah hari cuti',
'vacay.fullDay': 'Sehari penuh',
+ 'vacay.modeComp': 'Pengganti / Fleksi',
+ 'vacay.modeCompHint': 'Catat hari pengganti / fleksi (gratis — tanpa memotong cuti)',
+ 'vacay.compHalf': 'Setengah hari pengganti',
'vacay.entitlement': 'Jatah Cuti',
'vacay.entitlementDays': 'Hari',
'vacay.used': 'Terpakai',
diff --git a/shared/src/i18n/it/vacay.ts b/shared/src/i18n/it/vacay.ts
index 2e14898e6..96f7e8649 100644
--- a/shared/src/i18n/it/vacay.ts
+++ b/shared/src/i18n/it/vacay.ts
@@ -31,6 +31,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Mezza giornata',
'vacay.modeHalfHint': 'Registra mezze giornate di ferie',
'vacay.fullDay': 'Giornata intera',
+ 'vacay.modeComp': 'Recupero / Flex',
+ 'vacay.modeCompHint': 'Registra giorni di recupero / flex (gratis — nessuna ferie usata)',
+ 'vacay.compHalf': 'Mezza giornata di recupero',
'vacay.entitlement': 'Disponibilità',
'vacay.entitlementDays': 'Giorni',
'vacay.used': 'Usati',
diff --git a/shared/src/i18n/ja/vacay.ts b/shared/src/i18n/ja/vacay.ts
index 230bc8849..05490b72f 100644
--- a/shared/src/i18n/ja/vacay.ts
+++ b/shared/src/i18n/ja/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': '半休',
'vacay.modeHalfHint': '半休を登録',
'vacay.fullDay': '全休',
+ 'vacay.modeComp': '代休・フレックス',
+ 'vacay.modeCompHint': '代休・フレックス日を登録(休暇消費なし)',
+ 'vacay.compHalf': '半代休',
'vacay.entitlement': '付与日数',
'vacay.entitlementDays': '日',
'vacay.used': '使用済み',
diff --git a/shared/src/i18n/ko/vacay.ts b/shared/src/i18n/ko/vacay.ts
index ee33d64f4..85e86cb0c 100644
--- a/shared/src/i18n/ko/vacay.ts
+++ b/shared/src/i18n/ko/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': '반차',
'vacay.modeHalfHint': '반차 등록',
'vacay.fullDay': '종일',
+ 'vacay.modeComp': '대체휴무',
+ 'vacay.modeCompHint': '대체/보상 휴무 등록 (무료 — 휴가 차감 없음)',
+ 'vacay.compHalf': '반일 대체휴무',
'vacay.entitlement': '휴가 일수',
'vacay.entitlementDays': '일',
'vacay.used': '사용',
diff --git a/shared/src/i18n/nl/vacay.ts b/shared/src/i18n/nl/vacay.ts
index e73191eb8..6896a4545 100644
--- a/shared/src/i18n/nl/vacay.ts
+++ b/shared/src/i18n/nl/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Halve dag',
'vacay.modeHalfHint': 'Halve vakantiedagen invoeren',
'vacay.fullDay': 'Hele dag',
+ 'vacay.modeComp': 'Compensatie',
+ 'vacay.modeCompHint': 'Compensatie-/flexdagen invoeren (gratis — geen vakantie gebruikt)',
+ 'vacay.compHalf': 'Halve compensatiedag',
'vacay.entitlement': 'Recht',
'vacay.entitlementDays': 'Dagen',
'vacay.used': 'Gebruikt',
diff --git a/shared/src/i18n/pl/vacay.ts b/shared/src/i18n/pl/vacay.ts
index 131a83902..e801612d3 100644
--- a/shared/src/i18n/pl/vacay.ts
+++ b/shared/src/i18n/pl/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Pół dnia',
'vacay.modeHalfHint': 'Zapisz pół dnia urlopu',
'vacay.fullDay': 'Cały dzień',
+ 'vacay.modeComp': 'Odbiór',
+ 'vacay.modeCompHint': 'Zapisz dni odbioru / czasu wolnego (za darmo — bez urlopu)',
+ 'vacay.compHalf': 'Pół dnia odbioru',
'vacay.entitlement': 'Wymiar',
'vacay.entitlementDays': 'Dni',
'vacay.used': 'Wykorzystane',
diff --git a/shared/src/i18n/ru/vacay.ts b/shared/src/i18n/ru/vacay.ts
index 89e1b4dc9..fb5e4c149 100644
--- a/shared/src/i18n/ru/vacay.ts
+++ b/shared/src/i18n/ru/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Полдня',
'vacay.modeHalfHint': 'Отмечать полдня отпуска',
'vacay.fullDay': 'Полный день',
+ 'vacay.modeComp': 'Отгул',
+ 'vacay.modeCompHint': 'Отмечать отгулы (бесплатно — отпуск не расходуется)',
+ 'vacay.compHalf': 'Полдня отгула',
'vacay.entitlement': 'Право на отпуск',
'vacay.entitlementDays': 'Дни',
'vacay.used': 'Использовано',
diff --git a/shared/src/i18n/sv/vacay.ts b/shared/src/i18n/sv/vacay.ts
index 92a087047..76a656447 100644
--- a/shared/src/i18n/sv/vacay.ts
+++ b/shared/src/i18n/sv/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Halvdag',
'vacay.modeHalfHint': 'Registrera halva semesterdagar',
'vacay.fullDay': 'Heldag',
+ 'vacay.modeComp': 'Komp / Flex',
+ 'vacay.modeCompHint': 'Registrera komp-/flexdagar (gratis — ingen semester används)',
+ 'vacay.compHalf': 'Halv kompdag',
'vacay.entitlement': 'Rättighet',
'vacay.entitlementDays': 'Dagar',
'vacay.used': 'Använt',
diff --git a/shared/src/i18n/tr/vacay.ts b/shared/src/i18n/tr/vacay.ts
index faffeeee9..9ef3114ec 100644
--- a/shared/src/i18n/tr/vacay.ts
+++ b/shared/src/i18n/tr/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Yarım gün',
'vacay.modeHalfHint': 'Yarım izin günü ekle',
'vacay.fullDay': 'Tam gün',
+ 'vacay.modeComp': 'Serbest zaman',
+ 'vacay.modeCompHint': 'Serbest zaman / esnek gün ekle (ücretsiz — izin kullanılmaz)',
+ 'vacay.compHalf': 'Yarım serbest zaman günü',
'vacay.entitlement': 'Yetki',
'vacay.entitlementDays': 'Günler',
'vacay.used': 'Kullanılmış',
diff --git a/shared/src/i18n/uk/vacay.ts b/shared/src/i18n/uk/vacay.ts
index 2036a07bd..bf22af94d 100644
--- a/shared/src/i18n/uk/vacay.ts
+++ b/shared/src/i18n/uk/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Пів дня',
'vacay.modeHalfHint': 'Позначати пів дня відпустки',
'vacay.fullDay': 'Повний день',
+ 'vacay.modeComp': 'Відгул',
+ 'vacay.modeCompHint': 'Позначати дні відгулу (безкоштовно — відпустка не використовується)',
+ 'vacay.compHalf': 'Пів дня відгулу',
'vacay.entitlement': 'Право на відпустку',
'vacay.entitlementDays': 'Дні',
'vacay.used': 'Використано',
diff --git a/shared/src/i18n/vi/vacay.ts b/shared/src/i18n/vi/vacay.ts
index 4011e0e05..0fbd71b5a 100644
--- a/shared/src/i18n/vi/vacay.ts
+++ b/shared/src/i18n/vi/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': 'Nửa ngày',
'vacay.modeHalfHint': 'Ghi nửa ngày nghỉ',
'vacay.fullDay': 'Cả ngày',
+ 'vacay.modeComp': 'Nghỉ bù',
+ 'vacay.modeCompHint': 'Ghi ngày nghỉ bù (miễn phí — không dùng phép)',
+ 'vacay.compHalf': 'Nửa ngày nghỉ bù',
'vacay.entitlement': 'Quyền lợi',
'vacay.entitlementDays': 'Ngày',
'vacay.used': 'Đã dùng',
diff --git a/shared/src/i18n/zh-TW/vacay.ts b/shared/src/i18n/zh-TW/vacay.ts
index 6a26ed7a7..268fb910e 100644
--- a/shared/src/i18n/zh-TW/vacay.ts
+++ b/shared/src/i18n/zh-TW/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': '半天',
'vacay.modeHalfHint': '記錄半天假期',
'vacay.fullDay': '全天',
+ 'vacay.modeComp': '補休 / 彈性',
+ 'vacay.modeCompHint': '記錄補休/彈性假(免費 — 不佔用年假)',
+ 'vacay.compHalf': '半天補休',
'vacay.entitlement': '年假額度',
'vacay.entitlementDays': '天',
'vacay.used': '已用',
diff --git a/shared/src/i18n/zh/vacay.ts b/shared/src/i18n/zh/vacay.ts
index b24bab432..ee99d6410 100644
--- a/shared/src/i18n/zh/vacay.ts
+++ b/shared/src/i18n/zh/vacay.ts
@@ -30,6 +30,9 @@ const vacay: TranslationStrings = {
'vacay.modeHalf': '半天',
'vacay.modeHalfHint': '记录半天假期',
'vacay.fullDay': '全天',
+ 'vacay.modeComp': '调休',
+ 'vacay.modeCompHint': '记录调休/弹性假(免费 — 不占用年假)',
+ 'vacay.compHalf': '半天调休',
'vacay.entitlement': '年假额度',
'vacay.entitlementDays': '天',
'vacay.used': '已用',
diff --git a/shared/src/vacay/vacay.schema.ts b/shared/src/vacay/vacay.schema.ts
index 327b5c872..66a7b3cea 100644
--- a/shared/src/vacay/vacay.schema.ts
+++ b/shared/src/vacay/vacay.schema.ts
@@ -51,6 +51,9 @@ export const vacayToggleEntryRequestSchema = z.object({
target_user_id: z.union([z.number(), z.string()]).optional(),
// Half vacation days (#552): 0.5 logs a half day, 1 (or omitted) a full day.
fraction: z.union([z.literal(0.5), z.literal(1)]).optional(),
+ // Leave type (#1074): 'comp' logs a flex/comp day (does not touch the
+ // entitlement), 'vacation' (or omitted) a regular vacation day.
+ kind: z.enum(['vacation', 'comp']).optional(),
});
export type VacayToggleEntryRequest = z.infer<typeof vacayToggleEntryRequestSchema>;