Files
SCAII_Sync_Client/registros/scaii/reg_504.py
2026-07-09 13:38:20 -05:00

36 lines
1.3 KiB
Python

from typing import List, Dict, Any
class Generador504SCAII:
@staticmethod
def preparar_listado_json(id_pedimento: int, contenedores_raw: str) -> List[Dict[str, Any]]:
"""
Procesa el string de contenedores (CONT1|TIPO1,CONT2|TIPO2)
y genera una lista de registros para la API.
"""
registros = []
if not contenedores_raw or contenedores_raw.strip() == "":
return registros
# En WinDev: FOR EACH STRING sContenedores OF DS_Facturas.c1 SEPARATED BY ","
bloques = contenedores_raw.split(",")
for bloque in bloques:
if not bloque.strip():
continue
# En WinDev: (sNumeroContenedor,sTipoContenedor) = StringSplit(sContenedores,"|")
partes = bloque.split("|")
num_contenedor = partes[0].strip() if len(partes) > 0 else ""
tipo_contenedor = partes[1].strip() if len(partes) > 1 else " "
if num_contenedor:
registros.append({
"id_pedimento_501": id_pedimento,
"numero_contenedor_504": num_contenedor,
"tipo_contenedor_504": tipo_contenedor,
"status_504": "1"
})
return registros