#232 Payment document linkage
* adds error message on intervention view if a payment has been added but no document has been uploaded yet * adds same check to quality checker, meaning no intervention can be recorded which has a payment but no document * adds trigger for sending data to egon on uploading a document in case of an already existing payment * adds translations
This commit is contained in:
@@ -10,4 +10,23 @@ from konova.forms.modals import NewDocumentModalForm
|
||||
|
||||
|
||||
class NewInterventionDocumentModalForm(NewDocumentModalForm):
|
||||
document_model = InterventionDocument
|
||||
document_model = InterventionDocument
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
""" Extension of regular NewDocumentModalForm
|
||||
|
||||
Checks whether payments exist on the intervention and sends the data to EGON
|
||||
|
||||
Args:
|
||||
*args ():
|
||||
**kwargs ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
doc = super().save(*args, **kwargs)
|
||||
|
||||
if self.instance.payments.exists():
|
||||
self.instance.send_data_to_egon()
|
||||
|
||||
return doc
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if has_payment_without_document %}
|
||||
<div class="alert alert-danger mb-0">
|
||||
{% trans 'You entered a payment. Please upload the legal document which defines the payment`s amount.' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card-body scroll-300 p-2">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
|
||||
@@ -21,8 +21,21 @@ class InterventionQualityChecker(AbstractQualityChecker):
|
||||
self._check_legal_data()
|
||||
self._check_compensations()
|
||||
self._check_geometry()
|
||||
self._check_payment_documents()
|
||||
self.valid = len(self.messages) == 0
|
||||
|
||||
def _check_payment_documents(self):
|
||||
""" Checks existence of documents in case of payments
|
||||
|
||||
There should be at least one legal document which defines the payment's total amount.
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
has_payment_without_document = self.obj.payments.exists() and not self.obj.get_documents()[1].exists()
|
||||
if has_payment_without_document:
|
||||
self._add_missing_attr_name(_("Documents"))
|
||||
|
||||
def _check_responsible_data(self):
|
||||
""" Checks data quality of related Responsibility
|
||||
|
||||
|
||||
@@ -157,6 +157,8 @@ def detail_view(request: HttpRequest, id: str):
|
||||
if last_checked:
|
||||
last_checked_tooltip = DATA_CHECKED_PREVIOUSLY_TEMPLATE.format(last_checked.get_timestamp_str_formatted(), last_checked.user)
|
||||
|
||||
has_payment_without_document = intervention.payments.exists() and not intervention.get_documents()[1].exists()
|
||||
|
||||
context = {
|
||||
"obj": intervention,
|
||||
"last_checked": last_checked,
|
||||
@@ -168,6 +170,7 @@ def detail_view(request: HttpRequest, id: str):
|
||||
"is_zb_member": in_group(_user, ZB_GROUP),
|
||||
"is_ets_member": in_group(_user, ETS_GROUP),
|
||||
"LANIS_LINK": intervention.get_LANIS_link(),
|
||||
"has_payment_without_document": has_payment_without_document,
|
||||
TAB_TITLE_IDENTIFIER: f"{intervention.identifier} - {intervention.title}",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user