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

Comp/Flex days (#1074) — complete. A second leave type that does not deduct from the vacation entitlement (flextime / overtime offset). New kind column on vacay_entries, excluded from usedDays via a CASE sum; toggleEntry carries kind through service/nest/store with change-detection; desktop and mobile get a comp toolbar toggle next to the half-day one (orthogonal, so a half comp day is free); comp segments render as a diagonal hatch of the person colour, per-segment for split days (Version B). comp_used is surfaced separately in getStats. Translated into all 23 locales.

Configurable vacation year (#737) — backend only. Per-user vacay_user_settings (calendar / fiscal / anniversary), resolveYearWindow, and usedDays / compUsedDays / getStats / carry-over now computed over the leave-year [start,end) window. 'calendar' resolves byte-identically to the old date-prefix behaviour, so nothing changes for existing users and the feature is inert until the settings UI lands. Frontend (settings selector + calendar window rollover), the settings endpoint, window-aware getEntries and holiday loading are still to do — see the PR description.
This commit is contained in:
Maurice
2026-07-24 20:40:15 +02:00
committed by Maurice
parent c61203e607
commit c475e5b04c
38 changed files with 329 additions and 67 deletions
+22
View File
@@ -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) {