diff --git a/jdav_web/finance/admin.py b/jdav_web/finance/admin.py index e6fddc1..0f5237d 100644 --- a/jdav_web/finance/admin.py +++ b/jdav_web/finance/admin.py @@ -89,12 +89,25 @@ class StatementUnSubmittedAdmin(CommonAdminMixin, admin.ModelAdmin): messages.success(request, _("Successfully submited %(name)s. The finance department will notify the requestors as soon as possible.") % {'name': str(statement)}) return HttpResponseRedirect(reverse('admin:%s_%s_changelist' % (self.opts.app_label, self.opts.model_name))) - context = dict(self.admin_site.each_context(request), - title=_('Submit statement'), + + if statement.excursion: + memberlist = statement.excursion + context = dict(self.admin_site.each_context(request), + title=_('Finance overview'), opts=self.opts, - statement=statement) - - return render(request, 'admin/submit_statement.html', context=context) + memberlist=memberlist, + object=memberlist, + participant_count=memberlist.participant_count, + ljp_contributions=memberlist.potential_ljp_contributions, + total_relative_costs=memberlist.total_relative_costs, + **memberlist.statement.template_context()) + return render(request, 'admin/freizeit_finance_overview.html', context=context) + else: + context = dict(self.admin_site.each_context(request), + title=_('Submit statement'), + opts=self.opts, + statement=statement) + return render(request, 'admin/submit_statement.html', context=context) class TransactionOnSubmittedStatementInline(admin.TabularInline): diff --git a/jdav_web/finance/locale/de/LC_MESSAGES/django.po b/jdav_web/finance/locale/de/LC_MESSAGES/django.po index 491c098..9f6d9e3 100644 --- a/jdav_web/finance/locale/de/LC_MESSAGES/django.po +++ b/jdav_web/finance/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-19 11:40+0100\n" +"POT-Creation-Date: 2025-01-19 14:26+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -169,7 +169,7 @@ msgstr "Geldtöpfe" msgid "Short description" msgstr "Kurzbeschreibung" -#: finance/models.py +#: finance/models.py finance/templates/admin/submit_statement.html msgid "Explanation" msgstr "Erklärung" @@ -208,7 +208,7 @@ msgstr "Preis pro Nacht" #: finance/models.py msgid "Submitted" -msgstr "Eingericht" +msgstr "Eingereicht" #: finance/models.py msgid "Submitted on" @@ -291,10 +291,11 @@ msgstr "Bezahlte Abrechnungen" #: finance/models.py finance/templates/admin/confirmed_statement.html #: finance/templates/admin/overview_submitted_statement.html +#: finance/templates/admin/submit_statement.html msgid "Amount" msgstr "Betrag" -#: finance/models.py +#: finance/models.py finance/templates/admin/submit_statement.html msgid "Paid by" msgstr "Bezahlt von" @@ -533,6 +534,18 @@ msgstr "Einreichen" msgid "Submit to the finance department" msgstr "Beim Finanzreferat einreichen" +#: finance/templates/admin/submit_statement.html +msgid "" +"Please check if all expenses are documented correctly and if all payers have " +"a valid account code." +msgstr "" +"Bitte überprüfe, ob alle Ausgaben korrekt erfasst sind und ob alle " +"auslegenden Personen eine gültige IBAN haben." + +#: finance/templates/admin/submit_statement.html +msgid "IBAN valid" +msgstr "IBAN gültig" + #: finance/templates/admin/submit_statement.html msgid "" "Do you want to submit the statement for further processing by the finance " diff --git a/jdav_web/finance/templates/admin/overview_submitted_statement.html b/jdav_web/finance/templates/admin/overview_submitted_statement.html index 4a33ae6..0546b81 100644 --- a/jdav_web/finance/templates/admin/overview_submitted_statement.html +++ b/jdav_web/finance/templates/admin/overview_submitted_statement.html @@ -1,5 +1,6 @@ {% extends "admin/base_site.html" %} {% load i18n admin_urls static %} +{% load overview_extras %} {% block extrahead %} {{ block.super }} @@ -40,7 +41,7 @@ {{ bill.amount }}€. - {{ bill.costs_covered }} + {{ bill.costs_covered|render_bool }} {% endfor %} diff --git a/jdav_web/finance/templates/admin/submit_statement.html b/jdav_web/finance/templates/admin/submit_statement.html index 838c410..01bfe8a 100644 --- a/jdav_web/finance/templates/admin/submit_statement.html +++ b/jdav_web/finance/templates/admin/submit_statement.html @@ -1,5 +1,6 @@ {% extends "admin/base_site.html" %} {% load i18n admin_urls static %} +{% load overview_extras %} {% block extrahead %} {{ block.super }} @@ -24,6 +25,35 @@ {% block content %}

