From 107cbeadee9a67da3a130794e9991dfc3675d083 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Thu, 28 Oct 2021 17:21:07 +0200 Subject: [PATCH] #19 Tests * fixes bug where compensations still appeared on the public report despite being marked as deleted * fixes bug where eco account could be deducted into a negative account balance --- compensation/managers.py | 4 +++- ema/tests.py | 3 --- intervention/forms/modalForms.py | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 ema/tests.py diff --git a/compensation/managers.py b/compensation/managers.py index c97cd518..61933ee3 100644 --- a/compensation/managers.py +++ b/compensation/managers.py @@ -35,7 +35,9 @@ class CompensationManager(models.Manager): """ def get_queryset(self): - return super().get_queryset().select_related( + return super().get_queryset().filter( + deleted__isnull=True, + ).select_related( "modified", "intervention", "intervention__recorded", diff --git a/ema/tests.py b/ema/tests.py deleted file mode 100644 index 7ce503c2..00000000 --- a/ema/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/intervention/forms/modalForms.py b/intervention/forms/modalForms.py index 84e96126..a069267a 100644 --- a/intervention/forms/modalForms.py +++ b/intervention/forms/modalForms.py @@ -345,9 +345,9 @@ class NewDeductionModalForm(BaseModalForm): return False # Calculate valid surface - sum_surface = acc.get_surface_after_states() + deductable_surface = acc.deductable_surface sum_surface_deductions = acc.get_deductions_surface() - rest_surface = sum_surface - sum_surface_deductions + rest_surface = deductable_surface - sum_surface_deductions form_surface = float(self.cleaned_data["surface"]) is_valid_surface = form_surface < rest_surface if not is_valid_surface: