handle model changes in management commands
This commit is contained in:
@@ -17,17 +17,3 @@ class Command(BaseCommand):
|
||||
balance = all_donations_sum - all_payments_sum
|
||||
print("-------------------------")
|
||||
print(f"Bilanz: {euro(balance)}")
|
||||
print()
|
||||
|
||||
print("Leute mit Schulden:")
|
||||
awaited_sum = 0
|
||||
for user in User.objects.all().order_by("username"):
|
||||
if (value := user.balance) < 0:
|
||||
print(f"{user}: {euro(-value)}")
|
||||
awaited_sum -= value
|
||||
print("-------------------------")
|
||||
print(f"gesamt: {euro(awaited_sum)}")
|
||||
balance_after_payments = balance + awaited_sum
|
||||
print("-------------------------")
|
||||
print(f"Bilanz danach: {euro(balance_after_payments)}")
|
||||
print()
|
||||
|
||||
@@ -12,7 +12,6 @@ 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"):
|
||||
print(f">>> {user.username.capitalize()}")
|
||||
to_pay = user.consumed_drinks_price
|
||||
if to_pay != 0:
|
||||
paid_consumption = user.consumption_list.filter(for_free=False)
|
||||
@@ -21,27 +20,4 @@ class Command(BaseCommand):
|
||||
name = id_to_name[drink_dict["drink_id"]]
|
||||
amount = drink_dict["amount"]
|
||||
drink_list.append(f"{amount}x {name}")
|
||||
drink_list_str = ", ".join(drink_list)
|
||||
print(f"zu zahlen: {euro(to_pay)} ({drink_list_str})")
|
||||
|
||||
donated = user.donations_made
|
||||
if donated != 0:
|
||||
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: {euro(donated)} ({don_list_str})")
|
||||
|
||||
paid = user.other_payments_made
|
||||
if paid != 0:
|
||||
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: {euro(paid)} ({pay_list_str})")
|
||||
|
||||
paid_back = user.paybacks_received
|
||||
if paid_back != 0:
|
||||
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: {euro(paid_back)} ({pb_list_str})")
|
||||
|
||||
balance = donated + paid - to_pay - paid_back
|
||||
print(f"==> STAND: {euro(balance)}")
|
||||
print()
|
||||
print(f"{user.username.capitalize()}: {euro(to_pay)} ({", ".join(drink_list)})")
|
||||
|
||||
Reference in New Issue
Block a user