diff --git a/interfaz.py b/interfaz.py index f301667..45b20f8 100644 --- a/interfaz.py +++ b/interfaz.py @@ -184,7 +184,7 @@ class InterfazFlet: self.page.run_task(_done) except Exception as ex: - print(f"[UI ERROR] {ex}") + log.error(f"[UI ERROR] Fallo en el hilo de sincronizacion: {ex}", exc_info=True) async def _err(): self.status_label.value = f"Error: {ex}" self.page.update() diff --git a/registros/scaf/reg_501.py b/registros/scaf/reg_501.py index 0371174..929e58f 100644 --- a/registros/scaf/reg_501.py +++ b/registros/scaf/reg_501.py @@ -9,10 +9,11 @@ class Generador501SCAF: """ # Lógica de Destino/Zona (SCAF a veces usa códigos distintos, pero el if parece igual) - destino = datos_pedi.get("OPCIONDESTINO", "") + # OJO: usar "or ''" y no get(k, ''), porque un NULL de BD llega como None y el default no aplica + destino = datos_pedi.get("OPCIONDESTINO") or "" codigo_destino = "9" if "Interior" in destino else "7" if any(x in destino for x in ["Región", "Franja"]) else "" - - clave_transfer = datos_cliente.get("CLAVETRANSFER", "").strip() if datos_cliente else "" + + clave_transfer = (datos_cliente.get("CLAVETRANSFER") or "").strip() if datos_cliente else "" # Construcción del Registro 501 SCAF registro = { diff --git a/registros/scaii/reg_501.py b/registros/scaii/reg_501.py index b532974..67d543d 100644 --- a/registros/scaii/reg_501.py +++ b/registros/scaii/reg_501.py @@ -9,11 +9,12 @@ class Generador501: """ # Lógica de Destino/Zona (Opcional) - destino = datos_pedi.get("Destino", "") + # OJO: usar "or ''" y no get(k, ''), porque un NULL de BD llega como None y el default no aplica + destino = datos_pedi.get("Destino") or "" codigo_destino = "9" if "Interior" in destino else "7" if any(x in destino for x in ["Región", "Franja"]) else "" - + # Clave del Importador/Exportador - clave_transfer = datos_cliente.get("CLAVETRANSFER", "").strip() if datos_cliente else "" + clave_transfer = (datos_cliente.get("CLAVETRANSFER") or "").strip() if datos_cliente else "" # Construcción del Registro 501 registro = {