get or create instead of get

This commit is contained in:
Sayyid Hamid Mahdavi 2025-10-25 16:25:18 +03:30
parent a8166a7bdf
commit 4efb4ab664

View file

@ -354,7 +354,7 @@ class CategoryDepositVerifyAPIView(generics.RetrieveAPIView):
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
else:
category = None
wallet = Wallet.objects.get(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, category=category)
wallet, created = Wallet.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, category=category)
return Transaction.objects.filter(application=application, payer_wallet=wallet).all()
def retrieve(self, request, *args, **kwargs):
@ -464,7 +464,7 @@ class CategoryWithdrawVerifyAPIView(generics.RetrieveAPIView):
category = get_object_or_404(Category.objects.all(), uuid=category_uuid)
else:
category = None
wallet = Wallet.objects.get(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, category=category)
wallet, created = Wallet.objects.get_or_create(owner_uuid=application.uuid, owner_type=TypeChoices.APPLICATION, category=category)
return Transaction.objects.filter(application=application, payee_wallet=wallet).all()
def retrieve(self, request, *args, **kwargs):