{% translate "Submit to the finance department" %}

+

{% translate "Please check if all expenses are documented correctly and if all payers have a valid account code." %}

+ + + + + + + {% for bill in statement.bill_set.all %} + + + + + + + + {% endfor %} +
+ {% trans "Explanation" %}{% trans "Amount" %}{% trans "Paid by" %}{% trans "IBAN valid" %}
+ {{bill.short_description}} + + {{bill.explanation}} + + {{ bill.amount }}€ + + {{ bill.paid_by.name }} + + {{ bill.paid_by.iban_valid|render_bool }} +
+

{% trans "Do you want to submit the statement for further processing by the finance department? If you proceed, no further changes to the statement are possible." %}

diff --git a/jdav_web/members/locale/de/LC_MESSAGES/django.po b/jdav_web/members/locale/de/LC_MESSAGES/django.po index f50cb29..02327dd 100644 --- a/jdav_web/members/locale/de/LC_MESSAGES/django.po +++ b/jdav_web/members/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-01-19 10:08+0100\n" +"POT-Creation-Date: 2025-01-19 19:16+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -411,7 +411,7 @@ msgid "" "Successfully submited statement. The finance department will notify you as " "soon as possible." msgstr "" -"Abrechnung erfolgreich eingericht. Die Finanzabteilung wird sich bei dir so " +"Abrechnung erfolgreich eingereicht. Die Finanzabteilung wird sich bei dir so " "schnell wie möglich melden." #: members/admin.py members/templates/admin/freizeit_finance_overview.html @@ -1089,6 +1089,14 @@ msgstr "Erklärung" msgid "Amount" msgstr "Betrag" +#: members/templates/admin/freizeit_finance_overview.html +msgid "Paid by" +msgstr "Bezahlt von" + +#: members/templates/admin/freizeit_finance_overview.html +msgid "IBAN valid" +msgstr "IBAN gültig" + #: members/templates/admin/freizeit_finance_overview.html #, python-format msgid "The total expected expenses are %(total_bills_theoretic)s €." @@ -1229,14 +1237,17 @@ msgstr "Abrechnung einreichen" msgid "" "Did you already complete this excursion? If yes, please check if all listed " "expenses are correct\n" -"and then submit the statement for processing by the finance department. If " -"you proceed,\n" +"and people who want their money back have valid bank account numbers. Then " +"submit the statement for processing by the finance department. If you " +"proceed,\n" "no further changes to the statement are possible." msgstr "" "Hat die Ausfahrt bereits stattgefunden? Wenn ja, prüfe bitte ob alle " -"aufgelisteten Kosten korrekt sind und reiche deine Abrechnung dann beim " -"Finanzreferat ein. Wenn du fortschreitest sind keine weiteren Änderungen an " -"der Abrechnung mehr möglich." +"aufgelisteten Kosten korrekt sind, alle notwendigen Belege hochgeladen sind " +"und ob alle Personen, die Geld ausbezahlt bekommen sollen, eine gültige IBAN " +"haben. Reiche deine Abrechnung dann beim Finanzreferat ein. Wenn du " +"fortschreitest, sind keine weiteren Änderungen an der Abrechnung mehr " +"möglich." #: members/templates/admin/freizeit_finance_overview.html msgid "Submit" diff --git a/jdav_web/members/models.py b/jdav_web/members/models.py index b18896f..e049399 100644 --- a/jdav_web/members/models.py +++ b/jdav_web/members/models.py @@ -30,6 +30,7 @@ from contrib.rules import memberize_user, has_global_perm from utils import cvt_to_decimal from dateutil.relativedelta import relativedelta +from schwifty import IBAN def generate_random_key(): return uuid.uuid4().hex @@ -342,6 +343,10 @@ class Member(Person): """Returning the whole place (plz + town)""" return "{0} {1}".format(self.plz, self.town) + @property + def iban_valid(self): + return IBAN(self.iban, allow_invalid=True).is_valid + @property def address(self): """Returning the whole address""" @@ -1210,7 +1215,7 @@ class Freizeit(CommonModel): if not self.statement: return 0 total_costs = self.statement.total_bills_theoretic - total_contributions = self.statement.total_staff + self.potential_ljp_contributions + total_contributions = self.statement.total_subsidies + self.potential_ljp_contributions return total_costs - total_contributions @property diff --git a/jdav_web/members/templates/admin/freizeit_finance_overview.html b/jdav_web/members/templates/admin/freizeit_finance_overview.html index 99aa909..ae14716 100644 --- a/jdav_web/members/templates/admin/freizeit_finance_overview.html +++ b/jdav_web/members/templates/admin/freizeit_finance_overview.html @@ -1,5 +1,6 @@ {% extends "admin/base_site.html" %} {% load i18n admin_urls static %} +{% load overview_extras %} {% block extrahead %} {{ block.super }} @@ -38,6 +39,8 @@ cost plan! {% trans "Explanation" %} {% trans "Amount" %} + {% trans "Paid by" %} + {% trans "IBAN valid" %} {% for bill in memberlist.statement.bill_set.all %} @@ -50,6 +53,12 @@ cost plan! {{ bill.amount }}€ + + {{ bill.paid_by.name }} + + + {{ bill.paid_by.iban_valid|render_bool }} + {% endfor %} @@ -78,21 +87,29 @@ cost plan!

