From a9d69d1fb813e89fc73ecd7dce4c33359e590d6f Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Wed, 26 Oct 2016 14:05:18 +0200 Subject: [PATCH] Calcul de la periode de cotiz en mieux --- cotisations/models.py | 8 ++++---- cotisations/views.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cotisations/models.py b/cotisations/models.py index 7b729aa7..2db945b4 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -32,12 +32,12 @@ class Facture(models.Model): def facture_post_save(sender, **kwargs): facture = kwargs['instance'] user = facture.user - user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) @receiver(post_delete, sender=Facture) def facture_post_delete(sender, **kwargs): user = kwargs['instance'].user - user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) class Vente(models.Model): facture = models.ForeignKey('Facture', on_delete=models.CASCADE) @@ -64,14 +64,14 @@ def vente_post_save(sender, **kwargs): vente = kwargs['instance'] if vente.iscotisation: user = vente.facture.user - user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) @receiver(post_delete, sender=Vente) def vente_post_delete(sender, **kwargs): vente = kwargs['instance'] if vente.iscotisation: user = vente.facture.user - user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) + #user.ldap_sync(base=False, access_refresh=True, mac_refresh=False) class Article(models.Model): name = models.CharField(max_length=255) diff --git a/cotisations/views.py b/cotisations/views.py index 5debb53f..6db859ca 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -29,12 +29,13 @@ def form(ctx, template, request): c.update(csrf(request)) return render_to_response(template, c, context_instance=RequestContext(request)) -def create_cotis(vente, user, duration): +def create_cotis(vente, user, duration, date_start=False): """ Update et crée l'objet cotisation associé à une facture, prend en argument l'user, la facture pour la quantitéi, et l'article pour la durée""" cotisation=Cotisation(vente=vente) - date_max = user.end_adhesion() or timezone.now() - if date_max < timezone.now(): - datemax = timezone.now() + date_start = date_start or timezone.now() + date_max = user.end_adhesion() or date_start + if date_max < date_start: + date_max = date_start cotisation.date_start=date_max cotisation.date_end = cotisation.date_start + relativedelta(months=duration) cotisation.save()