mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 21:32:58 +00:00
29 lines
983 B
Python
29 lines
983 B
Python
from django.db import models
|
|
from django.contrib.auth import get_user_model
|
|
import uuid
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class WalletTransaction(models.Model):
|
|
TRANSACTION_TYPES = [
|
|
('top_up', 'Top Up'),
|
|
('agent_usage', 'Agent Usage'),
|
|
('refund', 'Refund'),
|
|
]
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='wallet_transactions')
|
|
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
|
type = models.CharField(max_length=20, choices=TRANSACTION_TYPES)
|
|
description = models.TextField()
|
|
agent_slug = models.CharField(max_length=100, blank=True)
|
|
stripe_session_id = models.CharField(max_length=200, blank=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
|
|
def __str__(self):
|
|
return f"{self.user.email} - {self.amount} AED ({self.type})"
|