forked from uncloud/uncloud
55 lines
857 B
Python
55 lines
857 B
Python
from django.shortcuts import render
|
|
|
|
# Create your views here.
|
|
|
|
|
|
# to be implemented
|
|
class BalanceViewSet(viewsets.ModelViewSet):
|
|
# here we return a number
|
|
# number = sum(payments) - sum(bills)
|
|
|
|
bills = Bills.objects.filter(owner=self.request.user)
|
|
payments = Payment.objects.filter(owner=self.request.user)
|
|
|
|
# sum_paid = sum([ amount for amount payments..,. ]) # you get the picture
|
|
# sum_to_be_paid = sum([ amount for amount bills..,. ]) # you get the picture
|
|
|
|
|
|
class Bills(viewset.ModelViewSet):
|
|
def unpaid(self, request):
|
|
return Bills.objects.filter(owner=self.request.user, paid=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
serializer_class = BillSerializer
|
|
permission_classes = [permissions.IsAuthenticated]
|
|
http_method_names = ['get']
|
|
|
|
def get_queryset(self):
|
|
return self.request.user.get_bills()
|