|
|
|
@ -238,7 +238,7 @@ class EcoAccount(AbstractCompensation):
|
|
|
|
|
Returns:
|
|
|
|
|
sum_surface (float)
|
|
|
|
|
"""
|
|
|
|
|
return self.withdraws.all().aggregate(Sum("surface"))["surface__sum"] or 0
|
|
|
|
|
return self.deductions.all().aggregate(Sum("surface"))["surface__sum"] or 0
|
|
|
|
|
|
|
|
|
|
def get_available_rest(self, as_percentage: bool = False):
|
|
|
|
|
""" Calculates available rest surface of the eco account
|
|
|
|
@ -250,7 +250,7 @@ class EcoAccount(AbstractCompensation):
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
ret_val = 0
|
|
|
|
|
deductions = self.withdraws.filter(
|
|
|
|
|
deductions = self.deductions.filter(
|
|
|
|
|
intervention__deleted=None,
|
|
|
|
|
)
|
|
|
|
|
deductions_surfaces = deductions.aggregate(Sum("surface"))["surface__sum"] or 0
|
|
|
|
@ -299,7 +299,7 @@ class EcoAccount(AbstractCompensation):
|
|
|
|
|
return ret_msgs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EcoAccountWithdraw(BaseResource):
|
|
|
|
|
class EcoAccountDeduction(BaseResource):
|
|
|
|
|
"""
|
|
|
|
|
A deduction object for eco accounts
|
|
|
|
|
"""
|
|
|
|
@ -309,7 +309,7 @@ class EcoAccountWithdraw(BaseResource):
|
|
|
|
|
null=True,
|
|
|
|
|
blank=True,
|
|
|
|
|
help_text="Deducted from",
|
|
|
|
|
related_name="withdraws",
|
|
|
|
|
related_name="deductions",
|
|
|
|
|
)
|
|
|
|
|
surface = models.FloatField(
|
|
|
|
|
null=True,
|
|
|
|
@ -325,7 +325,7 @@ class EcoAccountWithdraw(BaseResource):
|
|
|
|
|
null=True,
|
|
|
|
|
blank=True,
|
|
|
|
|
help_text="Deducted for",
|
|
|
|
|
related_name="withdraws",
|
|
|
|
|
related_name="deductions",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|