mirror of https://gitlab.crans.org/bde/nk20
[Treasury] Don't add non-existing transactions to sogé-credits (eg. when membership is free)
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
76531595ad
commit
a3a9dfc812
|
@ -331,13 +331,15 @@ class SogeCredit(models.Model):
|
||||||
|
|
||||||
if bde_qs.exists():
|
if bde_qs.exists():
|
||||||
m = bde_qs.get()
|
m = bde_qs.get()
|
||||||
if m.transaction not in self.transactions.all():
|
if MembershipTransaction.objects.filter(membership=m).exists(): # non-free membership
|
||||||
self.transactions.add(m.transaction)
|
if m.transaction not in self.transactions.all():
|
||||||
|
self.transactions.add(m.transaction)
|
||||||
|
|
||||||
if kfet_qs.exists():
|
if kfet_qs.exists():
|
||||||
m = kfet_qs.get()
|
m = kfet_qs.get()
|
||||||
if m.transaction not in self.transactions.all():
|
if MembershipTransaction.objects.filter(membership=m).exists(): # non-free membership
|
||||||
self.transactions.add(m.transaction)
|
if m.transaction not in self.transactions.all():
|
||||||
|
self.transactions.add(m.transaction)
|
||||||
|
|
||||||
if 'wei' in settings.INSTALLED_APPS:
|
if 'wei' in settings.INSTALLED_APPS:
|
||||||
from wei.models import WEIClub
|
from wei.models import WEIClub
|
||||||
|
@ -345,8 +347,9 @@ class SogeCredit(models.Model):
|
||||||
wei_qs = Membership.objects.filter(user=self.user, club=wei, date_start__gte=wei.membership_start)
|
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 MembershipTransaction.objects.filter(membership=m).exists(): # non-free membership
|
||||||
self.transactions.add(m.transaction)
|
if m.transaction not in self.transactions.all():
|
||||||
|
self.transactions.add(m.transaction)
|
||||||
|
|
||||||
for tr in self.transactions.all():
|
for tr in self.transactions.all():
|
||||||
tr.valid = False
|
tr.valid = False
|
||||||
|
|
Loading…
Reference in New Issue