from django.shortcuts import render

# Create your views here.

@@ -9,55 +9,1951 @@
 ngo.
-shortcuts import render%0A%0A# Create your views here.
+db.models import Q%0A%0Afrom rest_framework.generics import ListAPIView%0Afrom rest_framework.viewsets import ModelViewSet%0A%0Afrom accounting import models, serializers%0A%0A%0Aclass LedgerViewSet(ModelViewSet):%0A    queryset = models.Ledger.objects.all()%0A    serializer_class = serializers.LedgerSerializer%0A%0A%0Aclass LedgersByCompanyList(ListAPIView):%0A    serializer_class = serializers.LedgerSerializer%0A%0A    def get_queryset(self):%0A        pk = self.kwargs%5B'pk'%5D%0A        return models.Ledger.objects.filter(company=pk)%0A%0A%0Aclass AccountViewSet(ModelViewSet):%0A    queryset = models.Account.objects.all()%0A    serializer_class = serializers.AccountSerializer%0A%0A%0Aclass AccountsByLedgerList(ListAPIView):%0A    serializer_class = serializers.AccountSerializer%0A%0A    def get_queryset(self):%0A        pk = self.kwargs%5B'pk'%5D%0A        return models.Account.objects.filter(ledger=pk)%0A%0A%0Aclass AccountsByAccountSubtypeList(ListAPIView):%0A    serializer_class = serializers.AccountSerializer%0A%0A    def get_queryset(self):%0A        pk = self.kwargs%5B'pk'%5D%0A        return models.Account.objects.filter(account_subtype=pk)%0A%0A%0Aclass AccountSubtypeViewSet(ModelViewSet):%0A    queryset = models.AccountSubtype.objects.all()%0A    serializer_class = serializers.AccountSubtypeSerializer%0A%0A%0Aclass AccountSubtypesByCompanyList(ListAPIView):%0A    serializer_class = serializers.AccountSubtypeSerializer%0A%0A    def get_queryset(self):%0A        pk = self.kwargs%5B'pk'%5D%0A        return models.AccountSubtype.objects.filter(company=pk)%0A%0A%0A# TODO: Perhaps this should be a read-only serializer.%0Aclass TransactionViewSet(ModelViewSet):%0A    queryset = models.Transaction.objects.all()%0A    serializer_class = serializers.TransactionSerializer%0A%0A%0Aclass TransactionsByAccountList(ListAPIView):%0A    serializer_class = serializers.TransactionSerializer%0A%0A    def get_queryset(self):%0A        pk = self.kwargs%5B'pk'%5D%0A        return models.Transaction.objects.filter(%0A            Q(debit_account) %7C Q(credit_account)%0A        )
 %0A

ADD initial accounting/views.py