Se modifico la tarea para que haga el update del pedimento
Al parecer no se estaba mandando la fuente en el endpoint y eso fue lo que causaba el error
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,6 +8,9 @@ __pycache__/
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
main2.py
|
||||
sample.xml
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
|
||||
35
tasks.py
35
tasks.py
@@ -90,7 +90,40 @@ def pedimento_completo_task(self, request_data: Dict[str, Any]):
|
||||
if not soap_response:
|
||||
raise Exception("Error en la petición SOAP para pedimento completo")
|
||||
|
||||
|
||||
logger.info("[TASK] Petición SOAP para pedimento completo completada exitosamente")
|
||||
|
||||
# Actualizar datos del pedimento con información del XML (igual que en el endpoint)
|
||||
try:
|
||||
xml_content = soap_response.get('xml_content', {})
|
||||
if xml_content:
|
||||
update_content = {k: v for k, v in xml_content.items() if k != 'identificadores_ed'}
|
||||
update_content['existe_expediente'] = True
|
||||
pedimento_response = await rest_controller.put_pedimento(
|
||||
service_data['pedimento']['id'],
|
||||
update_content
|
||||
)
|
||||
logger.info("Pedimento actualizado exitosamente (TASK)")
|
||||
else:
|
||||
logger.warning("No se recibió contenido XML para actualizar el pedimento (TASK)")
|
||||
except Exception as e:
|
||||
logger.warning(f"No se pudo actualizar el pedimento (TASK, continuando proceso): {e}")
|
||||
|
||||
|
||||
# Procesar y guardar COVEs (igual que en el endpoint)
|
||||
try:
|
||||
coves = xml_content.get('coves', []) if 'xml_content' in locals() else []
|
||||
logger.warning(f"COVEs encontrados: {coves}")
|
||||
for cove in coves:
|
||||
logger.warning(f"Procesando COVE: {cove}")
|
||||
cove_result = await _post_coves(
|
||||
response_service=service_data,
|
||||
coves=coves
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error al procesar COVEs: {e}")
|
||||
cove_result = None
|
||||
|
||||
# Subir documento de pedimento completo si la petición fue exitosa
|
||||
try:
|
||||
upload_result = await _post_edocuments(
|
||||
@@ -742,7 +775,6 @@ def coves_task(self, **kwargs):
|
||||
|
||||
return run_async_task(_execute_coves)
|
||||
|
||||
|
||||
@celery_app.task(bind=True)
|
||||
def acuse_cove_task(self, **kwargs):
|
||||
"""Tarea asíncrona para obtener acuse de COVE"""
|
||||
@@ -891,3 +923,4 @@ def acuse_cove_task(self, **kwargs):
|
||||
raise e
|
||||
|
||||
return run_async_task(_execute_acuse_cove)
|
||||
|
||||
|
||||
@@ -315,6 +315,7 @@ async def get_soap_pedimento_completo(credenciales, response_service, soap_contr
|
||||
|
||||
data['organizacion'] = response_service['organizacion']
|
||||
data['id'] = response_service['pedimento']['id']
|
||||
data['fuente'] = 2
|
||||
|
||||
return {
|
||||
"servicio": response_service,
|
||||
|
||||
Reference in New Issue
Block a user