EcoAccount withdraws

* adds functionality for withdraws from eco accounts in detail view of interventions and eco account as well
* adds get_surface() method to AbstractCompensation class to provide a simple getter for a sql calculation
* adds get_surface_withdraws() method to EcoAccount class to provide a simple getter for a sql calculation
* renames some routes to match coherent rout naming
* adds logic check on NewWithdrawForm
* renames templates/table directory to templates/form, since there are form-table templates inside --> more clarity
* adds new autocomplete routes to konova/urls.py for Interventions and EcoAccounts
* adds/updates translations
* adds/updates template comments
* updates requirements.txt
This commit is contained in:
mipel
2021-08-10 10:42:04 +02:00
parent 17d697da92
commit 72d61a23da
21 changed files with 388 additions and 121 deletions
+18 -3
View File
@@ -7,9 +7,8 @@ Created on: 17.11.20
"""
from django.contrib.auth.models import User
from django.contrib.gis.db import models
from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import transaction
from django.utils import timezone
from django.core.validators import MinValueValidator
from django.db.models import Sum
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
@@ -121,6 +120,14 @@ class AbstractCompensation(BaseObject):
class Meta:
abstract = True
def get_surface(self) -> float:
""" Calculates the compensation's/account's surface
Returns:
sum_surface (float)
"""
return self.after_states.all().aggregate(Sum("surface"))["surface__sum"]
class Compensation(AbstractCompensation):
"""
@@ -188,6 +195,14 @@ class EcoAccount(AbstractCompensation):
def __str__(self):
return "{}".format(self.identifier)
def get_surface_withdraws(self) -> float:
""" Calculates the compensation's/account's surface
Returns:
sum_surface (float)
"""
return self.withdraws.all().aggregate(Sum("surface"))["surface__sum"]
class EcoAccountWithdraw(BaseResource):
"""