From 76531595ad6400625debddbdd9c6075678fb000d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 16 Sep 2021 10:58:23 +0200 Subject: [PATCH] =?UTF-8?q?80=20=E2=82=AC=20for=20people=20that=20opened?= =?UTF-8?q?=20an=20account=20to=20Soci=C3=A9t=C3=A9=20g=C3=A9n=C3=A9rale?= =?UTF-8?q?=20and=20don't=20go=20to=20the=20WEI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yohann D'ANELLO --- apps/treasury/models.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/treasury/models.py b/apps/treasury/models.py index 3ba1ee7c..28351531 100644 --- a/apps/treasury/models.py +++ b/apps/treasury/models.py @@ -1,6 +1,6 @@ # Copyright (C) 2018-2021 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later - +import datetime from datetime import date from django.conf import settings @@ -305,8 +305,16 @@ class SogeCredit(models.Model): @property def amount(self): - return self.credit_transaction.total if self.valid \ - else sum(transaction.total for transaction in self.transactions.all()) + if self.valid: + return self.credit_transaction.total + amount = sum(transaction.total for transaction in self.transactions.all()) + if 'wei' in settings.INSTALLED_APPS: + from wei.models import WEIMembership + if not WEIMembership.objects.filter(club__weiclub__year=datetime.date.today().year, user=self.user)\ + .exists(): + # 80 € for people that don't go to WEI + amount += 8000 + return amount def update_transactions(self): """