From f4d17f2f4597b4b704fbbb27a2126cab6751b3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 1 Sep 2014 02:49:20 +0200 Subject: [PATCH] =?UTF-8?q?[templates]=20Le=20listing=20des=20factures=20a?= =?UTF-8?q?ffiche=20le=20contr=C3=B4le.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- printing/templates.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/printing/templates.py b/printing/templates.py index 2b456fc..6e9fe44 100644 --- a/printing/templates.py +++ b/printing/templates.py @@ -129,16 +129,29 @@ def list_machines(machines, width=None): width=width) def list_factures(factures, width=None): - return tableau([ - [f['fid'][0], f['modePaiement'][0], - style("OK", "vert") if f.get('recuPaiement', []) else style("NON", "rouge"), - ' '.join(attr['code'] for attr in f.get('article',[])), - u"%s€" % sum([float(a['pu'])*int(a['nombre']) for a in f.get('article',[])]) - ] for f in factures], - titre = [u'fid', u'Mode de paiement', u'Payé', u'Articles', u"Total"], - largeur = [5, 16, 6, '*', 8], - alignement = ['d', 'g', 'c', 'g', 'd'], - width=width) + data = [] + for facture in factures: + controle = facture.get('controle', [""])[0] + if controle == "TRUE": + controle = style(u"Validée", "vert") + elif controle == "FALSE": + controle = style(u"Invalide", "rouge") + else: + controle = u"N/A" + data.append([ + facture['fid'][0], + facture['modePaiement'][0], + style("OK", "vert") if facture.get('recuPaiement', []) else style("NON", "rouge"), + controle, + ' '.join(attr['code'] for attr in facture.get('article',[])), + u"%s €" % sum([float(a['pu'])*int(a['nombre']) for a in facture.get('article',[])]) + ]) + return tableau( + data, + titre = [u'fid', u'Mode de paiement', u'Payé', u'Contrôle', u'Articles', u"Total"], + largeur = [5, 16, 6, 8, '*', 8], + alignement = ['d', 'g', 'c', 'c', 'g', 'd'], + width=width) def list_adherents(adherents, width=None): return tableau([