fix(dashboard): subtract cash prefill from income to fix Bilanz
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 <noreply@anthropic.com>
This commit is contained in:
+9
-1
@@ -1,5 +1,6 @@
|
|||||||
import math
|
import math
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from decimal import Decimal
|
||||||
from zoneinfo import ZoneInfo
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -747,9 +748,14 @@ DAY_LABELS = {1: "Donnerstag", 2: "Freitag", 3: "Samstag", 4: "Sonntag"}
|
|||||||
def dashboard_view(request):
|
def dashboard_view(request):
|
||||||
year = current_year()
|
year = current_year()
|
||||||
|
|
||||||
|
CASH_PREFILL = Decimal("500.00")
|
||||||
|
|
||||||
total_donations = Donation.objects.filter(date__year=year).aggregate(s=Sum("amount"))["s"] or 0
|
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
|
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"))
|
drinks = list(Drink.objects.filter(year=year).order_by("name"))
|
||||||
drink_rows = [
|
drink_rows = [
|
||||||
@@ -958,6 +964,8 @@ def dashboard_view(request):
|
|||||||
"total_entry": total_entry,
|
"total_entry": total_entry,
|
||||||
"method_split": method_split,
|
"method_split": method_split,
|
||||||
"cash_total": cash_total,
|
"cash_total": cash_total,
|
||||||
|
"cash_prefill": CASH_PREFILL,
|
||||||
|
"cash_net": cash_net,
|
||||||
"top_free_recipient": top_free_recipient,
|
"top_free_recipient": top_free_recipient,
|
||||||
"free_total_count": free_total_count,
|
"free_total_count": free_total_count,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,16 @@
|
|||||||
<span class="hist-price">{{ total_donations|euro }}</span>
|
<span class="hist-price">{{ total_donations|euro }}</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="fin-row">
|
<li class="fin-row">
|
||||||
<span class="hist-what">Zahlungen (User-Tab)</span>
|
<span class="hist-what">Cashless (User-Tab)</span>
|
||||||
<span class="hist-price">{{ user_payments_total|euro }}</span>
|
<span class="hist-price">{{ user_payments_total|euro }}</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="fin-row">
|
<li class="fin-row">
|
||||||
<span class="hist-what">Kasse (bar)</span>
|
<span class="hist-what">Kasse (bar, nach Vorschuss)</span>
|
||||||
<span class="hist-price">{{ cash_total|euro }}</span>
|
<span class="hist-price">{{ cash_net|euro }}</span>
|
||||||
|
</li>
|
||||||
|
<li class="fin-row">
|
||||||
|
<span class="hist-what">Kassen-Vorschuss</span>
|
||||||
|
<span class="hist-price">{{ cash_prefill|euro }}</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="fin-row">
|
<li class="fin-row">
|
||||||
<span class="hist-what">Einkaufspreis Getränke</span>
|
<span class="hist-what">Einkaufspreis Getränke</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user