From 9d79ba35bc95f2f4bc1c17fc12850e18c81f686c Mon Sep 17 00:00:00 2001 From: CCS Admin Date: Tue, 24 Feb 2026 09:34:19 +0000 Subject: [PATCH] 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 --- backend/app/services/vorjahr_service.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/app/services/vorjahr_service.py b/backend/app/services/vorjahr_service.py index e9afe87..419c94e 100644 --- a/backend/app/services/vorjahr_service.py +++ b/backend/app/services/vorjahr_service.py @@ -97,9 +97,12 @@ def refresh_vorjahr_cache(db: Session, jahr: int) -> int: # --------------------------------------------------------------------------- def _aggregate_summaries(jahr: int, summaries: list[YearlySummary]) -> dict: - """Sum up weekly YearlySummary rows into yearly totals.""" - result = { - "jahr": jahr, + """Sum up weekly YearlySummary rows into yearly totals. + + 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), "ablehnungen": sum(_safe(s.ablehnungen) 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_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: