20 lines
754 B
Python
20 lines
754 B
Python
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)}")
|