Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
MustafaMunir123 committed Dec 15, 2023
1 parent aa484b1 commit 3481a37
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/transactions/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ def get_serializer():
def post(self, request):
try:
user = request.user
print("Boss")
serializer = self.get_serializer()
serializer = serializer(data=request.data)
print("Toss")
serializer.is_valid(raise_exception=True)
serializer.save(user=user)
print("Loss")
return success_response(data=serializer.validated_data, status=status.HTTP_200_OK)
except Exception as ex:
raise ex
Expand Down Expand Up @@ -70,11 +73,12 @@ def post(self, request):
return success_response(status=status.HTTP_200_OK, data=f"transaction with id {entry_no} updated.")

last_transaction = Transaction.objects.last()
last_entry = last_transaction.entry_no
if entry_no != last_entry + 1:
return success_response(
status=status.HTTP_400_BAD_REQUEST, success=False, data="invalid transaction id"
)
if last_transaction:
last_entry = last_transaction.entry_no
if entry_no != last_entry + 1:
return success_response(
status=status.HTTP_400_BAD_REQUEST, success=False, data="invalid transaction id"
)

to_account = request.data.pop("to_account", None)
from_account = request.data.pop("from_account", None)
Expand Down

0 comments on commit 3481a37

Please sign in to comment.