diff --git a/apps/member/migrations/0015_alter_profile_promotion.py b/apps/member/migrations/0015_alter_profile_promotion.py new file mode 100644 index 00000000..f838c563 --- /dev/null +++ b/apps/member/migrations/0015_alter_profile_promotion.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.4 on 2025-08-02 13:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('member', '0014_create_bda'), + ] + + operations = [ + migrations.AlterField( + model_name='profile', + name='promotion', + field=models.PositiveSmallIntegerField(default=2025, help_text='Year of entry to the school (None if not ENS student)', null=True, verbose_name='promotion'), + ), + ] diff --git a/apps/treasury/models.py b/apps/treasury/models.py index 214203a9..48709801 100644 --- a/apps/treasury/models.py +++ b/apps/treasury/models.py @@ -353,13 +353,11 @@ class SogeCredit(models.Model): def amount(self): if self.valid: return self.credit_transaction.total - amount = sum(max(transaction.total - 2000, 0) 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=self.credit_transaction.created_at.year, user=self.user).exists(): - # 80 € for people that don't go to WEI - amount += 8000 + amount = 0 + transactions_wei = self.transactions.filter(membership__club__weiclub__isnull=False) + amount += sum(max(transaction.total - transaction.membership.club.weiclub.fee_soge_credit, 0) for transaction in transactions_wei) + transactions_not_wei = self.transactions.filter(membership__club__weiclub__isnull=True) + amount += sum(transaction.total for transaction in transactions_not_wei) return amount def update_transactions(self): @@ -441,7 +439,7 @@ class SogeCredit(models.Model): With Great Power Comes Great Responsibility... """ - total_fee = sum(max(transaction.total - 2000, 0) for transaction in self.transactions.all() if not transaction.valid) + total_fee = self.amount if self.user.note.balance < total_fee: raise ValidationError(_("This user doesn't have enough money to pay the memberships with its note. " "Please ask her/him to credit the note before invalidating this credit.")) diff --git a/apps/wei/migrations/0017_alter_weiclub_fee_soge_credit.py b/apps/wei/migrations/0017_alter_weiclub_fee_soge_credit.py new file mode 100644 index 00000000..c78ffdd4 --- /dev/null +++ b/apps/wei/migrations/0017_alter_weiclub_fee_soge_credit.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.4 on 2025-08-02 13:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wei', '0016_weiregistration_fee_alter_weiclub_fee_soge_credit'), + ] + + operations = [ + migrations.AlterField( + model_name='weiclub', + name='fee_soge_credit', + field=models.PositiveIntegerField(default=0, verbose_name='membership fee (soge credit)'), + ), + ] diff --git a/apps/wei/models.py b/apps/wei/models.py index 18ba8a58..2c0653c7 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -40,7 +40,7 @@ class WEIClub(Club): fee_soge_credit = models.PositiveIntegerField( verbose_name=_("membership fee (soge credit)"), - default=2000, + default=0, ) class Meta: diff --git a/apps/wei/views.py b/apps/wei/views.py index e3355345..d180d3d9 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -798,11 +798,6 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update choose_bus_form.fields["team"].queryset = BusTeam.objects.filter(bus__wei=context["club"]) context["membership_form"] = choose_bus_form - if not self.object.soge_credit and self.object.user.profile.soge: - form = context["form"] - form.fields["soge_credit"].disabled = True - form.fields["soge_credit"].help_text = _("You already opened an account in the Société générale.") - return context def get_form(self, form_class=None): @@ -823,6 +818,10 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update form.fields["deposit_type"].required = True form.fields["deposit_type"].help_text = _("Choose how you want to pay the deposit") + if self.object.user.profile.soge: + form.fields["soge_credit"].disabled = True + form.fields["soge_credit"].help_text = _("You already opened an account in the Société générale.") + return form def get_membership_form(self, data=None, instance=None):