Remove drink_stats / total_balance / user_stats commands
All three are now superseded by the staff-only /suff/dashboard/ page plus the year-scoped Drink and User admin views: drink_stats by the Drink list+detail, user_stats by the User list+detail breakdown, and total_balance by the dashboard's Refinanzierung gesamt panel. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
from django.core.management import BaseCommand
|
||||
from django.db.models import Sum
|
||||
|
||||
from gaehsnitz.models import Drink
|
||||
from gaehsnitz.templatetags.money import euro
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
for drink in Drink.objects.all():
|
||||
print(f"--- {drink.name} ---")
|
||||
|
||||
print(f"Kästen (laut Abrechnung):")
|
||||
ordered = drink.crates_ordered
|
||||
print(f" bestellt: {ordered}")
|
||||
purchased = drink.crates_purchased
|
||||
print(f" gekauft: {purchased}")
|
||||
full_ret = ordered - purchased
|
||||
print(f" voll zurück: {full_ret}")
|
||||
empty_ret = drink.crates_returned
|
||||
print(f" leer zurück: {empty_ret}")
|
||||
remaining = purchased - empty_ret
|
||||
print(f" übrig: {remaining}")
|
||||
|
||||
print("Flaschen (laut Strichliste):")
|
||||
bought = drink.bottles_total
|
||||
print(f" gekauft: {bought}")
|
||||
consumed = drink.consumption_list.aggregate(sum=Sum("amount"))["sum"] or 0
|
||||
print(f" getrunken: {consumed}")
|
||||
remaining = bought - consumed
|
||||
print(f" übrig: {remaining}")
|
||||
purchase_value = remaining * drink.purchase_price_per_bottle
|
||||
print(f" Wert: {euro(purchase_value)}")
|
||||
@@ -1,19 +0,0 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management import BaseCommand
|
||||
from django.db.models import Sum
|
||||
|
||||
from gaehsnitz.models import Payment, Donation
|
||||
from gaehsnitz.templatetags.money import euro
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
all_donations_sum = Donation.objects.all().aggregate(sum=Sum("amount"))["sum"]
|
||||
print(f"Alle Spenden/Zahlungen: {euro(all_donations_sum)}")
|
||||
all_payments_sum = Payment.objects.all().aggregate(sum=Sum("amount"))["sum"]
|
||||
print(f"Alle Ausgaben: {euro(all_payments_sum)}")
|
||||
balance = all_donations_sum - all_payments_sum
|
||||
print("-------------------------")
|
||||
print(f"Bilanz: {euro(balance)}")
|
||||
@@ -1,23 +0,0 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management import BaseCommand
|
||||
from django.db.models import Sum
|
||||
|
||||
from gaehsnitz.models import Drink
|
||||
from gaehsnitz.templatetags.money import euro
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
id_to_name = {d.id: d.name for d in Drink.objects.all()}
|
||||
for user in User.objects.all().order_by("username"):
|
||||
to_pay = user.consumed_drinks_price
|
||||
if to_pay != 0:
|
||||
paid_consumption = user.consumption_list.filter(for_free=False)
|
||||
drink_list = []
|
||||
for drink_dict in paid_consumption.values("drink_id").annotate(amount=Sum("amount")):
|
||||
name = id_to_name[drink_dict["drink_id"]]
|
||||
amount = drink_dict["amount"]
|
||||
drink_list.append(f"{amount}x {name}")
|
||||
print(f"{user.username.capitalize()}: {euro(to_pay)} ({', '.join(drink_list)})")
|
||||
Reference in New Issue
Block a user