-
Notifications
You must be signed in to change notification settings - Fork 0
/
desbloqueio.py
executable file
·37 lines (29 loc) · 1.12 KB
/
desbloqueio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# coding: utf8
import database
import datetime
from cliente import clientes_bloqueados
cursor = database.get_vigo_connection().cursor()
# Pego todos os clientes que estão bloqueados e
# verifico se há boletos em aberto/vencido para eles
for cliente in clientes_bloqueados():
cursor.execute('SELECT vencimento '
'FROM financeiro_boletos '
'WHERE '
' id_cliente=%s '
' AND ativo="S" '
' AND pago="0" '
' AND vencimento BETWEEN \'2015-01-01\' AND CURDATE() '
'ORDER BY vencimento '
'LIMIT 1 '
, (cliente.id,))
row = cursor.fetchone()
# Se não houver boletos em aberto/vencido, libero
if not row:
cliente.libera()
continue
vencimento = row[0]
dias_atraso = (datetime.date.today()-vencimento).days
if (dias_atraso<15):
cliente.libera()
database.get_vigo_connection().commit()