From ddc6fb8a98db4309819467c668893069e66de063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Fri, 10 Oct 2014 11:27:13 +0200 Subject: [PATCH] [ldap_crans] En rend un peu plus lisible le calcul de fin adh/conn --- gestion/config/config.py | 1 + gestion/ldap_crans.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gestion/config/config.py b/gestion/config/config.py index daad1c22..28466f73 100644 --- a/gestion/config/config.py +++ b/gestion/config/config.py @@ -8,6 +8,7 @@ import datetime # Fichier généré à partir de bcfg2 from config_srv import adm_only, role +gtfepoch = "19700101000000Z" ##### Gestion des câblages # Selon la date, on met : # -ann_scol : Année scolaire en cours diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index f18b5f99..1bf39a1a 100755 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -1492,7 +1492,12 @@ class BaseProprietaire(BaseClasseCrans): # On récupère sur les factures l'ensemble de celles comportant une adhésion. adh_factures = self.factures_adh() - finAdh = max([0.0] + [fromGeneralizedTimeFormat(facture._data.get('finAdhesion', ["19700101000000Z"])[0]) for facture in adh_factures if facture.controle() != "FALSE" and facture.recuPaiement() is not None]) + fgtf = lambda fac:fromGeneralizedTimeFormat(fac._data.get('finAdhesion', [config.gtfepoch])[0]) + finAdh = max([0.0] + [fgtf(facture) for facture + in adh_factures + if facture.controle() != "FALSE" + and facture.recuPaiement() is not None + ]) if update == False: return finAdh @@ -2382,7 +2387,12 @@ class Adherent(BaseProprietaire): # On récupère sur les factures l'ensemble de celles comportant une connexion. conn_factures = self.factures_conn() - finConn = max([0.0] + [fromGeneralizedTimeFormat(facture._data.get('finConnexion', ["19700101000000Z"])[0]) for facture in conn_factures if facture.controle() != "FALSE" and facture.recuPaiement() is not None]) + fgtf = lambda fac:fromGeneralizedTimeFormat(fac._data.get('finConnexion', [config.gtfepoch])[0]) + finConn = max([0.0] + [fgtf(facture) for facture + in conn_factures + if facture.controle() != "FALSE" + and facture.recuPaiement() is not None + ]) if mois is None: return finConn