from django.db import models
import uuid


class Request(models.Model):
    """Заявка покупателя (RFQ - Request For Quotation)"""
    uuid = models.CharField(max_length=100, unique=True, default=uuid.uuid4)
    product_uuid = models.CharField(max_length=100)
    quantity = models.DecimalField(max_digits=10, decimal_places=2)
    source_location_uuid = models.CharField(max_length=100)
    user_id = models.CharField(max_length=255)

    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = 'calculations'  # Keep old table name for data compatibility
        ordering = ['-created_at']

    def __str__(self):
        return f"Заявка {self.uuid} - {self.quantity}"