{% blocktrans %}The allowance of {{ allowance_per_yl }}€ per person is configured to be paid to:{% endblocktrans %} -

    + + + {% for member in memberlist.statement.allowance_to.all %} -
  • - {{ member.name }} -
  • + + + + {% endfor %} - +
    + {% trans "IBAN valid" %}
    {{ member.name }}{{ member.iban_valid|render_bool }}

    {% blocktrans %}The subsidies for night and transportation costs of {{ total_subsidies }}€ is configured to be paid to:{% endblocktrans %} -

      -
    • - {{ memberlist.statement.subsidy_to.name }} -
    • -
    + + + + + + + +
    + {% trans "IBAN valid" %}
    {{ memberlist.statement.subsidy_to.name }}{{ memberlist.statement.subsidy_to.iban_valid|render_bool }}

    {% if not memberlist.statement.allowance_to_valid %}

    @@ -128,7 +145,7 @@ you may obtain up to 25€ times {{ duration }} days for {{ participant_count }} {% trans "Contributions by the association" %} - -{{ total_staff }}€ + -{{ total_subsidies }}€ @@ -162,7 +179,7 @@ excursions main page, you can generate a template for a seminar report.{% endblo

    {% trans "Submit statement" %}

    {% blocktrans %}Did you already complete this excursion? If yes, please check if all listed expenses are correct -and then submit the statement for processing by the finance department. If you proceed, +and people who want their money back have valid bank account numbers. Then submit the statement for processing by the finance department. If you proceed, no further changes to the statement are possible.{% endblocktrans %}

    diff --git a/jdav_web/members/templatetags/overview_extras.py b/jdav_web/members/templatetags/overview_extras.py index 5127167..95d11a4 100644 --- a/jdav_web/members/templatetags/overview_extras.py +++ b/jdav_web/members/templatetags/overview_extras.py @@ -1,4 +1,5 @@ from django import template +from django.utils.html import format_html register = template.Library() @@ -15,3 +16,19 @@ def has_attendee_wrapper(klettertreff, member): @register.simple_tag def has_jugendleiter_wrapper(klettertreff, jugendleiter): return blToColor(klettertreff.has_jugendleiter(jugendleiter)) + +@register.filter +def render_bool(boolean_value): + + if not isinstance(boolean_value, bool): + raise ValueError(f"""Custom Filter 'render_bool': Supplied value '{boolean_value}' is not bool, but {type(boolean_value)}.""") + + if boolean_value: # True is a green tick + color = "#bcd386" + htmlclass = "icon-tick" + else: # False is a red cross + color = "#dba4a4" + htmlclass = "icon-cross" + + return format_html(f"""""") \ No newline at end of file