feat: Implement quarterly confirmation system with automatic support payments
- Add VierteljahresNachweis model for quarterly document tracking - Remove studiennachweis_erforderlich field (now always required) - Fix modal edit view to include studiennachweis section - Implement automatic DestinataerUnterstuetzung creation when requirements met - Set payment due dates to exact quarter end dates (Mar 31, Jun 30, Sep 30, Dec 31) - Add quarterly confirmation CRUD views with modal and full-screen editing - Update templates with comprehensive quarterly management interface - Include proper validation, status tracking, and progress indicators
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.contrib import admin
|
||||
from django.db.models import Count, Sum
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.html import format_html
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
@@ -9,7 +10,7 @@ from .models import (AppConfiguration, AuditLog, BackupJob, BankTransaction,
|
||||
CSVImport, Destinataer, DestinataerUnterstuetzung,
|
||||
DokumentLink, Foerderung, Land, LandVerpachtung, Paechter, Person,
|
||||
Rentmeister, StiftungsKonto, UnterstuetzungWiederkehrend,
|
||||
Verwaltungskosten)
|
||||
Verwaltungskosten, VierteljahresNachweis)
|
||||
|
||||
|
||||
@admin.register(CSVImport)
|
||||
@@ -968,6 +969,194 @@ class HelpBoxAdmin(admin.ModelAdmin):
|
||||
super().save_model(request, obj, form, change)
|
||||
|
||||
|
||||
@admin.register(VierteljahresNachweis)
|
||||
class VierteljahresNachweisAdmin(admin.ModelAdmin):
|
||||
list_display = [
|
||||
"destinataer",
|
||||
"jahr",
|
||||
"quartal",
|
||||
"status",
|
||||
"completion_percentage",
|
||||
"faelligkeitsdatum",
|
||||
"is_overdue_display",
|
||||
"eingereicht_am",
|
||||
"geprueft_von",
|
||||
]
|
||||
list_filter = [
|
||||
"jahr",
|
||||
"quartal",
|
||||
"status",
|
||||
"studiennachweis_erforderlich",
|
||||
"studiennachweis_eingereicht",
|
||||
"einkommenssituation_bestaetigt",
|
||||
"vermogenssituation_bestaetigt",
|
||||
"faelligkeitsdatum",
|
||||
]
|
||||
search_fields = [
|
||||
"destinataer__vorname",
|
||||
"destinataer__nachname",
|
||||
"destinataer__email",
|
||||
]
|
||||
readonly_fields = [
|
||||
"id",
|
||||
"erstellt_am",
|
||||
"aktualisiert_am",
|
||||
"completion_percentage",
|
||||
"is_overdue_display",
|
||||
]
|
||||
ordering = ["-jahr", "-quartal", "destinataer__nachname"]
|
||||
|
||||
fieldsets = (
|
||||
(
|
||||
"Grundinformationen",
|
||||
{
|
||||
"fields": (
|
||||
"destinataer",
|
||||
"jahr",
|
||||
"quartal",
|
||||
"status",
|
||||
"faelligkeitsdatum",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"Studiennachweis",
|
||||
{
|
||||
"fields": (
|
||||
"studiennachweis_erforderlich",
|
||||
"studiennachweis_eingereicht",
|
||||
"studiennachweis_datei",
|
||||
"studiennachweis_bemerkung",
|
||||
),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
(
|
||||
"Einkommenssituation",
|
||||
{
|
||||
"fields": (
|
||||
"einkommenssituation_bestaetigt",
|
||||
"einkommenssituation_text",
|
||||
"einkommenssituation_datei",
|
||||
),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
(
|
||||
"Vermögenssituation",
|
||||
{
|
||||
"fields": (
|
||||
"vermogenssituation_bestaetigt",
|
||||
"vermogenssituation_text",
|
||||
"vermogenssituation_datei",
|
||||
),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
(
|
||||
"Weitere Dokumente",
|
||||
{
|
||||
"fields": (
|
||||
"weitere_dokumente",
|
||||
"weitere_dokumente_beschreibung",
|
||||
),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
(
|
||||
"Verwaltung & Prüfung",
|
||||
{
|
||||
"fields": (
|
||||
"interne_notizen",
|
||||
"eingereicht_am",
|
||||
"geprueft_am",
|
||||
"geprueft_von",
|
||||
),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
(
|
||||
"Metadaten",
|
||||
{
|
||||
"fields": (
|
||||
"id",
|
||||
"erstellt_am",
|
||||
"aktualisiert_am",
|
||||
"completion_percentage",
|
||||
"is_overdue_display",
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
def completion_percentage(self, obj):
|
||||
"""Show completion percentage as colored badge"""
|
||||
percentage = obj.get_completion_percentage()
|
||||
if percentage == 100:
|
||||
color = "success"
|
||||
elif percentage >= 70:
|
||||
color = "info"
|
||||
elif percentage >= 30:
|
||||
color = "warning"
|
||||
else:
|
||||
color = "danger"
|
||||
|
||||
return format_html(
|
||||
'<span class="badge bg-{}">{} %</span>',
|
||||
color,
|
||||
percentage
|
||||
)
|
||||
completion_percentage.short_description = "Fortschritt"
|
||||
|
||||
def is_overdue_display(self, obj):
|
||||
"""Display overdue status with icon"""
|
||||
if obj.is_overdue():
|
||||
return format_html(
|
||||
'<span class="text-danger"><i class="fas fa-exclamation-triangle"></i> Ja</span>'
|
||||
)
|
||||
return format_html(
|
||||
'<span class="text-success"><i class="fas fa-check"></i> Nein</span>'
|
||||
)
|
||||
is_overdue_display.short_description = "Überfällig"
|
||||
|
||||
actions = ["mark_as_approved", "mark_as_needs_revision"]
|
||||
|
||||
def mark_as_approved(self, request, queryset):
|
||||
"""Bulk action to approve submitted confirmations"""
|
||||
count = 0
|
||||
for nachweis in queryset.filter(status="eingereicht"):
|
||||
nachweis.status = "geprueft"
|
||||
nachweis.geprueft_am = timezone.now()
|
||||
nachweis.geprueft_von = request.user
|
||||
nachweis.save()
|
||||
count += 1
|
||||
|
||||
if count:
|
||||
self.message_user(
|
||||
request,
|
||||
f"{count} Nachweise wurden als geprüft und freigegeben markiert."
|
||||
)
|
||||
else:
|
||||
self.message_user(
|
||||
request,
|
||||
"Keine eingereichten Nachweise gefunden.",
|
||||
level="warning"
|
||||
)
|
||||
mark_as_approved.short_description = "Ausgewählte Nachweise freigeben"
|
||||
|
||||
def mark_as_needs_revision(self, request, queryset):
|
||||
"""Bulk action to mark confirmations as needing revision"""
|
||||
count = queryset.exclude(status__in=["offen", "nachbesserung"]).update(
|
||||
status="nachbesserung"
|
||||
)
|
||||
if count:
|
||||
self.message_user(
|
||||
request,
|
||||
f"{count} Nachweise wurden als nachbesserungsbedürftig markiert."
|
||||
)
|
||||
mark_as_needs_revision.short_description = "Nachbesserung erforderlich markieren"
|
||||
|
||||
|
||||
# Customize admin site
|
||||
admin.site.site_header = "Stiftungsverwaltung Administration"
|
||||
admin.site.site_title = "Stiftungsverwaltung Admin"
|
||||
|
||||
Reference in New Issue
Block a user