from django.db import models
from apps.mtm.models import Mgroup, Material
from apps.utils.models import CommonADModel, BaseModel
from apps.mtm.models import Mgroup
from apps.wpm.models import SfLog
# Create your models here.

class Fee(BaseModel):
    """TN:费用"""
    name = models.CharField('名称', max_length=20)
    cate = models.CharField('父名称', max_length=20)
    element = models.CharField('要素', max_length=20, help_text='直接材料/直接人工/制造费用')
    sort = models.PositiveSmallIntegerField('排序', default=1)


class FeeSet(CommonADModel):
    """TN:费用集合"""
    year = models.PositiveSmallIntegerField('年份')
    month = models.PositiveSmallIntegerField('月份')
    mgroup = models.ForeignKey(Mgroup, verbose_name='关联工段', on_delete=models.CASCADE)
    fee = models.ForeignKey(Fee, verbose_name='关联费用', on_delete=models.CASCADE)
    cost_unit = models.FloatField('单位成本')


class PriceSet(CommonADModel):
    """TN:价格集合"""
    year = models.PositiveSmallIntegerField('年份')
    month = models.PositiveSmallIntegerField('月份')
    material = models.ForeignKey('mtm.material', on_delete=models.CASCADE, verbose_name='关联物料')
    price_unit = models.FloatField('单价', null=True, blank=True)