Payment date and comment #3

* adds payment-comment relation in NewPaymentForm
 * drops transfer note form field (may not be used anyway) and replace it with comment
 * adds/updates translations
This commit is contained in:
mipel 2021-08-26 14:30:05 +02:00
parent 3bb7ff3e3f
commit 83039b9e84
7 changed files with 113 additions and 80 deletions

View File

@ -60,12 +60,18 @@ class NewPaymentForm(BaseModalForm):
format="%d.%m.%Y" format="%d.%m.%Y"
) )
) )
transfer_note = forms.CharField( comment = forms.CharField(
max_length=200, max_length=200,
required=False, required=False,
label=_("Comment"),
label_suffix=_(""), label_suffix=_(""),
label=_("Transfer note"), help_text=_("Additional comment, maximum {} letters").format(200),
help_text=_("Note for money transfer") widget=forms.Textarea(
attrs={
"rows": 5,
"class": "w-100"
}
)
) )
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -75,6 +81,29 @@ class NewPaymentForm(BaseModalForm):
self.form_caption = _("Add a payment for intervention '{}'").format(self.intervention.title) self.form_caption = _("Add a payment for intervention '{}'").format(self.intervention.title)
self.add_placeholder_for_field("amount", "0,00") self.add_placeholder_for_field("amount", "0,00")
def is_valid(self):
"""
Checks on form validity.
For this form we need to make sure that a date or a comment is set.
If both are missing, the user needs to enter at least an explanation why
there is no date to be entered.
Returns:
is_valid (bool): True if valid, False otherwise
"""
super_valid = super().is_valid()
date = self.cleaned_data["due"]
comment = self.cleaned_data["comment"] or None
if not date and not comment:
# At least one needs to be set!
self.add_error(
"comment",
_("If there is no date you can enter, please explain why.")
)
return False
return super_valid
def save(self): def save(self):
with transaction.atomic(): with transaction.atomic():
created_action = UserActionLogEntry.objects.create( created_action = UserActionLogEntry.objects.create(
@ -90,7 +119,7 @@ class NewPaymentForm(BaseModalForm):
created=created_action, created=created_action,
amount=self.cleaned_data.get("amount", -1), amount=self.cleaned_data.get("amount", -1),
due_on=self.cleaned_data.get("due", None), due_on=self.cleaned_data.get("due", None),
comment=self.cleaned_data.get("transfer_note", None), comment=self.cleaned_data.get("comment", None),
intervention=self.intervention, intervention=self.intervention,
) )
self.intervention.log.add(edited_action) self.intervention.log.add(edited_action)

View File

@ -44,7 +44,7 @@
<td class="align-middle"> <td class="align-middle">
{% trans deadline.type_humanized %} {% trans deadline.type_humanized %}
</td> </td>
<td class="align-middle">{{ deadline.date }}</td> <td class="align-middle">{{ deadline.date|default_if_none:"---" }}</td>
<td class="align-middle">{{ deadline.comment }}</td> <td class="align-middle">{{ deadline.comment }}</td>
<td> <td>
{% if is_default_member and has_access %} {% if is_default_member and has_access %}

View File

@ -44,7 +44,7 @@
<td class="align-middle"> <td class="align-middle">
{% trans deadline.type_humanized %} {% trans deadline.type_humanized %}
</td> </td>
<td class="align-middle">{{ deadline.date }}</td> <td class="align-middle">{{ deadline.date|default_if_none:"---" }}</td>
<td class="align-middle">{{ deadline.comment }}</td> <td class="align-middle">{{ deadline.comment }}</td>
<td> <td>
{% if is_default_member and has_access %} {% if is_default_member and has_access %}

View File

@ -44,7 +44,7 @@
<td class="align-middle"> <td class="align-middle">
{% trans deadline.type_humanized %} {% trans deadline.type_humanized %}
</td> </td>
<td class="align-middle">{{ deadline.date }}</td> <td class="align-middle">{{ deadline.date|default_if_none:"---" }}</td>
<td class="align-middle">{{ deadline.comment }}</td> <td class="align-middle">{{ deadline.comment }}</td>
<td> <td>
{% if is_default_member and has_access %} {% if is_default_member and has_access %}

View File

