[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
|
||||
# -*- mode: python; coding: utf-8 -*-
|
||||
#
|
||||
# $Id: stats_cableurs.py,v 1.2 2007-09-29 17:50:09 dimino Exp $
|
||||
#
|
||||
# total_impression.py
|
||||
# -----------------
|
||||
#
|
||||
|
@ -56,23 +54,23 @@ def soldes_adherent(dlinf, dlsup, adherent, verbose):
|
|||
totalcredit = 0
|
||||
|
||||
for hist in adherent.historique():
|
||||
sep = ' '
|
||||
sep = ' '
|
||||
champ = hist.replace(',', '').replace(': ', '').split(sep)
|
||||
if datestrtoint(champ[0]) >= dlinf and (dlsup == 0 or datestrtoint(champ[0]) <= dlsup):
|
||||
if champ[3] == 'debit':
|
||||
if verbose >= 2:
|
||||
try:
|
||||
cprint(hist, 'rouge')
|
||||
except:
|
||||
cprint('Non affichable : ' + sep.join(champ[:4]), 'rouge')
|
||||
if verbose >= 2:
|
||||
try:
|
||||
cprint(hist, 'rouge')
|
||||
except:
|
||||
cprint('Non affichable : ' + sep.join(champ[:4]), 'rouge')
|
||||
totaldebit += float(champ[4])
|
||||
elif champ[3] == 'credit':
|
||||
if verbose >= 2:
|
||||
try:
|
||||
cprint(hist, 'vert')
|
||||
except:
|
||||
cprint('Non affichable : ' + sep.join(champ[:4]), 'vert')
|
||||
totalcredit += float(champ[4])
|
||||
elif champ[3] == 'credit':
|
||||
if verbose >= 2:
|
||||
try:
|
||||
cprint(hist, 'vert')
|
||||
except:
|
||||
cprint('Non affichable : ' + sep.join(champ[:4]), 'vert')
|
||||
totalcredit += float(champ[4])
|
||||
|
||||
return totaldebit, totalcredit
|
||||
|
||||
|
@ -87,30 +85,30 @@ def calcul_soldes():
|
|||
if len(sysargv) > 1:
|
||||
if '-h' in sysargv:
|
||||
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
||||
sys.exit(1)
|
||||
if '-v' in sysargv:
|
||||
verbose = 1
|
||||
sysargv.remove('-v')
|
||||
if '-vv' in sysargv:
|
||||
verbose = 2
|
||||
sysargv.remove('-vv')
|
||||
if len(sysargv) > 1:
|
||||
strdlinf = sysargv[1]
|
||||
try:
|
||||
sys.exit(1)
|
||||
if '-v' in sysargv:
|
||||
verbose = 1
|
||||
sysargv.remove('-v')
|
||||
if '-vv' in sysargv:
|
||||
verbose = 2
|
||||
sysargv.remove('-vv')
|
||||
if len(sysargv) > 1:
|
||||
strdlinf = sysargv[1]
|
||||
try:
|
||||
dlinf = datestrtoint(strdlinf)
|
||||
except:
|
||||
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
||||
except:
|
||||
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
||||
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
||||
sys.exit(1)
|
||||
if len(sysargv) > 2:
|
||||
strdlsup = sysargv[2]
|
||||
sys.exit(1)
|
||||
if len(sysargv) > 2:
|
||||
strdlsup = sysargv[2]
|
||||
dlsup = datestrtoint(strdlsup)
|
||||
try:
|
||||
try:
|
||||
dlsup = datestrtoint(strdlsup)
|
||||
except:
|
||||
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
||||
except:
|
||||
cprint('***** Date invalide : ' + strdlinf + ' *****', 'rouge')
|
||||
cprint(__doc__ % { 'prog': sysargv[0] }, 'bleu')
|
||||
sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
totaldebit = 0
|
||||
totalcredit = 0
|
||||
|
@ -119,24 +117,24 @@ def calcul_soldes():
|
|||
|
||||
for adherent in liste:
|
||||
adhdebit, adhcredit = soldes_adherent(dlinf, dlsup, adherent, verbose)
|
||||
if adhdebit + adhcredit > 0 and adhdebit + adhcredit < 1000000: # On evite Toto Passoir
|
||||
if verbose >= 2:
|
||||
cprint('-' * 40, 'cyan')
|
||||
if verbose >= 1:
|
||||
if adhdebit + adhcredit > 0 and adhdebit + adhcredit < 1000000: # On evite Toto Passoir
|
||||
if verbose >= 2:
|
||||
cprint('-' * 40, 'cyan')
|
||||
if verbose >= 1:
|
||||
cprint('Debit total pour ' + adherent.Nom() + ' : ' + str(adhdebit) + ' euros', 'rouge')
|
||||
cprint('Credit total pour ' + adherent.Nom() + ' : ' + str(adhcredit) + ' euros', 'vert')
|
||||
cprint('=' * 40, 'bleu')
|
||||
cprint('=' * 40, 'bleu')
|
||||
totaldebit += adhdebit
|
||||
totalcredit += adhcredit
|
||||
totalcredit += adhcredit
|
||||
if verbose >= 1:
|
||||
cprint('=' * 80, 'bleu')
|
||||
if dlinf == 0:
|
||||
cprint('Totaux :', 'cyan')
|
||||
cprint('Totaux :', 'cyan')
|
||||
else:
|
||||
if dlsup == 0:
|
||||
cprint('Totaux depuis le ' + strdlinf + ' :', 'cyan')
|
||||
else:
|
||||
cprint('Totaux entre le ' + strdlinf + ' et le ' + strdlsup + ' :', 'cyan')
|
||||
if dlsup == 0:
|
||||
cprint('Totaux depuis le ' + strdlinf + ' :', 'cyan')
|
||||
else:
|
||||
cprint('Totaux entre le ' + strdlinf + ' et le ' + strdlsup + ' :', 'cyan')
|
||||
cprint('Debit total : ' + str(totaldebit) + ' euros', 'rouge')
|
||||
cprint('Credit total : ' + str(totalcredit) + ' euros', 'vert')
|
||||
if verbose >= 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue