se estan creando el registro de las tareas sin problemas

This commit is contained in:
2025-10-08 21:15:03 -06:00
parent 48db0d72d8
commit 770e0a4d13
15 changed files with 858 additions and 258 deletions

View File

@@ -13,6 +13,7 @@ from .controllers import remesa_rest_controller, remesa_vu_controller, remesa_xm
from utils.helpers import soap_error
from ..common import create_service_response, create_error_response
# Logger configurado para el módulo
logger = logging.getLogger("app.api")
@@ -71,11 +72,8 @@ async def obtener_remesa(**kwargs) -> Dict[str, Any]:
)
# Generar nombre de archivo
file_name = f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}.xml"
# Enviar documento
try:
if soap_error(soap_response):
file_name = f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}.xml"
if soap_error(soap_response):
file_name = f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}_ERROR.xml"
document_response = await remesa_rest_controller.post_document(
soap_response=soap_response,
organizacion=pedimento_data.get('organizacion'),
@@ -84,15 +82,17 @@ async def obtener_remesa(**kwargs) -> Dict[str, Any]:
document_type=10,
)
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
else:
document_response = await remesa_rest_controller.post_document(
soap_response=soap_response,
organizacion=pedimento_data.get('organizacion'),
pedimento=pedimento_data.get('id'),
file_name=file_name,
document_type=3,
)
# Enviar documento
try:
document_response = await remesa_rest_controller.post_document(
soap_response=soap_response,
organizacion=pedimento_data.get('organizacion'),
pedimento=pedimento_data.get('id'),
file_name=file_name,
document_type=3,
)
except Exception as e:
logger.error(f"Error al enviar documento: {e}")
raise HTTPException(status_code=500, detail="Error al guardar documento")
@@ -108,10 +108,19 @@ async def obtener_remesa(**kwargs) -> Dict[str, Any]:
logger.info(f"Remesa procesada exitosamente: {pedimento_data.get('pedimento')}")
return {
"documento": document_response,
"xml_content": remesas_data
}
return create_service_response(
message="Remesa procesada exitosamente",
data={
"documento": document_response,
"xml_content": remesas_data
},
metadata={
"file_name": file_name,
"document_type": 3,
"pedimento_app": pedimento_data.get('pedimento_app'),
"organizacion": pedimento_data.get('organizacion')
}
)
except HTTPException:
raise
@@ -170,7 +179,17 @@ async def post_remesa_data(**kwargs) -> Dict[str, Any]:
logger.info("Procesamiento de pedimento completo finalizado")
return result
# Crear respuesta estandarizada
return create_service_response(
success=True,
message="Procesamiento de remesa completado",
data=result,
warnings=[result["coves_error"]] if result.get("coves_error") else None,
metadata={
"total_coves_procesados": len(result.get("coves_procesados", [])) if result.get("coves_procesados") else 0
}
)