fix: wrap vorjahr data in "summary" key to match excel_export structure

get_vorjahr_summary returned a flat dict, but excel_export looked for
data under vj.get("summary", {}), resulting in empty Vorjahr columns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
CCS Admin 2026-02-24 09:34:19 +00:00
parent 8502c7a7fb
commit 9d79ba35bc

View file

@ -97,9 +97,12 @@ def refresh_vorjahr_cache(db: Session, jahr: int) -> int:
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
def _aggregate_summaries(jahr: int, summaries: list[YearlySummary]) -> dict: def _aggregate_summaries(jahr: int, summaries: list[YearlySummary]) -> dict:
"""Sum up weekly YearlySummary rows into yearly totals.""" """Sum up weekly YearlySummary rows into yearly totals.
result = {
"jahr": jahr, Returns a dict with a ``summary`` key so that excel_export can access
it the same way as the current-year sheet1 data (``data.get("summary")``).
"""
totals = {
"erstberatungen": sum(_safe(s.erstberatungen) for s in summaries), "erstberatungen": sum(_safe(s.erstberatungen) for s in summaries),
"ablehnungen": sum(_safe(s.ablehnungen) for s in summaries), "ablehnungen": sum(_safe(s.ablehnungen) for s in summaries),
"unterlagen": sum(_safe(s.unterlagen) for s in summaries), "unterlagen": sum(_safe(s.unterlagen) for s in summaries),
@ -108,7 +111,7 @@ def _aggregate_summaries(jahr: int, summaries: list[YearlySummary]) -> dict:
"gutachten_alternative": sum(_safe(s.gutachten_alternative) for s in summaries), "gutachten_alternative": sum(_safe(s.gutachten_alternative) for s in summaries),
"gutachten_bestaetigung": sum(_safe(s.gutachten_bestaetigung) for s in summaries), "gutachten_bestaetigung": sum(_safe(s.gutachten_bestaetigung) for s in summaries),
} }
return result return {"jahr": jahr, "summary": totals}
def _calculate_and_cache(db: Session, jahr: int) -> dict: def _calculate_and_cache(db: Session, jahr: int) -> dict: