[total_impression.py] Cleanup
Ignore-this: 9d250c29fd9f3d4708ffa23af34cda6b darcs-hash:20110907100607-ddb99-788a31cf20359794f9e1cbb739910962d58b0a97.gz
This commit is contained in:
parent
2d53246bb7
commit
16cb2af317
1 changed files with 44 additions and 46 deletions
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- mode: python; coding: utf-8 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# $Id: stats_cableurs.py,v 1.2 2007-09-29 17:50:09 dimino Exp $
|
|
||||||
#
|
|
||||||
# total_impression.py
|
# total_impression.py
|
||||||
# -----------------
|
# -----------------
|
||||||
#
|
#
|
||||||
|
@ -56,23 +54,23 @@ def soldes_adherent(dlinf, dlsup, adherent, verbose):
|
||||||
totalcredit = 0
|
totalcredit = 0
|
||||||
|
|
||||||
for hist in adherent.historique():
|
for hist in adherent.historique():
|
||||||
sep = ' '
|
sep = ' '
|
||||||
champ = hist.replace(',', '').replace(': ', '').split(sep)
|
champ = hist.replace(',', '').replace(': ', '').split(sep)
|
||||||
if datestrtoint(champ[0]) >= dlinf and (dlsup == 0 or datestrtoint(champ[0]) <= dlsup):
|
if datestrtoint(champ[0]) >= dlinf and (dlsup == 0 or datestrtoint(champ[0]) <= dlsup):
|
||||||
if champ[3] == 'debit':
|
if champ[3] == 'debit':
|
||||||
if verbose >= 2:
|
if verbose >= 2:
|
||||||
try:
|
try:
|
||||||
cprint(hist, 'rouge')
|
cprint(hist, 'rouge')
|
||||||
except:
|
except:
|
||||||
cprint('Non affichable : ' + sep.join(champ[:4]), 'rouge')
|
cprint('Non affichable : ' + sep.join(champ[:4]), 'rouge')
|
||||||
totaldebit += float(champ[4])
|
totaldebit += float(champ[4])
|
||||||
elif champ[3] == 'credit':
|
elif champ[3] == 'credit':
|
||||||
if verbose >= 2:
|
if verbose >= 2:
|
||||||
try:
|
try:
|
||||||
cprint(hist, 'vert')
|
cprint(hist, 'vert')
|
||||||
except:
|
except:
|
||||||
cprint('Non affichable : ' + sep.join(champ[:4]), 'vert')
|
cprint('Non affichable : ' + sep.join(champ[:4]), 'vert')
|
||||||
totalcredit += float(champ[4])
|
totalcredit += float(champ[4])
|
||||||
|
|
||||||
return totaldebit, totalcredit
|
return totaldebit, totalcredit
|
||||||
|
|
||||||
|
@ -87,30 +85,30 @@ def calcul_soldes():
|
||||||
if len(sysargv) > 1:
|
if len(sysargv) > 1:
|
||||||
if '-h' in sysargv:
|
if '-h' in sysargv:
|
||||||
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if '-v' in sysargv:
|
if '-v' in sysargv:
|
||||||
verbose = 1
|
verbose = 1
|
||||||
sysargv.remove('-v')
|
sysargv.remove('-v')
|
||||||
if '-vv' in sysargv:
|
if '-vv' in sysargv:
|
||||||
verbose = 2
|
verbose = 2
|
||||||
sysargv.remove('-vv')
|
sysargv.remove('-vv')
|
||||||
if len(sysargv) > 1:
|
if len(sysargv) > 1:
|
||||||
strdlinf = sysargv[1]
|
strdlinf = sysargv[1]
|
||||||
try:
|
try:
|
||||||
dlinf = datestrtoint(strdlinf)
|
dlinf = datestrtoint(strdlinf)
|
||||||
except:
|
except:
|
||||||
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
||||||
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if len(sysargv) > 2:
|
if len(sysargv) > 2:
|
||||||
strdlsup = sysargv[2]
|
strdlsup = sysargv[2]
|
||||||
dlsup = datestrtoint(strdlsup)
|
dlsup = datestrtoint(strdlsup)
|
||||||
try:
|
try:
|
||||||
dlsup = datestrtoint(strdlsup)
|
dlsup = datestrtoint(strdlsup)
|
||||||
except:
|
except:
|
||||||
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
||||||
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
totaldebit = 0
|
totaldebit = 0
|
||||||
totalcredit = 0
|
totalcredit = 0
|
||||||
|
@ -119,28 +117,28 @@ def calcul_soldes():
|
||||||
|
|
||||||
for adherent in liste:
|
for adherent in liste:
|
||||||
adhdebit, adhcredit = soldes_adherent(dlinf, dlsup, adherent, verbose)
|
adhdebit, adhcredit = soldes_adherent(dlinf, dlsup, adherent, verbose)
|
||||||
if adhdebit + adhcredit > 0 and adhdebit + adhcredit < 1000000: # On evite Toto Passoir
|
if adhdebit + adhcredit > 0 and adhdebit + adhcredit < 1000000: # On evite Toto Passoir
|
||||||
if verbose >= 2:
|
if verbose >= 2:
|
||||||
cprint('-' * 40, 'cyan')
|
cprint('-' * 40, 'cyan')
|
||||||
if verbose >= 1:
|
if verbose >= 1:
|
||||||
cprint('Debit total pour ' + adherent.Nom() + ' : ' + str(adhdebit) + ' euros', 'rouge')
|
cprint('Debit total pour ' + adherent.Nom() + ' : ' + str(adhdebit) + ' euros', 'rouge')
|
||||||
cprint('Credit total pour ' + adherent.Nom() + ' : ' + str(adhcredit) + ' euros', 'vert')
|
cprint('Credit total pour ' + adherent.Nom() + ' : ' + str(adhcredit) + ' euros', 'vert')
|
||||||
cprint('=' * 40, 'bleu')
|
cprint('=' * 40, 'bleu')
|
||||||
totaldebit += adhdebit
|
totaldebit += adhdebit
|
||||||
totalcredit += adhcredit
|
totalcredit += adhcredit
|
||||||
if verbose >= 1:
|
if verbose >= 1:
|
||||||
cprint('=' * 80, 'bleu')
|
cprint('=' * 80, 'bleu')
|
||||||
if dlinf == 0:
|
if dlinf == 0:
|
||||||
cprint('Totaux :', 'cyan')
|
cprint('Totaux :', 'cyan')
|
||||||
else:
|
else:
|
||||||
if dlsup == 0:
|
if dlsup == 0:
|
||||||
cprint('Totaux depuis le ' + strdlinf + ' :', 'cyan')
|
cprint('Totaux depuis le ' + strdlinf + ' :', 'cyan')
|
||||||
else:
|
else:
|
||||||
cprint('Totaux entre le ' + strdlinf + ' et le ' + strdlsup + ' :', 'cyan')
|
cprint('Totaux entre le ' + strdlinf + ' et le ' + strdlsup + ' :', 'cyan')
|
||||||
cprint('Debit total : ' + str(totaldebit) + ' euros', 'rouge')
|
cprint('Debit total : ' + str(totaldebit) + ' euros', 'rouge')
|
||||||
cprint('Credit total : ' + str(totalcredit) + ' euros', 'vert')
|
cprint('Credit total : ' + str(totalcredit) + ' euros', 'vert')
|
||||||
if verbose >= 1:
|
if verbose >= 1:
|
||||||
cprint('=' * 80, 'bleu')
|
cprint('=' * 80, 'bleu')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
calcul_soldes()
|
calcul_soldes()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue