8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 03:43:12 +00:00

Calcul de la periode de cotiz en mieux

This commit is contained in:
Gabriel Detraz 2016-10-26 14:05:18 +02:00
parent be948084cf
commit a9d69d1fb8
2 changed files with 9 additions and 8 deletions

View file

@ -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)

View file

@ -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()