You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
3.9 KiB
72 lines
3.9 KiB
3 weeks ago
|
from django.db import models
|
||
|
|
||
|
class Product(models.Model):
|
||
|
name = models.CharField(max_length=255, verbose_name="Наименование товара")
|
||
|
manufacturer_name = models.CharField(max_length=255, verbose_name="Производитель")
|
||
|
manufacturer_country = models.CharField(max_length=255, verbose_name="Страна производителя")
|
||
|
manufacturer_code = models.CharField(max_length=50, verbose_name="Код производителя", blank=True, null=True)
|
||
|
dimensions = models.CharField(max_length=255, verbose_name="Размеры", blank=True, null=True)
|
||
|
unit_of_measure = models.CharField(max_length=50, verbose_name="Единица измерения")
|
||
|
shelf_life_days = models.IntegerField(verbose_name="Срок годности (дни)")
|
||
|
barcode = models.CharField(max_length=50, unique=True, verbose_name="Штрихкод")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
|
||
|
class StorageLocation(models.Model):
|
||
|
TYPE_CHOICES = [
|
||
|
('Store', 'Магазин'),
|
||
|
('Distribution Center', 'Распределительный центр'),
|
||
|
('Office', 'Офис'),
|
||
|
]
|
||
|
name = models.CharField(max_length=255, verbose_name="Наименование")
|
||
|
type = models.CharField(max_length=50, choices=TYPE_CHOICES, verbose_name="Тип места хранения")
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.name
|
||
|
|
||
|
|
||
|
class StockOperation(models.Model):
|
||
|
OPERATION_TYPE_CHOICES = [
|
||
|
('Incoming', 'Приход'),
|
||
|
('Outgoing', 'Расход'),
|
||
|
('Transfer', 'Перемещение'),
|
||
|
]
|
||
|
product = models.ForeignKey(Product, on_delete=models.CASCADE, verbose_name="Товар")
|
||
|
location = models.ForeignKey(StorageLocation, on_delete=models.CASCADE, verbose_name="Место хранения")
|
||
|
operation_type = models.CharField(max_length=50, choices=OPERATION_TYPE_CHOICES, verbose_name="Тип операции")
|
||
|
quantity = models.IntegerField(verbose_name="Количество")
|
||
|
operation_date = models.DateTimeField(auto_now_add=True, verbose_name="Дата операции")
|
||
|
expiration_date = models.DateField(blank=True, null=True, verbose_name="Срок годности")
|
||
|
|
||
|
def __str__(self):
|
||
|
return f"{self.operation_type} - {self.product.name}"
|
||
|
|
||
|
|
||
|
class PriceList(models.Model):
|
||
|
PRICE_TYPE_CHOICES = [
|
||
|
('Regular', 'Регулярная'),
|
||
|
('Discount', 'Скидочная'),
|
||
|
('Promotional', 'Акционная'),
|
||
|
]
|
||
|
product = models.ForeignKey(Product, on_delete=models.CASCADE, verbose_name="Товар")
|
||
|
price_type = models.CharField(max_length=50, choices=PRICE_TYPE_CHOICES, verbose_name="Тип цены")
|
||
|
entry_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="Входная цена")
|
||
|
final_price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="Итоговая цена")
|
||
|
date_effective = models.DateField(verbose_name="Дата вступления в силу")
|
||
|
constraint_percent_limit = models.DecimalField(max_digits=5, decimal_places=2, default=1000, verbose_name="Лимит на наценку (%)")
|
||
|
constraint_price_change = models.DecimalField(max_digits=5, decimal_places=2, default=90, verbose_name="Лимит на изменение цены (%)")
|
||
|
|
||
|
def __str__(self):
|
||
|
return f"{self.price_type} - {self.product.name}"
|
||
|
|
||
|
|
||
|
class Inventory(models.Model):
|
||
|
product = models.ForeignKey(Product, on_delete=models.CASCADE, verbose_name="Товар")
|
||
|
location = models.ForeignKey(StorageLocation, on_delete=models.CASCADE, verbose_name="Место хранения")
|
||
|
quantity = models.IntegerField(verbose_name="Количество")
|
||
|
inventory_date = models.DateField(verbose_name="Дата инвентаризации")
|
||
|
|
||
|
def __str__(self):
|
||
|
return f"Инвентаризация {self.product.name} - {self.location.name}"
|