add detailed finance stuff and reuse euro teplate tag
This commit is contained in:
@@ -3,6 +3,7 @@ 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()
|
||||
|
||||
@@ -21,26 +22,26 @@ class Command(BaseCommand):
|
||||
amount = drink_dict["amount"]
|
||||
drink_list.append(f"{amount}x {name}")
|
||||
drink_list_str = ", ".join(drink_list)
|
||||
print(f"zu zahlen: {to_pay:.2f} € ({drink_list_str})")
|
||||
print(f"zu zahlen: {euro(to_pay)} ({drink_list_str})")
|
||||
|
||||
donated = user.donations_made
|
||||
if donated != 0:
|
||||
don_list = [f"{don.date:%d.%m.} {don.amount:.2f} €" for don in user.donations.order_by("date")]
|
||||
don_list = [f"{don.date:%d.%m.} {euro(don.amount)}" for don in user.donations.order_by("date")]
|
||||
don_list_str = ", ".join(don_list)
|
||||
print(f"gespendet: {donated:.2f} € ({don_list_str})")
|
||||
print(f"gespendet: {euro(donated)} ({don_list_str})")
|
||||
|
||||
paid = user.other_payments_made
|
||||
if paid != 0:
|
||||
pay_list = [f"{pay.purpose} {pay.amount:.2f} €" for pay in user.payments.order_by("date")]
|
||||
pay_list = [f"{pay.purpose} {euro(pay.amount)}" for pay in user.payments.order_by("date")]
|
||||
pay_list_str = ", ".join(pay_list)
|
||||
print(f"bezahlt: {paid:.2f} € ({pay_list_str})")
|
||||
print(f"bezahlt: {euro(paid)} ({pay_list_str})")
|
||||
|
||||
paid_back = user.paybacks_received
|
||||
if paid_back != 0:
|
||||
pb_list = [f"{pb.date:%d.%m.} {pb.amount:.2f} €" for pb in user.paybacks.order_by("date")]
|
||||
pb_list = [f"{pb.date:%d.%m.} {euro(pb.amount)}" for pb in user.paybacks.order_by("date")]
|
||||
pb_list_str = ", ".join(pb_list)
|
||||
print(f"zurückbekommen: {paid_back:.2f} € ({pb_list_str})")
|
||||
print(f"zurückbekommen: {euro(paid_back)} ({pb_list_str})")
|
||||
|
||||
balance = donated + paid - to_pay - paid_back
|
||||
print(f"==> STAND: {balance:.2f} €")
|
||||
print(f"==> STAND: {euro(balance)}")
|
||||
print()
|
||||
|
||||
Reference in New Issue
Block a user