mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-12-02 05:04:25 +01:00
feat(api): read and write sub-transactions
Transactions, installment plans and recurring transactions take a nested sub_transactions list; their amount becomes the parts' sum. Changing only the amount of a split transaction, or adding parts to a transfer, is a validation error.
This commit is contained in:
1 parent
ae245fb1d1
commit
5459865366
3 files changed
+206
-29
No files matched your search
@@ -52,7 +52,7 @@ class TransactionViewSet(viewsets.ModelViewSet):
|
||||
ordering = ["-id"]
|
||||
|
||||
def get_queryset(self):
|
||||
return Transaction.objects.all()
|
||||
return Transaction.objects.prefetch_related("sub_transactions")
|
||||
|
||||
def perform_create(self, serializer):
|
||||
instance = serializer.save()
|
||||
@@ -145,7 +145,7 @@ class InstallmentPlanViewSet(viewsets.ModelViewSet):
|
||||
ordering = ["-id"]
|
||||
|
||||
def get_queryset(self):
|
||||
return InstallmentPlan.objects.all()
|
||||
return InstallmentPlan.objects.prefetch_related("sub_transactions")
|
||||
|
||||
|
||||
class RecurringTransactionViewSet(viewsets.ModelViewSet):
|
||||
@@ -175,4 +175,4 @@ class RecurringTransactionViewSet(viewsets.ModelViewSet):
|
||||
ordering = ["-id"]
|
||||
|
||||
def get_queryset(self):
|
||||
return RecurringTransaction.objects.all()
|
||||
return RecurringTransaction.objects.prefetch_related("sub_transactions")
|
||||
Reference in new issue
Block a user