diff --git a/backend/api/v1/modules/a76/invoices/routes.py b/backend/api/v1/modules/a76/invoices/routes.py index f5428197..54fb72d0 100644 --- a/backend/api/v1/modules/a76/invoices/routes.py +++ b/backend/api/v1/modules/a76/invoices/routes.py @@ -3,6 +3,7 @@ from typing import Dict, Any, Optional from core.config import settings from core.database import get_core_db +from core.exceptions import BaseAPIException from core.security import collect_user_role_names, get_current_user, validate_access_to_resource from fastapi import APIRouter, Depends, HTTPException, Query, Path from sqlalchemy import func, or_, and_ @@ -69,6 +70,8 @@ def get_creation_data( return InvoiceCatalogService.get_creation_data(db, tenant_id, company_id) except HTTPException: raise + except BaseAPIException: + raise except Exception as e: logger.exception("get_creation_data failed: %s", e) raise HTTPException(status_code=500, detail=f"Error al cargar datos de creación: {str(e)}") @@ -97,6 +100,8 @@ def get_edition_data( return data except HTTPException: raise + except BaseAPIException: + raise except Exception as e: logger.exception("get_edition_data failed: %s", e) raise HTTPException(status_code=500, detail=f"Error al cargar datos de edición: {str(e)}") @@ -191,6 +196,8 @@ def create_invoice( return services.InvoiceService.create(db, data, tenant_id, company_id) except HTTPException: raise + except BaseAPIException: + raise except Exception as e: logger.exception("create_invoice failed: %s", e) raise HTTPException(status_code=500, detail=f"Error al guardar factura: {str(e)}") @@ -337,6 +344,8 @@ def list_invoices( "page": page, "page_size": page_size } + except BaseAPIException: + raise except Exception as e: logger.exception("list_invoices failed: %s", e) raise HTTPException(status_code=500, detail=f"Internal server error in invoices list: {str(e)}")