feat(admin): enhance AdminTopupCreateView to support custom top-up descriptions
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m25s

This commit is contained in:
2025-07-27 19:55:22 +05:00
parent e3c2d4450f
commit 19321da0be
2 changed files with 10 additions and 3 deletions

View File

@@ -606,6 +606,8 @@ class AdminTopupCreateView(StaffEditorPermissionMixin, generics.CreateAPIView):
data = request.data
user_id = data.get("user_id")
amount = data.get("amount")
topup_description = ""
admin_description = data.get("description", "")
if not getattr(request.user, "is_admin", False):
return Response(
{"message": "You are not authorized to perform this action."},
@@ -635,8 +637,12 @@ class AdminTopupCreateView(StaffEditorPermissionMixin, generics.CreateAPIView):
payment_type="CASH",
status="PAID",
)
description = f"Topup of {amount} MVR (Cash)"
user.add_wallet_funds(amount, description, topup.id)
default_description = f"Topup of {amount} MVR (Cash)"
if admin_description and admin_description.strip() != "":
topup_description = admin_description.strip()
else:
topup_description = default_description
user.add_wallet_funds(amount, topup_description, topup.id)
serializer = TopupSerializer(topup)
return Response(serializer.data, status=status.HTTP_201_CREATED)