from django.db import models
from django.contrib.auth.models import User
# ユーザー
class userTrade(models.Model):
# ユーザー名
name = models.CharField(max_length=100)
# 備考
remarks = models.CharField(max_length=256, null=True, blank=True)
def __str__(self):
return self.name
# 仕入れ先
class userSupplier(models.Model):
# 仕入れ先
name = models.CharField(max_length=100)
# 備考
remarks = models.CharField(max_length=256, null=True, blank=True)
def __str__(self):
return self.name
# 商品
class item(models.Model):
# 商品名
name = models.CharField(max_length=100)
# 規格
size = models.CharField(max_length=100)
# 数量
quantity = models.FloatField()
def __str__(self):
return self.name
# 受注
class orderItem(models.Model):
# 記入日
createdDate = models.DateField(auto_now_add=True, null=True, blank=True)
# 納入日
deliveryDate = models.DateField(null=True, blank=True)
# 納入日(変更)
deliveryDateSub = models.DateField(null=True, blank=True)
# ユーザー
userTrade = models.ForeignKey(userTrade,related_name='UserTrade',on_delete=models.CASCADE, null=True, blank=True)
# 仕入れ先
supplier = models.ForeignKey(userSupplier,related_name='Supplier',on_delete=models.CASCADE, null=True, blank=True)
# 商品
item = models.ForeignKey(item,related_name='OrderItem',on_delete=models.CASCADE, null=True, blank=True)
# 規格
size = models.CharField(max_length=100, null=True, blank=True)
# 数量
quantity = models.FloatField(null=True, blank=True)
# 仕入れ値
purchasePrice = models.FloatField(null=True, blank=True)
# 売り値
sellingPrice = models.FloatField(null=True, blank=True)
# 利益
profit = models.FloatField(null=True, blank=True)
# 備考
remarks = models.CharField(max_length=256, null=True, blank=True)
def __str__(self):
return self.userTrade