[whos] Méthodes pour visualiser les factures
This commit is contained in:
parent
f390e9bc9e
commit
04a129f879
1 changed files with 121 additions and 4 deletions
125
gestion/whos.py
125
gestion/whos.py
|
@ -142,6 +142,8 @@ def aff(qqch,mtech=0) :
|
||||||
cprint(machines_brief(qqch))
|
cprint(machines_brief(qqch))
|
||||||
elif t == 'cid':
|
elif t == 'cid':
|
||||||
cprint(clubs_brief(qqch))
|
cprint(clubs_brief(qqch))
|
||||||
|
elif t == 'fid':
|
||||||
|
cprint(factures_brief(qqch))
|
||||||
else :
|
else :
|
||||||
i = 0
|
i = 0
|
||||||
for c in qqch :
|
for c in qqch :
|
||||||
|
@ -154,6 +156,8 @@ def aff(qqch,mtech=0) :
|
||||||
cprint(machine_details(c).strip())
|
cprint(machine_details(c).strip())
|
||||||
elif t == 'cid':
|
elif t == 'cid':
|
||||||
cprint(club_details(c).strip())
|
cprint(club_details(c).strip())
|
||||||
|
elif t == 'fid':
|
||||||
|
cprint(facture_details(c).strip())
|
||||||
|
|
||||||
# affiche le nombre de résultats
|
# affiche le nombre de résultats
|
||||||
if len(qqch) > 1:
|
if len(qqch) > 1:
|
||||||
|
@ -262,6 +266,59 @@ def machines_brief(machines) :
|
||||||
largeur = [5, 5, 13, 18, '*', 5, 10],
|
largeur = [5, 5, 13, 18, '*', 5, 10],
|
||||||
alignement = ['d', 'd', 'c', 'c', 'c', 'g', 'c'])
|
alignement = ['d', 'd', 'c', 'c', 'c', 'g', 'c'])
|
||||||
|
|
||||||
|
def factures_brief(factures) :
|
||||||
|
"""
|
||||||
|
Formatage sous forme d'un tableau des propriétés de la liste de machine :
|
||||||
|
* fid
|
||||||
|
* priorio
|
||||||
|
* articles
|
||||||
|
* modePaiement
|
||||||
|
* recuPaiement
|
||||||
|
* controle
|
||||||
|
* total
|
||||||
|
"""
|
||||||
|
data = []
|
||||||
|
|
||||||
|
# Copie locale triée par nom
|
||||||
|
factures = [] + factures
|
||||||
|
factures.sort(lambda x, y: cmp(int(x.id()), int(y.id())))
|
||||||
|
|
||||||
|
for facture in factures:
|
||||||
|
# Propriétaire
|
||||||
|
a = facture.proprietaire()
|
||||||
|
p = a.Nom()
|
||||||
|
|
||||||
|
# A jour administrativement
|
||||||
|
if not a.paiement_ok():
|
||||||
|
p = coul(p,'rouge')
|
||||||
|
|
||||||
|
# Contrôle
|
||||||
|
controle = facture.controle()
|
||||||
|
if controle == "TRUE":
|
||||||
|
controle = coul("Validée", "vert")
|
||||||
|
elif controle == "FALSE":
|
||||||
|
controle = coul("Invalide", "rouge")
|
||||||
|
else:
|
||||||
|
controle = "N/A"
|
||||||
|
|
||||||
|
# Données
|
||||||
|
data.append([
|
||||||
|
facture.id(),
|
||||||
|
p,
|
||||||
|
', '.join(article['code'] for article in facture.articles()),
|
||||||
|
facture.modePaiement(),
|
||||||
|
coul("OK", "vert") if facture.recuPaiement() else coul("NON", "rouge"),
|
||||||
|
controle,
|
||||||
|
unicode(facture.total()) + u" €",
|
||||||
|
])
|
||||||
|
|
||||||
|
return u"Le propriétaire en rouge signale un problème administratif.\n" + \
|
||||||
|
tableau(data,
|
||||||
|
titre = [u'fid', u'Propriétaire', u'Articles', u'Mode de paiement', u'Payé', u"Contrôle", u"Total"],
|
||||||
|
largeur = [5, 16, '*', 16, 10, 10, 8],
|
||||||
|
alignement = ['d', 'g', 'g', 'c', 'c', 'g', 'd']
|
||||||
|
)
|
||||||
|
|
||||||
def clubs_brief(clubs) :
|
def clubs_brief(clubs) :
|
||||||
"""
|
"""
|
||||||
Formatage sous forme de tableau des infos sur la liste de clubs fournie :
|
Formatage sous forme de tableau des infos sur la liste de clubs fournie :
|
||||||
|
@ -364,18 +421,26 @@ def list_factures(factures) :
|
||||||
factures.sort(lambda x, y: cmp(x.id(), y.id()))
|
factures.sort(lambda x, y: cmp(x.id(), y.id()))
|
||||||
|
|
||||||
for f in factures :
|
for f in factures :
|
||||||
|
controle = f.controle()
|
||||||
|
if controle == "TRUE":
|
||||||
|
controle = coul("Validée", "vert")
|
||||||
|
elif controle == "FALSE":
|
||||||
|
controle = coul("Invalide", "rouge")
|
||||||
|
else:
|
||||||
|
controle = "N/A"
|
||||||
data.append([
|
data.append([
|
||||||
f.id(),
|
f.id(),
|
||||||
f.modePaiement(),
|
f.modePaiement(),
|
||||||
coul("OK", "vert") if f.recuPaiement() else coul("NON", "rouge"),
|
coul("OK", "vert") if f.recuPaiement() else coul("NON", "rouge"),
|
||||||
|
controle,
|
||||||
', '.join(a['code'] for a in f.articles()),
|
', '.join(a['code'] for a in f.articles()),
|
||||||
u"%s€" % sum([float(a['pu'])*int(a['nombre']) for a in f.articles()])
|
u"%s€" % sum([float(a['pu'])*int(a['nombre']) for a in f.articles()])
|
||||||
])
|
])
|
||||||
|
|
||||||
return tableau(data,
|
return tableau(data,
|
||||||
titre = [u'fid', u'Mode de paiement', u'Payé', u'Articles', u"Total"],
|
titre = [u'fid', u'Mode de paiement', u'Payé', u"Contrôle", u'Articles', u"Total"],
|
||||||
largeur = [5, 16, 6, '*', 8],
|
largeur = [5, 16, 6, 10, '*', 8],
|
||||||
alignement = ['d', 'g', 'c', 'g', 'd'])
|
alignement = ['d', 'g', 'c', 'c', 'g', 'd'])
|
||||||
|
|
||||||
def list_spec(machines) :
|
def list_spec(machines) :
|
||||||
"""
|
"""
|
||||||
|
@ -630,6 +695,55 @@ def adher_details(adher) :
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
def facture_details(facture) :
|
||||||
|
"""
|
||||||
|
Affichage du détail des propriétés d'une facture
|
||||||
|
"""
|
||||||
|
|
||||||
|
controle = facture.controle()
|
||||||
|
if controle == "TRUE":
|
||||||
|
controle = coul("Validée", "vert")
|
||||||
|
elif controle == "FALSE":
|
||||||
|
controle = coul("Invalide", "rouge")
|
||||||
|
else:
|
||||||
|
controle = "N/A"
|
||||||
|
|
||||||
|
f=u''
|
||||||
|
# Fid
|
||||||
|
f+= coul(u'fid=%s ' % facture.id() ,'bleu')
|
||||||
|
# Proprio
|
||||||
|
f += coul(u'Proprio : ','gras') + "%s\n" % facture.proprietaire().Nom()
|
||||||
|
|
||||||
|
# Articles
|
||||||
|
f += coul(u"Articles :", "gras") + u"\n"
|
||||||
|
f += list_articles(facture)
|
||||||
|
f += u"\n"
|
||||||
|
|
||||||
|
# Mode de paiement
|
||||||
|
f += coul(u"Mode de paiement : ", "gras")
|
||||||
|
f += facture.modePaiement()
|
||||||
|
f += u" "
|
||||||
|
f += coul(u"Paiement reçu : ", "gras")
|
||||||
|
f += coul(facture.recuPaiement(), "vert") if facture.recuPaiement() else coul(u"Non", "rouge")
|
||||||
|
f += u"\n"
|
||||||
|
f += coul(u"Contrôle : ", "gras")
|
||||||
|
f += controle
|
||||||
|
|
||||||
|
return f
|
||||||
|
|
||||||
|
def list_articles(facture):
|
||||||
|
"""Liste en détail des articles d'une facture
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
data = [[article['code'], article['designation'], article['nombre'], article['pu']] for article in facture.articles()]
|
||||||
|
|
||||||
|
return tableau(data,
|
||||||
|
titre = [u'Code', u'Désignation', u'Nombre', u"Prix unitaire"],
|
||||||
|
largeur = [10, '*', 10, 10],
|
||||||
|
alignement = ['c', 'g', 'c', 'c'])
|
||||||
|
|
||||||
|
|
||||||
clients_ipsec = None
|
clients_ipsec = None
|
||||||
def ipsec_ok(machine) :
|
def ipsec_ok(machine) :
|
||||||
"""Indique si une machine est correctement authentifiée"""
|
"""Indique si une machine est correctement authentifiée"""
|
||||||
|
@ -1292,7 +1406,7 @@ def __recherche() :
|
||||||
__usage_brief(c.args[0])
|
__usage_brief(c.args[0])
|
||||||
|
|
||||||
# Traitement du résultat
|
# Traitement du résultat
|
||||||
if not res['adherent'] and not res['machine'] and not res['club']:
|
if not res['adherent'] and not res['machine'] and not res['club'] and not res['facture']:
|
||||||
# Pas de résultat dans la base
|
# Pas de résultat dans la base
|
||||||
# Recherche sur chambre ?
|
# Recherche sur chambre ?
|
||||||
if arg.count('=') == 1 and arg.split('=')[0] == 'chbre' :
|
if arg.count('=') == 1 and arg.split('=')[0] == 'chbre' :
|
||||||
|
@ -1365,6 +1479,9 @@ def __recherche() :
|
||||||
if res['club']:
|
if res['club']:
|
||||||
cprint(u"Résultats trouvés parmi les clubs :", 'cyan')
|
cprint(u"Résultats trouvés parmi les clubs :", 'cyan')
|
||||||
aff(res['club'])
|
aff(res['club'])
|
||||||
|
if res['facture']:
|
||||||
|
cprint(u"Résultats trouvés parmi les factures :", 'cyan')
|
||||||
|
aff(res['facture'])
|
||||||
|
|
||||||
if __name__ == '__main__' :
|
if __name__ == '__main__' :
|
||||||
global debug
|
global debug
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue