Merge branch 'development' into feature/api-sittar-actualizacion
This commit is contained in:
@@ -9,7 +9,12 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from api.v1.modules.a76.general_catalogs.company.models import Company
|
||||
from api.v1.modules.a76.invoices.models import InvoiceHeader
|
||||
from core.database import rls_company_var, rls_tenant_var
|
||||
from core.database import (
|
||||
RLS_COMPANY_KEY,
|
||||
RLS_TENANT_KEY,
|
||||
rls_company_var,
|
||||
rls_tenant_var,
|
||||
)
|
||||
|
||||
from .services.service import AuditService
|
||||
from .utils.serialization import serialize_for_json
|
||||
@@ -56,13 +61,17 @@ def _resolve_audit_company_tenant(session: Session, target) -> tuple:
|
||||
if company_id is not None:
|
||||
resolution_source = "company_self_id"
|
||||
if company_id is None:
|
||||
company_id = rls_company_var.get()
|
||||
company_id = session.info.get(RLS_COMPANY_KEY)
|
||||
if company_id is None:
|
||||
company_id = rls_company_var.get()
|
||||
if company_id is not None:
|
||||
resolution_source = "rls_context"
|
||||
|
||||
tenant_id = getattr(target, "tenant_id", None)
|
||||
if tenant_id is None:
|
||||
tenant_id = rls_tenant_var.get()
|
||||
tenant_id = session.info.get(RLS_TENANT_KEY)
|
||||
if tenant_id is None:
|
||||
tenant_id = rls_tenant_var.get()
|
||||
if tenant_id is not None and resolution_source == "target":
|
||||
resolution_source = "rls_context"
|
||||
|
||||
|
||||
@@ -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)}")
|
||||
|
||||
Reference in New Issue
Block a user