from django.db import models
import uuid
from . import CustomUser

class Purchase(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
    user = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
    identifier = models.BigIntegerField()
    purchase_date = models.DateTimeField()
    product_id = models.CharField(max_length=100)
    quantity = models.IntegerField(null=True, blank=True)
    revocation_date = models.DateTimeField(null=True, blank=True)

    def __str__(self):
        return f"{self.identifier} > {self.product_id} - {self.purchase_date} - {self.user.username}"
