1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-09-09 10:45:36 +02:00
parent af4be98b5b
commit 0dd3da5c01
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 16 additions and 15 deletions

View File

@ -3,6 +3,7 @@
from datetime import date from datetime import date
from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import MinValueValidator from django.core.validators import MinValueValidator
@ -11,10 +12,8 @@ from django.db.models import Q
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from member.models import Club, Membership from member.models import Club, Membership
from note.models import NoteSpecial, SpecialTransaction, MembershipTransaction, NoteUser from note.models import NoteSpecial, SpecialTransaction, MembershipTransaction, NoteUser
from wei.models import WEIClub
class Invoice(models.Model): class Invoice(models.Model):
@ -319,10 +318,8 @@ class SogeCredit(models.Model):
bde = Club.objects.get(name="BDE") bde = Club.objects.get(name="BDE")
kfet = Club.objects.get(name="Kfet") kfet = Club.objects.get(name="Kfet")
wei = WEIClub.objects.order_by('-year').first()
bde_qs = Membership.objects.filter(user=self.user, club=bde, date_start__gte=bde.membership_start) bde_qs = Membership.objects.filter(user=self.user, club=bde, date_start__gte=bde.membership_start)
kfet_qs = Membership.objects.filter(user=self.user, club=kfet, date_start__gte=kfet.membership_start) kfet_qs = Membership.objects.filter(user=self.user, club=kfet, date_start__gte=kfet.membership_start)
wei_qs = Membership.objects.filter(user=self.user, club=wei, date_start__gte=wei.membership_start)
if bde_qs.exists(): if bde_qs.exists():
m = bde_qs.get() m = bde_qs.get()
@ -334,6 +331,10 @@ class SogeCredit(models.Model):
if m.transaction not in self.transactions.all(): if m.transaction not in self.transactions.all():
self.transactions.add(m.transaction) self.transactions.add(m.transaction)
if 'wei' in settings.INSTALLED_APPS:
from wei.models import WEIClub
wei = WEIClub.objects.order_by('-year').first()
wei_qs = Membership.objects.filter(user=self.user, club=wei, date_start__gte=wei.membership_start)
if wei_qs.exists(): if wei_qs.exists():
m = wei_qs.get() m = wei_qs.get()
if m.transaction not in self.transactions.all(): if m.transaction not in self.transactions.all():