@ -31,7 +31,7 @@
{% trans 'Due on' %} {% trans 'Due on' %}
</th> </th>
<th scope="col"> <th scope="col">
{% trans 'Transfer comment' %} {% trans 'Comment' %}
</th> </th>
<th scope="col"> <th scope="col">
{% trans 'Action' %} {% trans 'Action' %}
@ -44,7 +44,7 @@
<td class="align-middle"> <td class="align-middle">
{{ pay.amount|floatformat:2 }} € {{ pay.amount|floatformat:2 }} €
</td> </td>
<td class="align-middle">{{ pay.due_on }}</td> <td class="align-middle">{{ pay.due_on|default_if_none:"---" }}</td>
<td class="align-middle">{{ pay.comment }}</td> <td class="align-middle">{{ pay.comment }}</td>
<td> <td>
{% if is_default_member and has_access %} {% if is_default_member and has_access %}

Binary file not shown.

View File

@ -3,20 +3,20 @@
# This file is distributed under the same license as the PACKAGE package. # This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#: compensation/filters.py:71 compensation/forms.py:46 compensation/forms.py:51 #: compensation/filters.py:71 compensation/forms.py:48 compensation/forms.py:53
#: compensation/forms.py:65 compensation/forms.py:234 compensation/forms.py:314 #: compensation/forms.py:67 compensation/forms.py:236 compensation/forms.py:331
#: intervention/filters.py:26 intervention/filters.py:40 #: intervention/filters.py:26 intervention/filters.py:40
#: intervention/filters.py:47 intervention/filters.py:48 #: intervention/filters.py:47 intervention/filters.py:48
#: intervention/forms.py:322 intervention/forms.py:334 #: intervention/forms.py:322 intervention/forms.py:334
#: intervention/forms.py:346 konova/forms.py:108 konova/forms.py:242 #: intervention/forms.py:346 konova/forms.py:108 konova/forms.py:252
#: konova/forms.py:275 konova/forms.py:280 konova/forms.py:292 #: konova/forms.py:287 konova/forms.py:292 konova/forms.py:304
#: konova/forms.py:304 konova/forms.py:317 user/forms.py:38 #: konova/forms.py:316 konova/forms.py:329 user/forms.py:38
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-24 14:26+0200\n" "POT-Creation-Date: 2021-08-26 13:45+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -30,54 +30,48 @@ msgstr ""
msgid "Show only unrecorded" msgid "Show only unrecorded"
msgstr "Nur unverzeichnete anzeigen" msgstr "Nur unverzeichnete anzeigen"
#: compensation/forms.py:45 compensation/forms.py:303 #: compensation/forms.py:49
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:31
#: intervention/templates/intervention/detail/includes/withdraws.html:31
msgid "Amount"
msgstr "Menge"
#: compensation/forms.py:47
msgid "in Euro" msgid "in Euro"
msgstr "in Euro" msgstr "in Euro"
#: compensation/forms.py:50 #: compensation/forms.py:52
#: intervention/templates/intervention/detail/includes/payments.html:31 #: intervention/templates/intervention/detail/includes/payments.html:31
msgid "Due on" msgid "Due on"
msgstr "Fällig am" msgstr "Fällig am"
#: compensation/forms.py:53 #: compensation/forms.py:55
msgid "Due on which date" msgid "Due on which date"
msgstr "Zahlung wird an diesem Datum erwartet" msgstr "Zahlung wird an diesem Datum erwartet"
#: compensation/forms.py:66 #: compensation/forms.py:68
msgid "Transfer note" msgid "Transfer note"
msgstr "Verwendungszweck" msgstr "Verwendungszweck"
#: compensation/forms.py:67 #: compensation/forms.py:69
msgid "Note for money transfer" msgid "Note for money transfer"
msgstr "Verwendungszweck für Überweisung" msgstr "Verwendungszweck für Überweisung"
#: compensation/forms.py:73 #: compensation/forms.py:75
msgid "Payment" msgid "Payment"
msgstr "Zahlung" msgstr "Zahlung"
#: compensation/forms.py:74 #: compensation/forms.py:76
msgid "Add a payment for intervention '{}'" msgid "Add a payment for intervention '{}'"
msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen" msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen"
#: compensation/forms.py:86 #: compensation/forms.py:88
msgid "Added payment" msgid "Added payment"
msgstr "Zahlung hinzufügen" msgstr "Zahlung hinzufügen"
#: compensation/forms.py:103 compensation/forms.py:115 #: compensation/forms.py:105 compensation/forms.py:117
msgid "Biotope Type" msgid "Biotope Type"
msgstr "Biotoptyp" msgstr "Biotoptyp"
#: compensation/forms.py:106 #: compensation/forms.py:108
msgid "Select the biotope type" msgid "Select the biotope type"
msgstr "Biotoptyp wählen" msgstr "Biotoptyp wählen"
#: compensation/forms.py:122 #: compensation/forms.py:124
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:36 #: compensation/templates/compensation/detail/compensation/includes/states-after.html:36
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:36 #: compensation/templates/compensation/detail/compensation/includes/states-before.html:36
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:36 #: compensation/templates/compensation/detail/eco_account/includes/states-after.html:36
@ -88,35 +82,35 @@ msgstr "Biotoptyp wählen"
msgid "Surface" msgid "Surface"
msgstr "Fläche" msgstr "Fläche"
#: compensation/forms.py:125 intervention/forms.py:476 #: compensation/forms.py:127 intervention/forms.py:476
msgid "in m²" msgid "in m²"
msgstr "" msgstr ""
#: compensation/forms.py:130 #: compensation/forms.py:132
msgid "New state" msgid "New state"
msgstr "Neuer Zustand" msgstr "Neuer Zustand"
#: compensation/forms.py:131 #: compensation/forms.py:133
msgid "Insert data for the new state" msgid "Insert data for the new state"
msgstr "Geben Sie die Daten des neuen Zustandes ein" msgstr "Geben Sie die Daten des neuen Zustandes ein"
#: compensation/forms.py:139 #: compensation/forms.py:141
msgid "Added state" msgid "Added state"
msgstr "Zustand hinzugefügt" msgstr "Zustand hinzugefügt"
#: compensation/forms.py:155 konova/forms.py:158 #: compensation/forms.py:157 konova/forms.py:168
msgid "Object removed" msgid "Object removed"
msgstr "Objekt entfernt" msgstr "Objekt entfernt"
#: compensation/forms.py:206 #: compensation/forms.py:208
msgid "Deadline Type" msgid "Deadline Type"
msgstr "Fristart" msgstr "Fristart"
#: compensation/forms.py:209 #: compensation/forms.py:211
msgid "Select the deadline type" msgid "Select the deadline type"
msgstr "Fristart wählen" msgstr "Fristart wählen"
#: compensation/forms.py:218 #: compensation/forms.py:220
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:31 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:31
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:31 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:31
#: ema/templates/ema/detail/includes/deadlines.html:31 #: ema/templates/ema/detail/includes/deadlines.html:31
@ -124,11 +118,11 @@ msgstr "Fristart wählen"
msgid "Date" msgid "Date"
msgstr "Datum" msgstr "Datum"
#: compensation/forms.py:221 #: compensation/forms.py:223
msgid "Select date" msgid "Select date"
msgstr "Datum wählen" msgstr "Datum wählen"
#: compensation/forms.py:233 compensation/forms.py:313 #: compensation/forms.py:235 compensation/forms.py:330
#: compensation/templates/compensation/detail/compensation/includes/actions.html:34 #: compensation/templates/compensation/detail/compensation/includes/actions.html:34
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:34 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:34
#: compensation/templates/compensation/detail/compensation/includes/documents.html:31 #: compensation/templates/compensation/detail/compensation/includes/documents.html:31
@ -141,36 +135,40 @@ msgstr "Datum wählen"
#: intervention/forms.py:345 #: intervention/forms.py:345
#: intervention/templates/intervention/detail/includes/documents.html:31 #: intervention/templates/intervention/detail/includes/documents.html:31
#: intervention/templates/intervention/detail/includes/revocation.html:35 #: intervention/templates/intervention/detail/includes/revocation.html:35
#: konova/forms.py:303 #: konova/forms.py:315
msgid "Comment" msgid "Comment"
msgstr "Kommentar" msgstr "Kommentar"
#: compensation/forms.py:235 compensation/forms.py:315 #: compensation/forms.py:237 compensation/forms.py:332
#: intervention/forms.py:347 konova/forms.py:305 #: intervention/forms.py:347 konova/forms.py:317
msgid "Additional comment, maximum {} letters" msgid "Additional comment, maximum {} letters"
msgstr "Zusätzlicher Kommentar, maximal {} Zeichen" msgstr "Zusätzlicher Kommentar, maximal {} Zeichen"
#: compensation/forms.py:246 #: compensation/forms.py:248
msgid "New deadline" msgid "New deadline"
msgstr "Neue Frist" msgstr "Neue Frist"
#: compensation/forms.py:247 #: compensation/forms.py:249
msgid "Insert data for the new deadline" msgid "Insert data for the new deadline"
msgstr "Geben Sie die Daten der neuen Frist ein" msgstr "Geben Sie die Daten der neuen Frist ein"
#: compensation/forms.py:264 #: compensation/forms.py:259
msgid "If there is no date you can enter, please explain why."
msgstr "Falls Sie kein Datum angeben können, erklären Sie bitte weshalb."
#: compensation/forms.py:280
msgid "Added deadline" msgid "Added deadline"
msgstr "Frist/Termin hinzugefügt" msgstr "Frist/Termin hinzugefügt"
#: compensation/forms.py:275 #: compensation/forms.py:291
msgid "Action Type" msgid "Action Type"
msgstr "Maßnahmentyp" msgstr "Maßnahmentyp"
#: compensation/forms.py:278 #: compensation/forms.py:294
msgid "Select the action type" msgid "Select the action type"
msgstr "Maßnahmentyp wählen" msgstr "Maßnahmentyp wählen"
#: compensation/forms.py:285 #: compensation/forms.py:303
#: compensation/templates/compensation/detail/compensation/includes/actions.html:37 #: compensation/templates/compensation/detail/compensation/includes/actions.html:37
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:37 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:37
#: compensation/templates/compensation/detail/compensation/includes/documents.html:34 #: compensation/templates/compensation/detail/compensation/includes/documents.html:34
@ -196,51 +194,57 @@ msgstr "Maßnahmentyp wählen"
msgid "Action" msgid "Action"
msgstr "Aktionen" msgstr "Aktionen"
#: compensation/forms.py:291 #: compensation/forms.py:308
msgid "Unit" msgid "Unit"
msgstr "Einheit" msgstr "Einheit"
#: compensation/forms.py:294 #: compensation/forms.py:311
msgid "Select the unit" msgid "Select the unit"
msgstr "Einheit wählen" msgstr "Einheit wählen"
#: compensation/forms.py:306 #: compensation/forms.py:320
#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:31
#: intervention/templates/intervention/detail/includes/withdraws.html:31
msgid "Amount"
msgstr "Menge"
#: compensation/forms.py:323
msgid "Insert the amount" msgid "Insert the amount"
msgstr "Menge eingeben" msgstr "Menge eingeben"
#: compensation/forms.py:326 #: compensation/forms.py:343
msgid "New action" msgid "New action"
msgstr "Neue Maßnahme" msgstr "Neue Maßnahme"
#: compensation/forms.py:327 #: compensation/forms.py:344
msgid "Insert data for the new action" msgid "Insert data for the new action"
msgstr "Geben Sie die Daten der neuen Maßnahme ein" msgstr "Geben Sie die Daten der neuen Maßnahme ein"
#: compensation/forms.py:346 #: compensation/forms.py:363
msgid "Added action" msgid "Added action"
msgstr "Maßnahme hinzugefügt" msgstr "Maßnahme hinzugefügt"
#: compensation/models.py:56 #: compensation/models.py:67
msgid "cm" msgid "cm"
msgstr "" msgstr ""
#: compensation/models.py:57 #: compensation/models.py:68
msgid "m" msgid "m"
msgstr "" msgstr ""
#: compensation/models.py:58 #: compensation/models.py:69
msgid "km" msgid "km"
msgstr "" msgstr ""
#: compensation/models.py:59 #: compensation/models.py:70
msgid "m²" msgid "m²"
msgstr "" msgstr ""
#: compensation/models.py:60 #: compensation/models.py:71
msgid "ha" msgid "ha"
msgstr "" msgstr ""
#: compensation/models.py:61 #: compensation/models.py:72
msgid "Pieces" msgid "Pieces"
msgstr "Stück" msgstr "Stück"
@ -260,7 +264,7 @@ msgstr "Kennung"
#: intervention/tables.py:28 #: intervention/tables.py:28
#: intervention/templates/intervention/detail/includes/compensations.html:33 #: intervention/templates/intervention/detail/includes/compensations.html:33
#: intervention/templates/intervention/detail/includes/documents.html:28 #: intervention/templates/intervention/detail/includes/documents.html:28
#: intervention/templates/intervention/detail/view.html:31 konova/forms.py:274 #: intervention/templates/intervention/detail/view.html:31 konova/forms.py:286
msgid "Title" msgid "Title"
msgstr "Bezeichnung" msgstr "Bezeichnung"
@ -463,7 +467,7 @@ msgstr "Dokumente"
#: compensation/templates/compensation/detail/eco_account/includes/documents.html:14 #: compensation/templates/compensation/detail/eco_account/includes/documents.html:14
#: ema/templates/ema/detail/includes/documents.html:14 #: ema/templates/ema/detail/includes/documents.html:14
#: intervention/templates/intervention/detail/includes/documents.html:14 #: intervention/templates/intervention/detail/includes/documents.html:14
#: konova/forms.py:316 #: konova/forms.py:328
msgid "Add new document" msgid "Add new document"
msgstr "Neues Dokument hinzufügen" msgstr "Neues Dokument hinzufügen"
@ -846,7 +850,7 @@ msgstr "Datum des Widerspruchs"
msgid "Document" msgid "Document"
msgstr "Dokument" msgstr "Dokument"
#: intervention/forms.py:335 konova/forms.py:293 #: intervention/forms.py:335 konova/forms.py:305
msgid "Must be smaller than 15 Mb" msgid "Must be smaller than 15 Mb"
msgstr "Muss kleiner als 15 Mb sein" msgstr "Muss kleiner als 15 Mb sein"
@ -868,7 +872,7 @@ msgstr "Kompensationen und Zahlungen geprüft"
msgid "Run check" msgid "Run check"
msgstr "Prüfung vornehmen" msgstr "Prüfung vornehmen"
#: intervention/forms.py:411 konova/forms.py:364 #: intervention/forms.py:411 konova/forms.py:376
msgid "" msgid ""
"I, {} {}, confirm that all necessary control steps have been performed by " "I, {} {}, confirm that all necessary control steps have been performed by "
"myself." "myself."
@ -1105,11 +1109,11 @@ msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!"
msgid "Not editable" msgid "Not editable"
msgstr "Nicht editierbar" msgstr "Nicht editierbar"
#: konova/forms.py:107 konova/forms.py:241 #: konova/forms.py:107 konova/forms.py:251
msgid "Confirm" msgid "Confirm"
msgstr "Bestätige" msgstr "Bestätige"
#: konova/forms.py:119 konova/forms.py:250 #: konova/forms.py:119 konova/forms.py:260
msgid "Remove" msgid "Remove"
msgstr "Löschen" msgstr "Löschen"
@ -1117,44 +1121,44 @@ msgstr "Löschen"
msgid "You are about to remove {} {}" msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen" msgstr "Sie sind dabei {} {} zu löschen"
#: konova/forms.py:251 #: konova/forms.py:261
msgid "Are you sure?" msgid "Are you sure?"
msgstr "Sind Sie sicher?" msgstr "Sind Sie sicher?"
#: konova/forms.py:279 #: konova/forms.py:291
msgid "Created on" msgid "Created on"
msgstr "Erstellt" msgstr "Erstellt"
#: konova/forms.py:281 #: konova/forms.py:293
msgid "When has this file been created? Important for photos." msgid "When has this file been created? Important for photos."
msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?" msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?"
#: konova/forms.py:291 #: konova/forms.py:303
#: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231 #: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231
msgid "File" msgid "File"
msgstr "Datei" msgstr "Datei"
#: konova/forms.py:341 #: konova/forms.py:353
msgid "Added document" msgid "Added document"
msgstr "Dokument hinzugefügt" msgstr "Dokument hinzugefügt"
#: konova/forms.py:355 #: konova/forms.py:367
msgid "Confirm record" msgid "Confirm record"
msgstr "Verzeichnen bestätigen" msgstr "Verzeichnen bestätigen"
#: konova/forms.py:363 #: konova/forms.py:375
msgid "Record data" msgid "Record data"
msgstr "Daten verzeichnen" msgstr "Daten verzeichnen"
#: konova/forms.py:368 #: konova/forms.py:380
msgid "Confirm unrecord" msgid "Confirm unrecord"
msgstr "Entzeichnen bestätigen" msgstr "Entzeichnen bestätigen"
#: konova/forms.py:369 #: konova/forms.py:381
msgid "Unrecord data" msgid "Unrecord data"
msgstr "Daten entzeichnen" msgstr "Daten entzeichnen"
#: konova/forms.py:370 #: konova/forms.py:382
msgid "I, {} {}, confirm that this data must be unrecorded." msgid "I, {} {}, confirm that this data must be unrecorded."
msgstr "" msgstr ""
"Ich, {} {}, bestätige, dass diese Daten wieder entzeichnet werden müssen." "Ich, {} {}, bestätige, dass diese Daten wieder entzeichnet werden müssen."
@ -1307,7 +1311,7 @@ msgstr "Abbrechen"
msgid "Save" msgid "Save"
msgstr "Speichern" msgstr "Speichern"
#: templates/form/generic_table_form_body.html:22 #: templates/form/generic_table_form_body.html:23
msgid "Fields with * are required." msgid "Fields with * are required."
msgstr "* sind Pflichtfelder." msgstr "* sind Pflichtfelder."