import uuid from django.db import models from django.conf import settings from decimal import Decimal class WalletTransaction(models.Model): TRANSACTION_TYPES = [ ('deposit', 'Deposit'), ('withdrawal', 'Withdrawal'), ('fee', 'Fee'), ] STATUS_CHOICES = [ ('pending', 'Pending'), ('completed', 'Completed'), ('failed', 'Failed'), ] id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='wallet_transactions') transaction_type = models.CharField(max_length=20, choices=TRANSACTION_TYPES) amount = models.DecimalField(max_digits=10, decimal_places=2) status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending') stripe_payment_intent_id = models.CharField(max_length=255, null=True, blank=True) description = models.TextField(blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Meta: ordering = ['-created_at'] def __str__(self): return f"{self.user.email} - {self.transaction_type} - ${self.amount}"