""" API Router for calendar/accounting periods """ from fastapi import APIRouter, Depends, HTTPException, Query import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '../../../../shared')) from auth.dependencies import get_current_user from auth.models import CurrentUser from ..models.calendar import CalendarPeriodsResponse from ..services.calendar_service import CalendarService router = APIRouter(redirect_slashes=False) @router.get("/periods", response_model=CalendarPeriodsResponse) async def get_calendar_periods( company: int = Query(..., description="Company ID"), current_user: CurrentUser = Depends(get_current_user) ) -> CalendarPeriodsResponse: """ Get available accounting periods for a company. Returns periods ordered by year DESC, month DESC with Romanian month names. """ # Validate company access if str(company) not in current_user.companies: raise HTTPException( status_code=403, detail=f"Nu aveți acces la firma {company}" ) return await CalendarService.get_available_periods(company)