diff --git a/app/routes/contratos.py b/app/routes/contratos.py index 60423b3..e41689b 100644 --- a/app/routes/contratos.py +++ b/app/routes/contratos.py @@ -66,6 +66,12 @@ def ensure_defaults(): "INSERT INTO contratos (numero_contrato, nit_empresa, tipo_usuario, descripcion, excluir) VALUES (?,?,?,?,?)", (nc, nit, tu, desc, excluir), ) + else: + # Forzar excluir segĂșn el seed para que el DB siempre coincida + conn.execute( + "UPDATE contratos SET excluir=? WHERE numero_contrato=?", + (excluir, nc), + ) conn.commit() conn.close() diff --git a/app/services/json_generator.py b/app/services/json_generator.py index 160389a..fb5859a 100644 --- a/app/services/json_generator.py +++ b/app/services/json_generator.py @@ -218,9 +218,9 @@ def generar_rda_paciente(rows: list, default_profesional: str = "", default_espe result = { "codigoPrefijo": str(h.get("PREFIJO") or "").strip() or default_prefijo or "00", - "numero": numero_override if numero_override else ( + "numero": (numero_override if numero_override else ( str(h.get("NUM_FACTURA") or "").strip() if (h.get("NUM_FACTURA") or 0) != 0 else "" - ), + )).zfill(5) or "", "fecha": fecha, "codTercero": str(h.get("COD_PACIENTE") or "").strip(), "codVendedor": "00",