Commit 4138d4a2 by Javier

Usuario Ext

parent 6a172079
...@@ -132,19 +132,38 @@ def update_balance(target_clis: list[str]) -> Tuple[int, int]: ...@@ -132,19 +132,38 @@ def update_balance(target_clis: list[str]) -> Tuple[int, int]:
with typer.progressbar(active_users(), label="Actualizando Balance") as progress: with typer.progressbar(active_users(), label="Actualizando Balance") as progress:
for sip_account in progress: for sip_account in progress:
if sip_account['username'] in target_clis: if sip_account['username'] in target_clis:
# Cálculo de Parámetros
flat_rate = sip_account['offer'] if sip_account['plan'] == TARIFA_PLANA_ID else None flat_rate = sip_account['offer'] if sip_account['plan'] == TARIFA_PLANA_ID else None
credit = 999.00 if sip_account['credit'] <= 0 and sip_account['postpaid'] == True else round(sip_account['credit'],2)
# Si la cuenta es emisora de llamadas, añadimos ClaveEXT
if sip_account['credit'] > 0:
cursor.execute(
"""UPDATE [bdd_wifi].[dbo].[TB_ServicioFijo]
SET SaldoActual=?, Activo=?, TarifaPlana=?, Pospago=?, IdTarifa=?, UsuarioEXT=?,
ClaveEXT=? WHERE DDI=? AND FechaBaja is NULL""",
(credit, sip_account['active'],
flat_rate, sip_account['postpaid'], sip_account['plan'], sip_account['username'],
sip_account['password'], sip_account['username'])
)
else:
cursor.execute( cursor.execute(
"""UPDATE [bdd_wifi].[dbo].[TB_ServicioFijo] """UPDATE [bdd_wifi].[dbo].[TB_ServicioFijo]
SET SaldoActual=?, Activo=?, TarifaPlana=?, Pospago=?, IdTarifa=? SET SaldoActual=?, Activo=?, TarifaPlana=?, Pospago=?, IdTarifa=?
WHERE DDI=? AND FechaBaja is not NULL""", WHERE DDI=? AND FechaBaja is NULL""",
(sip_account['credit'], sip_account['active'], (credit, sip_account['active'],
flat_rate, sip_account['postpaid'], sip_account['plan'], sip_account['username']) flat_rate, sip_account['postpaid'], sip_account['plan'], sip_account['username'])
) )
updated = updated + 1 updated = updated + 1
cnx.commit()
else: else:
non_updated = non_updated + 1 non_updated = non_updated + 1
return updated, non_updated return updated, non_updated
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment