mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
Modification de create_cotis
This commit is contained in:
parent
9ee42c0743
commit
50b8420dd4
1 changed files with 7 additions and 4 deletions
|
@ -32,11 +32,14 @@ def form(ctx, template, request):
|
|||
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)
|
||||
if date_start:
|
||||
end_adhesion = Cotisation.objects.filter(vente=Vente.objects.filter(facture=Facture.objects.filter(user=user).exclude(valid=False))).filter(date_start__lt=date_start).aggregate(models.Max('date_end'))['date_end__max']
|
||||
else:
|
||||
end_adhesion = user.end_adhesion()
|
||||
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
|
||||
end_adhesion = end_adhesion or date_start
|
||||
date_max = max(end_adhesion, date_start)
|
||||
cotisation.date_start = date_max
|
||||
cotisation.date_end = cotisation.date_start + relativedelta(months=duration)
|
||||
cotisation.save()
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue