Optimize PDF export layout with compact columns and more space for partner names. Add accounting period display to invoices matching Trial Balance format. Fix date filtering to use local timezone instead of UTC. Update invoice ordering to chronological sequence (DATAACT, NRACT, NUME). **Backend changes:** - Add accounting period query from calendar table - Add currency (valuta) and cont filter support - Change invoice ordering to chronological (DATAACT ASC, NRACT ASC, NUME) - Add accounting_period field to InvoiceListResponse model **Frontend changes:** - Optimize PDF column widths (37% for partner names, compact numeric columns) - Add custom column width support in exportUtils - Fix date conversion from UTC to local timezone (prevents day shift) - Add accounting period display in PDF exports - Enhance E2E test coverage **Cleanup:** - Remove obsolete Trial Balance feature documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
2.5 KiB
Python
67 lines
2.5 KiB
Python
from fastapi import APIRouter, Depends, HTTPException, Query
|
|
from typing import Optional
|
|
from datetime import date
|
|
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.treasury import RegisterFilter, RegisterListResponse
|
|
from ..services.treasury_service import TreasuryService
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/bank-cash-register", response_model=RegisterListResponse)
|
|
async def get_bank_cash_register(
|
|
company: str = Query(description="Codul firmei"),
|
|
date_from: Optional[str] = Query(None, description="Data început (YYYY-MM-DD)"),
|
|
date_to: Optional[str] = Query(None, description="Data sfârșit (YYYY-MM-DD)"),
|
|
partner_name: Optional[str] = Query(None, description="Filtru nume partener"),
|
|
page: int = Query(1, ge=1, description="Pagina"),
|
|
page_size: int = Query(50, ge=1, le=10000000, description="Mărimea paginii"),
|
|
current_user: CurrentUser = Depends(get_current_user)
|
|
):
|
|
"""
|
|
Obține registrul de casă și bancă
|
|
|
|
- Necesită autentificare JWT
|
|
- Suportă filtrare și paginare
|
|
"""
|
|
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}")
|
|
|
|
# Convertește datele
|
|
date_from_obj = None
|
|
date_to_obj = None
|
|
|
|
if date_from:
|
|
try:
|
|
date_from_obj = date.fromisoformat(date_from)
|
|
except ValueError:
|
|
raise HTTPException(status_code=400, detail="Format dată început invalid")
|
|
|
|
if date_to:
|
|
try:
|
|
date_to_obj = date.fromisoformat(date_to)
|
|
except ValueError:
|
|
raise HTTPException(status_code=400, detail="Format dată sfârșit invalid")
|
|
|
|
filter_params = RegisterFilter(
|
|
company=company,
|
|
date_from=date_from_obj,
|
|
date_to=date_to_obj,
|
|
partner_name=partner_name,
|
|
page=page,
|
|
page_size=page_size
|
|
)
|
|
|
|
result = await TreasuryService.get_bank_cash_register(filter_params, current_user.username)
|
|
return result
|
|
|
|
except ValueError as e:
|
|
raise HTTPException(status_code=400, detail=str(e))
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"Eroare la obținerea registrului: {str(e)}") |