- Add PeriodSelectorMini component for global period selection - Add accountingPeriod store for shared period state - Add calendar service/router/model for available periods API - Update Dashboard, Invoices, Trial Balance, Bank/Cash Register views to respect selected period - Fix Trial Balance navigation sync bug (period now syncs on mount) - Update backend services to accept luna/an parameters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""
|
|
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)
|