Errores
This commit is contained in:
@@ -80,6 +80,14 @@ async def consume_ws_get_cove(**kwargs):
|
|||||||
raise Exception("No se recibió respuesta del servicio SOAP")
|
raise Exception("No se recibió respuesta del servicio SOAP")
|
||||||
|
|
||||||
if soap_error(soap_response):
|
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")
|
raise Exception("Error en la respuesta del servicio SOAP")
|
||||||
|
|
||||||
logger.info("Respuesta SOAP exitosa, enviando documento")
|
logger.info("Respuesta SOAP exitosa, enviando documento")
|
||||||
@@ -87,23 +95,14 @@ 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"
|
||||||
try:
|
try:
|
||||||
if soap_error(soap_response):
|
|
||||||
document_response = await coves_rest_controller.post_document(
|
document_response = await coves_rest_controller.post_document(
|
||||||
soap_response=soap_response,
|
soap_response=soap_response,
|
||||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||||
pedimento=kwargs.get('pedimento').get('id'),
|
pedimento=kwargs.get('pedimento').get('id'),
|
||||||
file_name=f"vu_COVE_{pedimento_app}_{cove}_ERROR.xml",
|
file_name=_file_name,
|
||||||
document_type=10,
|
document_type=8,
|
||||||
)
|
)
|
||||||
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:
|
except Exception as e:
|
||||||
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
||||||
raise Exception(f"Error en la respuesta SOAP: {str(e)}")
|
raise Exception(f"Error en la respuesta SOAP: {str(e)}")
|
||||||
|
|||||||
@@ -70,6 +70,13 @@ async def consume_ws_get_partida(**kwargs):
|
|||||||
raise Exception("No se recibió respuesta del servicio SOAP")
|
raise Exception("No se recibió respuesta del servicio SOAP")
|
||||||
|
|
||||||
if soap_error(soap_response):
|
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")
|
raise Exception("Error en la respuesta del servicio SOAP")
|
||||||
|
|
||||||
logger.info("Respuesta SOAP exitosa, enviando documento")
|
logger.info("Respuesta SOAP exitosa, enviando documento")
|
||||||
@@ -77,23 +84,14 @@ 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"
|
||||||
try:
|
try:
|
||||||
if soap_error(soap_response):
|
|
||||||
document_response = await partida_rest_controller.post_document(
|
document_response = await partida_rest_controller.post_document(
|
||||||
soap_response=soap_response,
|
soap_response=soap_response,
|
||||||
organizacion=kwargs.get('pedimento').get('organizacion'),
|
organizacion=kwargs.get('pedimento').get('organizacion'),
|
||||||
pedimento=kwargs.get('pedimento').get('id'),
|
pedimento=kwargs.get('pedimento').get('id'),
|
||||||
file_name=f"vu_PT_{pedimento_app}_{partida.get('numero', '')}_ERROR.xml",
|
file_name=_file_name,
|
||||||
document_type=10,
|
document_type=1,
|
||||||
)
|
)
|
||||||
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:
|
except Exception as e:
|
||||||
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
logger.error(f"Error detectado en la respuesta SOAP: {str(e)}")
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ async def consume_ws_get_pedimento_completo(**kwargs) -> Dict[str, Any]:
|
|||||||
|
|
||||||
if soap_error(soap_response):
|
if soap_error(soap_response):
|
||||||
logger.error(f"Error en respuesta SOAP: {soap_response.text if hasattr(soap_response, 'text') else 'Sin detalles'}")
|
logger.error(f"Error en respuesta SOAP: {soap_response.text if hasattr(soap_response, 'text') else 'Sin detalles'}")
|
||||||
|
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")
|
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
|
||||||
|
|
||||||
# Extraer datos del XML
|
# Extraer datos del XML
|
||||||
@@ -88,23 +95,13 @@ async def consume_ws_get_pedimento_completo(**kwargs) -> Dict[str, Any]:
|
|||||||
|
|
||||||
# Enviar documento
|
# Enviar documento
|
||||||
try:
|
try:
|
||||||
if soap_error(soap_response):
|
document_response = await pedimento_rest_controller.post_document(
|
||||||
document_response = await pedimento_rest_controller.post_document(
|
soap_response=soap_response,
|
||||||
soap_response=None,
|
organizacion=pedimento_data.get('organizacion'),
|
||||||
organizacion=pedimento_data.get('organizacion'),
|
pedimento=pedimento_data.get('id'),
|
||||||
pedimento=pedimento_data.get('id'),
|
file_name=file_name,
|
||||||
file_name=f"vu_PC_{pedimento_data.get('pedimento_app', 'unknown')}_ERROR.xml",
|
document_type=2,
|
||||||
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")
|
||||||
|
|||||||
@@ -69,34 +69,18 @@ async def obtener_remesa(**kwargs) -> Dict[str, Any]:
|
|||||||
data=soap_xml,
|
data=soap_xml,
|
||||||
headers=soap_headers
|
headers=soap_headers
|
||||||
)
|
)
|
||||||
|
|
||||||
if not soap_response:
|
|
||||||
raise HTTPException(status_code=500, detail="No se recibió respuesta del servicio SOAP")
|
|
||||||
|
|
||||||
if soap_error(soap_response):
|
|
||||||
logger.error(f"Error en respuesta SOAP: {soap_response.text if hasattr(soap_response, 'text') else 'Sin detalles'}")
|
|
||||||
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
|
|
||||||
|
|
||||||
|
|
||||||
# Extraer datos del XML
|
|
||||||
try:
|
|
||||||
remesas_data = remesa_xml_scraper.extract_remesas(soap_response.text)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Error al extraer datos XML: {e}")
|
|
||||||
raise HTTPException(status_code=500, detail="Error al procesar respuesta XML")
|
|
||||||
|
|
||||||
# Generar nombre de archivo
|
# Generar nombre de archivo
|
||||||
file_name = f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}.xml"
|
file_name = f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}.xml"
|
||||||
|
|
||||||
# Enviar documento
|
# Enviar documento
|
||||||
try:
|
try:
|
||||||
if soap_error(soap_response):
|
if soap_error(soap_response):
|
||||||
|
file_name = f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}.xml"
|
||||||
document_response = await remesa_rest_controller.post_document(
|
document_response = await remesa_rest_controller.post_document(
|
||||||
soap_response=None,
|
soap_response=soap_response,
|
||||||
organizacion=pedimento_data.get('organizacion'),
|
organizacion=pedimento_data.get('organizacion'),
|
||||||
pedimento=pedimento_data.get('id'),
|
pedimento=pedimento_data.get('id'),
|
||||||
file_name=f"vu_RM_{pedimento_data.get('pedimento_app', 'unknown')}_ERROR.xml",
|
file_name=file_name,
|
||||||
document_type=10,
|
document_type=10,
|
||||||
)
|
)
|
||||||
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
|
raise HTTPException(status_code=500, detail="Error en la respuesta del servicio SOAP")
|
||||||
@@ -108,11 +92,20 @@ async def obtener_remesa(**kwargs) -> Dict[str, Any]:
|
|||||||
file_name=file_name,
|
file_name=file_name,
|
||||||
document_type=3,
|
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")
|
||||||
|
|
||||||
|
# Extraer datos del XML
|
||||||
|
try:
|
||||||
|
remesas_data = remesa_xml_scraper.extract_remesas(soap_response.text)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error al extraer datos XML: {e}")
|
||||||
|
raise HTTPException(status_code=500, detail="Error al procesar respuesta XML")
|
||||||
|
|
||||||
|
|
||||||
logger.info(f"Remesa procesada exitosamente: {pedimento_data.get('pedimento')}")
|
logger.info(f"Remesa procesada exitosamente: {pedimento_data.get('pedimento')}")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user