bug
This commit is contained in:
@@ -1,33 +1,5 @@
|
|||||||
from celery import group
|
from celery import group
|
||||||
@shared_task
|
|
||||||
def procesar_pedimento_completo_individual(pedimento_id):
|
|
||||||
pedimento = Pedimento.objects.get(id=pedimento_id)
|
|
||||||
if not pedimento.documents.filter(document_type=2).exists(): # Tipo 2: Pedimento Completo
|
|
||||||
pedimento_dict = pedimento_to_dict(pedimento)
|
|
||||||
credenciales = Vucem.objects.filter(
|
|
||||||
id=CredencialesImportador.objects.filter(rfc=pedimento.contribuyente).first().vucem.id
|
|
||||||
).first()
|
|
||||||
credenciales_dict = credenciales_to_dict(credenciales)
|
|
||||||
payload = {
|
|
||||||
"pedimento": pedimento_dict,
|
|
||||||
"credencial": credenciales_dict
|
|
||||||
}
|
|
||||||
response = requests.post(
|
|
||||||
f"{SERVICE_API_URL_V2}/services/pedimento_completo",
|
|
||||||
data=json.dumps(payload),
|
|
||||||
headers={"Content-Type": "application/json"}
|
|
||||||
)
|
|
||||||
print(f"Servicio enviado para pedimento {pedimento.pedimento}")
|
|
||||||
def procesar_pedimentos_completos_en_lotes(organizacion_id, batch_size=20):
|
|
||||||
pedimentos = Pedimento.objects.filter(organizacion_id=organizacion_id)
|
|
||||||
ids = list(pedimentos.values_list('id', flat=True))
|
|
||||||
for i in range(0, len(ids), batch_size):
|
|
||||||
batch = ids[i:i+batch_size]
|
|
||||||
job = group(
|
|
||||||
procesar_pedimento_completo_individual.s(ped_id)
|
|
||||||
for ped_id in batch
|
|
||||||
)
|
|
||||||
job.apply_async()
|
|
||||||
|
|
||||||
from celery import shared_task, group
|
from celery import shared_task, group
|
||||||
from api.customs.models import *
|
from api.customs.models import *
|
||||||
@@ -83,6 +55,37 @@ def partida_to_dict(partida):
|
|||||||
"numero": partida.numero_partida,
|
"numero": partida.numero_partida,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@shared_task
|
||||||
|
def procesar_pedimento_completo_individual(pedimento_id):
|
||||||
|
pedimento = Pedimento.objects.get(id=pedimento_id)
|
||||||
|
if not pedimento.documents.filter(document_type=2).exists(): # Tipo 2: Pedimento Completo
|
||||||
|
pedimento_dict = pedimento_to_dict(pedimento)
|
||||||
|
credenciales = Vucem.objects.filter(
|
||||||
|
id=CredencialesImportador.objects.filter(rfc=pedimento.contribuyente).first().vucem.id
|
||||||
|
).first()
|
||||||
|
credenciales_dict = credenciales_to_dict(credenciales)
|
||||||
|
payload = {
|
||||||
|
"pedimento": pedimento_dict,
|
||||||
|
"credencial": credenciales_dict
|
||||||
|
}
|
||||||
|
response = requests.post(
|
||||||
|
f"{SERVICE_API_URL_V2}/services/pedimento_completo",
|
||||||
|
data=json.dumps(payload),
|
||||||
|
headers={"Content-Type": "application/json"}
|
||||||
|
)
|
||||||
|
print(f"Servicio enviado para pedimento {pedimento.pedimento}")
|
||||||
|
|
||||||
|
def procesar_pedimentos_completos_en_lotes(organizacion_id, batch_size=20):
|
||||||
|
pedimentos = Pedimento.objects.filter(organizacion_id=organizacion_id)
|
||||||
|
ids = list(pedimentos.values_list('id', flat=True))
|
||||||
|
for i in range(0, len(ids), batch_size):
|
||||||
|
batch = ids[i:i+batch_size]
|
||||||
|
job = group(
|
||||||
|
procesar_pedimento_completo_individual.s(ped_id)
|
||||||
|
for ped_id in batch
|
||||||
|
)
|
||||||
|
job.apply_async()
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def procesar_pedimentos_completos(organizacion_id):
|
def procesar_pedimentos_completos(organizacion_id):
|
||||||
pedimentos = Pedimento.objects.filter(organizacion_id=organizacion_id)
|
pedimentos = Pedimento.objects.filter(organizacion_id=organizacion_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user