se modifico tasks y views de auditor
This commit is contained in:
@@ -51,28 +51,6 @@ def auditor_descargas(pedimento, servicio, related_name, variable, mensaje):
|
||||
print(f"✗ No se encontró proceso de auditoría para pedimento {pedimento_id}.")
|
||||
|
||||
## Auditar pedimentos
|
||||
@shared_task
|
||||
def auditar_procesamiento_remesas(organizacion_id):
|
||||
pedimentos = obtener_pedimentos(organizacion_id)
|
||||
|
||||
for pedimento in pedimentos:
|
||||
if pedimento.remesas:
|
||||
# Tipo 3: Remesa
|
||||
if not pedimento.documents.filter(document_type=3).exists():
|
||||
ProcesamientoPedimento.objects.get_or_create(
|
||||
pedimento=pedimento,
|
||||
servicio_id=5, # ID del servicio de remesas
|
||||
organizacion=organizacion_id
|
||||
)
|
||||
else:
|
||||
xml_data = extraer_coves(pedimento)
|
||||
if xml_data:
|
||||
for remesa in xml_data:
|
||||
Cove.objects.get_or_create(
|
||||
pedimento=pedimento,
|
||||
numero_cove=remesa.get('remesaSA'),
|
||||
organizacion=organizacion_id
|
||||
)
|
||||
|
||||
@shared_task
|
||||
def auditar_procesamiento_remesa_por_pedimento(pedimento_id):
|
||||
@@ -259,4 +237,68 @@ def auditar_acuse(organizacion_id):
|
||||
variable='acuse_descargado',
|
||||
mensaje='acuse'
|
||||
)
|
||||
|
||||
|
||||
@shared_task
|
||||
def auditar_cove_por_pedimento(pedimento_id):
|
||||
try:
|
||||
from api.customs.models import Pedimento
|
||||
pedimento = Pedimento.objects.get(id=pedimento_id)
|
||||
auditor_descargas(
|
||||
pedimento,
|
||||
servicio=8,
|
||||
related_name='coves',
|
||||
variable='acuse_descargado',
|
||||
mensaje='COVE'
|
||||
)
|
||||
return {'success': True, 'pedimento_id': str(pedimento_id)}
|
||||
except Exception as e:
|
||||
return {'success': False, 'error': str(e), 'pedimento_id': str(pedimento_id)}
|
||||
|
||||
@shared_task
|
||||
def auditar_acuse_cove_por_pedimento(pedimento_id):
|
||||
try:
|
||||
from api.customs.models import Pedimento
|
||||
pedimento = Pedimento.objects.get(id=pedimento_id)
|
||||
auditor_descargas(
|
||||
pedimento,
|
||||
servicio=9,
|
||||
related_name='coves',
|
||||
variable='acuse_cove_descargado',
|
||||
mensaje='acuse de COVE'
|
||||
)
|
||||
return {'success': True, 'pedimento_id': str(pedimento_id)}
|
||||
except Exception as e:
|
||||
return {'success': False, 'error': str(e), 'pedimento_id': str(pedimento_id)}
|
||||
|
||||
@shared_task
|
||||
def auditar_edocument_por_pedimento(pedimento_id):
|
||||
try:
|
||||
from api.customs.models import Pedimento
|
||||
pedimento = Pedimento.objects.get(id=pedimento_id)
|
||||
auditor_descargas(
|
||||
pedimento,
|
||||
servicio=7,
|
||||
related_name='documentos',
|
||||
variable='edocument_descargado',
|
||||
mensaje='EDocument'
|
||||
)
|
||||
return {'success': True, 'pedimento_id': str(pedimento_id)}
|
||||
except Exception as e:
|
||||
return {'success': False, 'error': str(e), 'pedimento_id': str(pedimento_id)}
|
||||
|
||||
@shared_task
|
||||
def auditar_acuse_por_pedimento(pedimento_id):
|
||||
try:
|
||||
from api.customs.models import Pedimento
|
||||
pedimento = Pedimento.objects.get(id=pedimento_id)
|
||||
auditor_descargas(
|
||||
pedimento,
|
||||
servicio=6,
|
||||
related_name='documentos',
|
||||
variable='acuse_descargado',
|
||||
mensaje='acuse'
|
||||
)
|
||||
return {'success': True, 'pedimento_id': str(pedimento_id)}
|
||||
except Exception as e:
|
||||
return {'success': False, 'error': str(e), 'pedimento_id': str(pedimento_id)}
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ def procesar_pedimentos_completos(organizacion_id):
|
||||
respuestas = []
|
||||
for pedimento in pedimentos:
|
||||
if not pedimento.documents.filter(document_type=2).exists(): # Tipo 2: Pedimento Completo
|
||||
input("Presiona Enter para continuar...")
|
||||
# Convertir el pedimento a JSON usando el serializer
|
||||
pedimento_dict = pedimento_to_dict(pedimento)
|
||||
credenciales = Vucem.objects.filter(id=CredencialesImportador.objects.filter(rfc=pedimento.contribuyente).first().vucem.id).first()
|
||||
@@ -265,7 +266,6 @@ def procesar_remesas(organizacion_id):
|
||||
|
||||
print(f"Servicio enviado para pedimento {pedimento.pedimento}")
|
||||
|
||||
|
||||
@shared_task
|
||||
def procesar_coves(organizacion_id):
|
||||
pedimentos = Pedimento.objects.filter(
|
||||
@@ -429,3 +429,5 @@ def documentos_con_errores(organizacion_id):
|
||||
# Aquí puedes agregar lógica adicional para manejar documentos con errores
|
||||
# como enviar notificaciones, registrar en un log, etc.
|
||||
# documentos = Document.objects.all() --- IGNORE ---
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user