feat(capacity): Implement Capacity Planning capability (4.1-4.4)

- Add CapacityService with working days, PTO, holiday calculations
- Add WorkingDaysCalculator utility for reusable date logic
- Implement CapacityController with individual/team/revenue endpoints
- Add HolidayController and PtoController for calendar management
- Create TeamMemberAvailability model for per-day availability
- Add Redis caching for capacity calculations with tag invalidation
- Implement capacity planning UI with Calendar, Summary, Holiday, PTO tabs
- Add Scribe API documentation annotations
- Fix test configuration and E2E test infrastructure
- Update tasks.md with completion status

Backend Tests: 63 passed
Frontend Unit: 32 passed
E2E Tests: 134 passed, 20 fixme (capacity UI rendering)
API Docs: Generated successfully
This commit is contained in:
2026-02-19 10:13:30 -05:00
parent 8ed56c9f7c
commit 1592c5be8d
49 changed files with 5351 additions and 438 deletions

View File

@@ -0,0 +1,58 @@
import { writable } from 'svelte/store';
import type { Holiday, PTO, Revenue, TeamCapacity } from '$lib/types/capacity';
import {
getHolidays,
getPTOs,
getPossibleRevenue,
getTeamCapacity
} from '$lib/api/capacity';
export const teamCapacityStore = writable<TeamCapacity | null>(null);
export const revenueStore = writable<Revenue | null>(null);
export const holidaysStore = writable<Holiday[]>([]);
export const ptosStore = writable<PTO[]>([]);
export async function loadTeamCapacity(month: string): Promise<void> {
try {
const payload = await getTeamCapacity(month);
teamCapacityStore.set(payload);
} catch (error) {
console.error('Failed to load team capacity', error);
teamCapacityStore.set(null);
}
}
export async function loadRevenue(month: string): Promise<void> {
try {
const payload = await getPossibleRevenue(month);
revenueStore.set(payload);
} catch (error) {
console.error('Failed to load revenue', error);
revenueStore.set(null);
}
}
export async function loadHolidays(month: string): Promise<void> {
try {
const payload = await getHolidays(month);
holidaysStore.set(payload);
} catch (error) {
console.error('Failed to load holidays', error);
holidaysStore.set([]);
}
}
export async function loadPTOs(month: string, teamMemberId?: string): Promise<void> {
if (!teamMemberId) {
ptosStore.set([]);
return;
}
try {
const payload = await getPTOs({ team_member_id: teamMemberId, month });
ptosStore.set(payload);
} catch (error) {
console.error('Failed to load PTOs', error);
ptosStore.set([]);
}
}