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