From b5142ce3c713ef975ede0a36473fa1677aa24c5d Mon Sep 17 00:00:00 2001 From: Flo Ha Date: Sat, 20 Jun 2026 16:26:53 +0200 Subject: [PATCH] fix(dashboard): subtract cash prefill from income to fix Bilanz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 500€ Kassen-Vorschuss was counted as income, inflating Einnahmen by 500€ and showing Bilanz -166€ instead of the correct -666€. Co-Authored-By: Claude Sonnet 4.6 --- gaehsnitz/suff.py | 10 +++++++++- gaehsnitz/templates/suff/dashboard.html | 10 +++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gaehsnitz/suff.py b/gaehsnitz/suff.py index 86caefd..420ab8a 100644 --- a/gaehsnitz/suff.py +++ b/gaehsnitz/suff.py @@ -1,5 +1,6 @@ import math from datetime import datetime, timedelta +from decimal import Decimal from zoneinfo import ZoneInfo from django.conf import settings @@ -747,9 +748,14 @@ DAY_LABELS = {1: "Donnerstag", 2: "Freitag", 3: "Samstag", 4: "Sonntag"} def dashboard_view(request): year = current_year() + CASH_PREFILL = Decimal("500.00") + total_donations = Donation.objects.filter(date__year=year).aggregate(s=Sum("amount"))["s"] or 0 total_costs = Payment.objects.filter(date__year=year).aggregate(s=Sum("amount"))["s"] or 0 - user_payments_total = UserPayment.objects.filter(created_at__year=year).aggregate(s=Sum("amount"))["s"] or 0 + cash_raw = UserPayment.objects.filter(created_at__year=year, method="cash").aggregate(s=Sum("amount"))["s"] or Decimal("0") + cash_net = cash_raw - CASH_PREFILL + non_cash = UserPayment.objects.filter(created_at__year=year).exclude(method="cash").aggregate(s=Sum("amount"))["s"] or Decimal("0") + user_payments_total = cash_net + non_cash # real income, prefill excluded drinks = list(Drink.objects.filter(year=year).order_by("name")) drink_rows = [ @@ -958,6 +964,8 @@ def dashboard_view(request): "total_entry": total_entry, "method_split": method_split, "cash_total": cash_total, + "cash_prefill": CASH_PREFILL, + "cash_net": cash_net, "top_free_recipient": top_free_recipient, "free_total_count": free_total_count, } diff --git a/gaehsnitz/templates/suff/dashboard.html b/gaehsnitz/templates/suff/dashboard.html index aef4cda..7a7d84f 100644 --- a/gaehsnitz/templates/suff/dashboard.html +++ b/gaehsnitz/templates/suff/dashboard.html @@ -30,12 +30,16 @@ {{ total_donations|euro }}
  • - Zahlungen (User-Tab) + Cashless (User-Tab) {{ user_payments_total|euro }}
  • - Kasse (bar) - {{ cash_total|euro }} + Kasse (bar, nach Vorschuss) + {{ cash_net|euro }} +
  • +
  • + Kassen-Vorschuss + {{ cash_prefill|euro }}
  • Einkaufspreis Getränke