Consolidate 3 separate applications (reports-app, data-entry-app, telegram-bot) into a unified
architecture with single backend and frontend:
Backend Changes:
- Unified FastAPI backend at backend/ with modular structure
- Modules: reports, data_entry, telegram in backend/modules/
- Centralized config.py and main.py with all routers registered
- Single worker mode (--workers 1) for Telegram bot compatibility
- Shared Oracle connection pool and JWT authentication
- Unified requirements.txt and environment configuration
Frontend Changes:
- Single Vue.js SPA with module-based routing
- Unified frontend at src/ with modules in src/modules/{reports,data-entry}/
- Shared components and stores in src/shared/
- Error boundaries for module isolation
- Dual API proxy in Vite for module communication
Infrastructure:
- New unified startup scripts: start-prod.sh, start-test.sh, start-backend.sh
- Environment templates: .env.dev.example, .env.test.example, .env.prod.example
- Updated deployment scripts for Windows IIS
- Simplified SSH tunnel management
Documentation:
- Comprehensive CLAUDE.md with architecture overview
- Module-specific docs in docs/{data-entry,telegram}/
- Architecture decision records in docs/ARCHITECTURE-DECISIONS.md
- Deployment guides consolidated in deployment/windows/docs/
This migration reduces complexity, improves maintainability, and enables easier
deployment while maintaining all existing functionality.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
91 lines
3.4 KiB
Python
91 lines
3.4 KiB
Python
"""
|
|
API Router for Trial Balance (Balanță de Verificare)
|
|
Refactored to use service layer with caching
|
|
"""
|
|
from fastapi import APIRouter, Depends, HTTPException, Query
|
|
from typing import Optional
|
|
from datetime import date
|
|
# import sys # Removed - no longer needed
|
|
import os
|
|
|
|
from shared.auth.dependencies import get_current_user
|
|
from shared.auth.models import CurrentUser
|
|
from ..models.trial_balance import TrialBalanceResponse
|
|
from ..services.trial_balance_service import TrialBalanceService
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/", response_model=TrialBalanceResponse)
|
|
async def get_trial_balance(
|
|
company: str = Query(description="Codul firmei (ID)"),
|
|
luna: Optional[int] = Query(None, ge=1, le=12, description="Luna (1-12), default: luna curentă"),
|
|
an: Optional[int] = Query(None, ge=2000, le=2100, description="An, default: anul curent"),
|
|
cont_filter: Optional[str] = Query(None, description="Filtru număr cont (ex: '512', '4111')"),
|
|
denumire_filter: Optional[str] = Query(None, description="Filtru denumire cont (partial match, case-insensitive)"),
|
|
sort_by: str = Query("CONT", description="Coloană pentru sortare"),
|
|
sort_order: str = Query("asc", description="Ordinea sortării (asc | desc)"),
|
|
page: int = Query(1, ge=1, description="Pagina"),
|
|
page_size: int = Query(50, ge=1, le=1000000, description="Mărimea paginii"),
|
|
current_user: CurrentUser = Depends(get_current_user)
|
|
):
|
|
"""
|
|
Obține balanța de verificare sintetică pentru o firmă
|
|
|
|
- Necesită autentificare JWT
|
|
- Utilizatorul trebuie să aibă acces la firma specificată
|
|
- Suportă filtrare după cont și denumire
|
|
- Suportă paginare și sortare
|
|
- **CACHED 10 min** - folosește sistem cache two-tier (L1 Memory + L2 SQLite)
|
|
"""
|
|
try:
|
|
# Verifică dacă utilizatorul are acces la firma specificată
|
|
if company not in current_user.companies:
|
|
raise HTTPException(
|
|
status_code=403,
|
|
detail=f"Nu aveți acces la firma {company}"
|
|
)
|
|
|
|
# Setează valorile implicite pentru lună și an (luna și anul curent)
|
|
current_date = date.today()
|
|
if luna is None:
|
|
luna = current_date.month
|
|
if an is None:
|
|
an = current_date.year
|
|
|
|
# Convert company to int
|
|
company_id = int(company)
|
|
|
|
# Call service (with caching) - all business logic moved to service
|
|
data = await TrialBalanceService.get_trial_balance(
|
|
company_id=company_id,
|
|
luna=luna,
|
|
an=an,
|
|
cont_filter=cont_filter,
|
|
denumire_filter=denumire_filter,
|
|
sort_by=sort_by,
|
|
sort_order=sort_order,
|
|
page=page,
|
|
page_size=page_size,
|
|
username=current_user.username
|
|
)
|
|
|
|
return TrialBalanceResponse(
|
|
success=True,
|
|
data=data
|
|
)
|
|
|
|
except ValueError as e:
|
|
# Schema not found or validation error
|
|
logger.error(f"Validation error in trial balance: {str(e)}")
|
|
raise HTTPException(status_code=400, detail=str(e))
|
|
except Exception as e:
|
|
# Log unexpected errors
|
|
logger.error(f"Error fetching trial balance: {str(e)}", exc_info=True)
|
|
raise HTTPException(
|
|
status_code=500,
|
|
detail=f"Eroare la obținerea balanței de verificare: {str(e)}"
|
|
)
|