Merge branch 'master' into test
# Conflicts: # locale/de/LC_MESSAGES/django.mo # locale/de/LC_MESSAGES/django.po
This commit is contained in:
@@ -22,7 +22,7 @@ from compensation.utils.quality import CompensationQualityChecker
|
||||
from konova.models import BaseObject, AbstractDocument, Deadline, generate_document_file_upload_path, \
|
||||
GeoReferencedMixin, DeadlineType, ResubmitableObjectMixin
|
||||
from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, COMPENSATION_REMOVED_TEMPLATE, \
|
||||
DOCUMENT_REMOVED_TEMPLATE, DEADLINE_REMOVED, ADDED_DEADLINE, \
|
||||
DOCUMENT_REMOVED_TEMPLATE, DEADLINE_REMOVED, DEADLINE_ADDED, \
|
||||
COMPENSATION_ACTION_REMOVED, COMPENSATION_STATE_REMOVED, INTERVENTION_HAS_REVOCATIONS_TEMPLATE
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
@@ -76,7 +76,7 @@ class AbstractCompensation(BaseObject,
|
||||
|
||||
self.save()
|
||||
self.deadlines.add(deadline)
|
||||
self.mark_as_edited(user, edit_comment=ADDED_DEADLINE)
|
||||
self.mark_as_edited(user, edit_comment=DEADLINE_ADDED)
|
||||
return deadline
|
||||
|
||||
def remove_deadline(self, form):
|
||||
@@ -200,7 +200,9 @@ class AbstractCompensation(BaseObject,
|
||||
Returns:
|
||||
|
||||
"""
|
||||
return qs.aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
val = qs.aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
val = float('{:0.2f}'.format(val))
|
||||
return val
|
||||
|
||||
def quality_check(self) -> CompensationQualityChecker:
|
||||
""" Performs data quality check
|
||||
|
||||
@@ -61,7 +61,7 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
|
||||
|
||||
def clean(self):
|
||||
# Deductable surface can not be larger than added states after surface
|
||||
after_state_sum = self.get_state_after_surface_sum()
|
||||
after_state_sum = self.get_surface_after_states()
|
||||
if self.deductable_surface > after_state_sum:
|
||||
raise ValidationError(_("Deductable surface can not be larger than existing surfaces in after states"))
|
||||
|
||||
@@ -100,15 +100,9 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
|
||||
Returns:
|
||||
sum_surface (float)
|
||||
"""
|
||||
return self.deductions.all().aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
|
||||
def get_state_after_surface_sum(self) -> float:
|
||||
""" Calculates the account's after state surface sum
|
||||
|
||||
Returns:
|
||||
sum_surface (float)
|
||||
"""
|
||||
return self.after_states.all().aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
val = self.deductions.all().aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
val = float('{:0.2f}'.format(val))
|
||||
return val
|
||||
|
||||
def __calculate_deductable_rest(self):
|
||||
""" Calculates available rest surface of the eco account
|
||||
@@ -118,10 +112,7 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
|
||||
Returns:
|
||||
ret_val_total (float): Total amount
|
||||
"""
|
||||
deductions = self.deductions.filter(
|
||||
intervention__deleted=None,
|
||||
)
|
||||
deductions_surfaces = deductions.aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
deductions_surfaces = self.get_deductions_surface()
|
||||
|
||||
available_surface = self.deductable_surface
|
||||
if available_surface is None:
|
||||
|
||||
Reference in New Issue
Block a user