added gunicorn, and initial transaction split ability
This commit is contained in:
parent
b25c3921f9
commit
9e10b5e685
@ -123,6 +123,9 @@ class Transaction(models.Model):
|
|||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
is_split = models.models.BooleanField(default=False)
|
||||||
|
split_parent = models.models.ForeignKey(Transaction, on_delete=models.CASCADE, blank=True, null=True, related_name="split_children")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def qid(self):
|
def qid(self):
|
||||||
return f"T{self.pk}"
|
return f"T{self.pk}"
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class InstitutionViewSet(viewsets.ReadOnlyModelViewSet):
|
|||||||
class TransactionViewSet(viewsets.ModelViewSet):
|
class TransactionViewSet(viewsets.ModelViewSet):
|
||||||
"""API endpoint that allows Banks to be viewed.
|
"""API endpoint that allows Banks to be viewed.
|
||||||
"""
|
"""
|
||||||
queryset = Transaction.objects.all()
|
queryset = Transaction.objects.filter(is_split=False)
|
||||||
serializer_class = TransactionSerializer
|
serializer_class = TransactionSerializer
|
||||||
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
@ -74,6 +74,22 @@ class TransactionViewSet(viewsets.ModelViewSet):
|
|||||||
'trans_id': ['exact', 'lte', 'gte', 'isnull'],
|
'trans_id': ['exact', 'lte', 'gte', 'isnull'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action(detail=True, methods=['post'], url_path='split')
|
||||||
|
def split_transaction(self, request, pk=None):
|
||||||
|
parent = self.get_object()
|
||||||
|
base_information = {"authorized_date": parent.authorized_date,
|
||||||
|
"bank": parent.bank,
|
||||||
|
"name": parent.name,
|
||||||
|
"details": parent.details,
|
||||||
|
"slice": parent.slice,
|
||||||
|
"trans_id": parent.trans_id,
|
||||||
|
"split_parent": parent
|
||||||
|
}
|
||||||
|
child1 = Transaction.objects.create(**base_information)
|
||||||
|
child1.name = f"{child1.name}.split1"
|
||||||
|
child2 = Transaction.objects.create(**base_information)
|
||||||
|
child2.name = f"{child1.name}.split2"
|
||||||
|
|
||||||
|
|
||||||
class RuleViewSet(viewsets.ReadOnlyModelViewSet):
|
class RuleViewSet(viewsets.ReadOnlyModelViewSet):
|
||||||
"""API endpoint that allows Banks to be viewed.
|
"""API endpoint that allows Banks to be viewed.
|
||||||
|
|||||||
@ -24,3 +24,4 @@ requests-oauthlib==1.3.0
|
|||||||
sqlparse==0.4.1
|
sqlparse==0.4.1
|
||||||
urllib3==1.26.4
|
urllib3==1.26.4
|
||||||
whitenoise==5.2.0
|
whitenoise==5.2.0
|
||||||
|
gunicorn==20.1.0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user