implement balance getting

This commit is contained in:
Nico Schottelius 2021-01-01 12:41:54 +01:00
commit 6c15d2086e
7 changed files with 53 additions and 65 deletions

View file

@ -68,16 +68,6 @@ class Currency(models.TextChoices):
# USD = 'USD', _('US Dollar')
def get_balance_for_user(user):
bills = reduce(
lambda acc, entry: acc + entry.total,
Bill.objects.filter(owner=user),
0)
payments = reduce(
lambda acc, entry: acc + entry.amount,
Payment.objects.filter(owner=user),
0)
return payments - bills
###
# Stripe