Merge branch 'main' into MK/org_beitrag

pull/149/head
Christian Merten 8 months ago
commit 5c2adbcff6
Signed by: christian.merten
GPG Key ID: D953D69721B948B3

@ -135,11 +135,11 @@ class Statement(CommonModel):
needed_paiments.extend([(yl, self.allowance_per_yl) for yl in self.allowance_to.all()])
if self.subsidy_to:
needed_paiments.append((self.subsidy_to, self.total_subsidies))
# only include org fee if either allowance or subsidy is claimed (part of the property)
if self.total_org_fee:
needed_paiments.append((self.org_fee_payant, -self.total_org_fee))
if self.ljp_to:
needed_paiments.append((self.ljp_to, self.paid_ljp_contributions))
@ -255,16 +255,17 @@ class Statement(CommonModel):
if self.subsidy_to:
ref = _("Night and travel costs for %(excu)s") % {'excu': self.excursion.name}
Transaction(statement=self, member=self.subsidy_to, amount=self.total_subsidies, confirmed=False, reference=ref).save()
if self.total_org_fee:
# if no subsidy receiver is given but org fees have to be paid. Just pick on of allowance receivers
# if no subsidy receiver is given but org fees have to be paid. Just pick one of allowance receivers
ref = _("reduced by org fee")
Transaction(statement=self, member=self.org_fee_payant, amount=-self.total_org_fee, confirmed=False, reference=ref).save()
if self.ljp_to:
ref = _("LJP-Contribution %(excu)s") % {'excu': self.excursion.name}
Transaction(statement=self, member=self.ljp_to, amount=self.paid_ljp_contributions, confirmed=False, reference=ref).save()
Transaction(statement=self, member=self.ljp_to, amount=self.paid_ljp_contributions,
confirmed=False, reference=ref).save()
return True
def reduce_transactions(self):
@ -384,18 +385,18 @@ class Statement(CommonModel):
if self.excursion is None:
return 0
return cvt_to_decimal(10 * self.excursion.duration * self.excursion.old_participant_count)
@property
def total_org_fee(self):
"""only calculate org fee if subsidies or allowances are claimed."""
if self.subsidy_to or self.allowances_paid > 0:
return self.total_org_fee_theoretical
return cvt_to_decimal(0)
@property
def org_fee_payant(self):
return self.subsidy_to if self.subsidy_to else self.allowance_to.all()[0]
@property
def total_subsidies(self):
"""
@ -406,7 +407,7 @@ class Statement(CommonModel):
return (self.transportation_per_yl + self.nights_per_yl) * self.real_staff_count
else:
return cvt_to_decimal(0)
@property
def subsidies_paid(self):
return self.total_subsidies - self.total_org_fee
@ -424,7 +425,7 @@ class Statement(CommonModel):
the sum of subsidies and allowances that youth leaders are actually collecting
"""
return self.total_allowance + self.total_subsidies
@property
def total_staff_paid(self):
return self.total_staff - self.total_org_fee
@ -449,6 +450,10 @@ class Statement(CommonModel):
@property
def paid_ljp_contributions(self):
if hasattr(self.excursion, 'ljpproposal') and self.ljp_to:
if self.excursion.theoretic_ljp_participant_count < 5:
return 0
return cvt_to_decimal(
min(
(1-settings.LJP_TAX) * settings.LJP_CONTRIBUTION_PER_DAY * self.excursion.ljp_participant_count * self.excursion.ljp_duration,
@ -510,6 +515,7 @@ class Statement(CommonModel):
'allowance_to': self.allowance_to,
'paid_ljp_contributions': self.paid_ljp_contributions,
'ljp_to': self.ljp_to,
'theoretic_ljp_participant_count': self.excursion.theoretic_ljp_participant_count,
'participant_count': self.excursion.participant_count,
'total_seminar_days': self.excursion.total_seminar_days,
'ljp_tax': settings.LJP_TAX * 100,

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-04-15 22:18+0200\n"
"POT-Creation-Date: 2025-04-15 22:36+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1429,6 +1429,18 @@ msgstr ""
"Um den zu erhalten, musst du den LJP-Antrag innerhalb von 3 Wochen nach der "
"Ausfahrt beim Jugendreferat einreichen und formal genehmigt bekommen."
#: members/templates/admin/freizeit_finance_overview.html
msgid "Seminar hours"
msgstr "Seminar-Stunden"
#: members/templates/admin/freizeit_finance_overview.html
msgid "Seminar days"
msgstr "Seminar-Tage"
#: members/templates/admin/freizeit_finance_overview.html
msgid "Sum"
msgstr "Summe"
#: members/templates/admin/freizeit_finance_overview.html
msgid "The LJP contributions are configured to be paid to:"
msgstr "Die LJP-Zuschüsse werden ausgezahlt an:"
@ -1438,20 +1450,31 @@ msgstr "Die LJP-Zuschüsse werden ausgezahlt an:"
msgid ""
"By submitting a seminar report, you may apply for LJP contributions. In this "
"case,\n"
"you may obtain up to 25€ times %(duration)s days for %(participant_count)s "
"participants but only up to\n"
"you may obtain up to 25€ times %(duration)s days for "
"%(theoretic_ljp_participant_count)s participants but only up to\n"
"90%% of the total costs. This results in a total of %(ljp_contributions)s€. "
"If you have created a seminar report, you need to specify who should receive "
"the contributions in order to make use of them."
msgstr ""
"Indem du einen Seminarbericht anfertigst, kannst du Landesjugendplan (LJP) "
"Zuschüsse beantragen. In diesem Fall kannst du bis zu 25€ mal %(duration)s "
"Tage für %(participant_count)s Teilnehmende, aber nicht mehr als 90%% der "
"Tage für %(theoretic_ljp_participant_count)s Teilnehmende, aber nicht mehr als 90%% der "
"Gesamtausgaben erhalten. Das resultiert in einem Gesamtzuschuss von "
"%(ljp_contributions)s€. Wenn du schon einen Seminarbericht erstellt hast, "
"musst du im Tab 'Abrechnungen' noch angeben, an wen die LJP-Zuschüsse "
"ausgezahlt werden sollen."
#: members/templates/admin/freizeit_finance_overview.html
#, python-format
msgid ""
" Warning: LJP contributions can only be claimed for activities with at least "
"5 participants and one leader. This activity currently has only "
"%(theoretic_ljp_participant_count)s participants."
msgstr ""
"Achtung: Nur für Aktivitäten mit mindestens 5 Teilnehmenden und einer "
"Leitungsperson kann ein LJP-Antrag gestellt werden. Diese Ausfahrt hat "
"aktuell nur %(theoretic_ljp_participant_count)s Teilnehmende."
#: members/templates/admin/freizeit_finance_overview.html
msgid "Summary"
msgstr "Zusammenfassung"
@ -1815,13 +1838,13 @@ msgstr ""
msgid "Echo"
msgstr "Rückmeldung"
#: members/templates/members/echo.html
#: members/templates/members/echo.html members/tests.py
msgid ""
"Here is your current data. Please check if it is up to date and change "
"accordingly."
msgstr ""
"Hier siehst du deine aktuellen Daten. Bitte überprüfe alles und passe es "
"bei Bedarf an."
"Hier siehst du deine aktuellen Daten. Bitte überprüfe alles und passe es bei "
"Bedarf an."
#: members/templates/members/echo_failed.html members/tests.py
msgid "Echo failed"
@ -2250,12 +2273,6 @@ msgstr "ungültig"
msgid "expired"
msgstr "abgelaufen"
#: members/tests.py
msgid "Thanks for echoing back. Here is your current data:"
msgstr ""
"Vielen Dank, dass du dich rückmeldest. Hier siehst du deine aktuellen Daten. "
"Falls sich etwas geändert hat, trage das bitte hier ein."
#: members/views.py
msgid "Prename of the member."
msgstr "Vorname des*der Teilnehmenden"

@ -8,7 +8,7 @@ import csv
from django.db import models
from django.db.models import TextField, ManyToManyField, ForeignKey, Count,\
Sum, Case, Q, F, When, Value, IntegerField, Subquery, OuterRef
from django.db.models.functions import TruncDate
from django.db.models.functions import Cast
from django.utils.translation import gettext_lazy as _
from django.utils import timezone
from django.utils.html import format_html
@ -1293,20 +1293,36 @@ class Freizeit(CommonModel):
"""calculate seminar days based on intervention hours in every day"""
# TODO: add tests for this
if hasattr(self, 'ljpproposal'):
hours_per_day = (
self.ljpproposal.intervention_set
.annotate(day=TruncDate('date_start')) # Extract the date (without time)
.values('day') # Group by day
.annotate(total_duration=Sum('duration')) # Sum durations for each day
.order_by('day') # Sort results by date
)
hours_per_day = self.seminar_time_per_day
# Calculate the total number of seminar days
# Each day is counted as 1 if total_duration is >= 5 hours, as 0.5 if total_duration is >= 2.5
# otherwise 0
return sum([min(math.floor(h['total_duration']/cvt_to_decimal(2.5))/2, 1) for h in hours_per_day])
sum_days = sum([h['sum_days'] for h in hours_per_day])
return sum_days
else:
return 0
@property
def seminar_time_per_day(self):
if hasattr(self, 'ljpproposal'):
return (
self.ljpproposal.intervention_set
.annotate(day=Cast('date_start', output_field=models.DateField())) # Force it to date
.values('day') # Group by day
.annotate(total_duration=Sum('duration'))# Sum durations for each day
.annotate(
sum_days=Case(
When(total_duration__gte=5.0, then=Value(1.0)),
When(total_duration__gte=2.5, then=Value(0.5)),
default=Value(0.0),)
)
.order_by('day') # Sort results by date
)
else:
return []
@property
def ljp_duration(self):
"""calculate the duration in days for the LJP"""

@ -148,6 +148,26 @@ This results in a total contribution of {{ ljp_contributions }}€.
To receive them, you need to submit the LJP-Proposal within 3 weeks after your excursion and have it approved by the finance office.{% endblocktrans %}
</p>
<table>
<tr>
<td></td>
<td>{% trans "Seminar hours" %}</td>
<td>{% trans "Seminar days" %}</td>
</tr>
{% for day in memberlist.seminar_time_per_day %}
<tr>
<td>{{ day.day }}</td>
<td>{{ day.total_duration }}</td>
<td>{{ day.sum_days }}</td>
</tr>
{% endfor %}
<tr>
<td><b>{% trans "Sum" %}</b></td>
<td></td>
<td>{{ total_seminar_days }}</td>
</tr>
</table>
<p>
{% blocktrans %}The LJP contributions are configured to be paid to:{% endblocktrans %}
<table>
@ -164,12 +184,18 @@ To receive them, you need to submit the LJP-Proposal within 3 weeks after your e
{% else %}
<p>
{% blocktrans %}By submitting a seminar report, you may apply for LJP contributions. In this case,
you may obtain up to 25€ times {{ duration }} days for {{ participant_count }} participants but only up to
you may obtain up to 25€ times {{ duration }} days for {{ theoretic_ljp_participant_count }} participants but only up to
90% of the total costs. This results in a total of {{ ljp_contributions }}€. If you have created a seminar report, you need to specify who should receive the contributions in order to make use of them.{% endblocktrans %}
</p>
{% endif %}
{% if memberlist.theoretic_ljp_participant_count < 5 %}
<p>
{% blocktrans %} Warning: LJP contributions can only be claimed for activities with at least 5 participants and one leader. This activity currently has only {{ theoretic_ljp_participant_count }} participants.{% endblocktrans %}
</p>
{% endif %}
<h3>{% trans "Summary" %}</h3>
<p>

Loading…
Cancel
Save