Tackeo de errores
This commit is contained in:
@@ -86,14 +86,28 @@ async def consume_ws_get_cove(**kwargs):
|
||||
|
||||
# Enviar documento
|
||||
_file_name = f"vu_COVE_{pedimento_app}_{cove}.xml"
|
||||
document_response = await coves_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||
pedimento=kwargs.get('pedimento').get('id'),
|
||||
file_name=_file_name,
|
||||
document_type=8,
|
||||
)
|
||||
|
||||
try:
|
||||
if soap_error(soap_response):
|
||||
document_response = await coves_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||
pedimento=kwargs.get('pedimento').get('id'),
|
||||
file_name=f"vu_COVE_{pedimento_app}_{cove}_ERROR.xml",
|
||||
document_type=10,
|
||||
)
|
||||
raise Exception("Error en la respuesta del servicio SOAP")
|
||||
else:
|
||||
document_response = await coves_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||
pedimento=kwargs.get('pedimento').get('id'),
|
||||
file_name=_file_name,
|
||||
document_type=8,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
||||
raise Exception(f"Error en la respuesta SOAP: {str(e)}")
|
||||
|
||||
logger.info("Documento enviado, actualizando status de COVE")
|
||||
|
||||
# Actualizar status del COVE
|
||||
|
||||
@@ -76,13 +76,29 @@ async def consume_ws_get_partida(**kwargs):
|
||||
|
||||
# Enviar documento
|
||||
_file_name = f"vu_PT_{pedimento_app}_{partida.get('numero', '')}.xml"
|
||||
document_response = await partida_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||
pedimento=kwargs.get('pedimento').get('id'),
|
||||
file_name=_file_name,
|
||||
document_type=1,
|
||||
)
|
||||
try:
|
||||
if soap_error(soap_response):
|
||||
document_response = await partida_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||
pedimento=kwargs.get('pedimento').get('id'),
|
||||
file_name=f"vu_PT_{pedimento_app}_{partida.get('numero', '')}_ERROR.xml",
|
||||
document_type=10,
|
||||
)
|
||||
raise Exception("Error en la respuesta del servicio SOAP")
|
||||
else:
|
||||
document_response = await partida_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||
pedimento=kwargs.get('pedimento').get('id'),
|
||||
file_name=_file_name,
|
||||
document_type=1,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
||||
raise Exception(f"Error en la respuesta SOAP: {str(e)}")
|
||||
|
||||
|
||||
logger.info("Documento enviado, actualizando status de Partida")
|
||||
|
||||
|
||||
@@ -88,13 +88,23 @@ async def consume_ws_get_pedimento_completo(**kwargs) -> Dict[str, Any]:
|
||||
|
||||
# Enviar documento
|
||||
try:
|
||||
document_response = await pedimento_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=pedimento_data.get('organizacion'),
|
||||
pedimento=pedimento_data.get('id'),
|
||||
file_name=file_name,
|
||||
document_type=2,
|
||||
)
|
||||
if soap_error(soap_response):
|
||||
document_response = await pedimento_rest_controller.post_document(
|
||||
soap_response=None,
|
||||
organizacion=pedimento_data.get('organizacion'),
|
||||
pedimento=pedimento_data.get('id'),
|
||||
file_name=f"vu_PC_{pedimento_data.get('pedimento_app', 'unknown')}_ERROR.xml",
|
||||
document_type=10,
|
||||
)
|
||||
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
|
||||
else:
|
||||
document_response = await pedimento_rest_controller.post_document(
|
||||
soap_response=soap_response,
|
||||
organizacion=pedimento_data.get('organizacion'),
|
||||
pedimento=pedimento_data.get('id'),
|
||||
file_name=file_name,
|
||||
document_type=2,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error al enviar documento: {e}")
|
||||
raise HTTPException(status_code=500, detail="Error al guardar documento")
|
||||
|
||||
@@ -91,13 +91,23 @@ async def obtener_remesa(**kwargs) -> Dict[str, Any]:
|
||||
|
||||
# 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=2,
|
||||
)
|
||||
if soap_error(soap_response):
|
||||
document_response = await remesa_rest_controller.post_document(
|
||||
soap_response=None,
|
||||
organizacion=pedimento_data.get('organizacion'),
|
||||
pedimento=pedimento_data.get('id'),
|
||||
file_name=f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}_ERROR.xml",
|
||||
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,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error al enviar documento: {e}")
|
||||
raise HTTPException(status_code=500, detail="Error al guardar documento")
|
||||
|
||||
@@ -8,6 +8,8 @@ def soap_error(soap_response): # Testeado
|
||||
Returns:
|
||||
bool: True si no hay errores, False en caso contrario
|
||||
"""
|
||||
if '<ns2:tieneError>true</ns2:tieneError>' in soap_response.text:
|
||||
return True
|
||||
if '<ns3:tieneError>true</ns3:tieneError>' in soap_response.text:
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user