# Generated by Django 2.1.7 on 2019-03-13 16:15

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import public.fields
import public.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('product', '0001_initial'),
        ('partner', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='PurchaseOrder',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('state', models.CharField(choices=[('draft', '草稿'), ('confirm', '确认'), ('done', '完成'), ('cancel', '取消')], default='draft', max_length=20, verbose_name='状态')),
                ('date', models.DateField(verbose_name='日期')),
                ('created', models.DateField(auto_now_add=True, verbose_name='创建日期')),
                ('updated', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('order', public.fields.OrderField(db_index=True, default='New', max_length=10, unique=True, verbose_name='订单号码')),
                ('currency', models.CharField(choices=[('USD', '$美元'), ('CNY', '￥人民币'), ('EUR', '€欧元')], max_length=10, verbose_name='货币')),
                ('uom', models.CharField(choices=[('t', '吨'), ('m3', '立方')], max_length=10, verbose_name='计量单位')),
                ('batch', models.CharField(blank=True, help_text='如果不填，则采取"-"号前或编号前2位作为批次号', max_length=10, null=True, verbose_name='批次')),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='product.Category', verbose_name='品种分类')),
                ('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='purchaseorder_entry', to=settings.AUTH_USER_MODEL, verbose_name='登记人')),
                ('handler', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='purchaseorder_handler', to=settings.AUTH_USER_MODEL, verbose_name='经办人')),
                ('partner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='purchase_order', to='partner.Supplier', verbose_name='供应商')),
                ('quarry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='product.Quarry', verbose_name='矿口')),
            ],
            options={
                'verbose_name': '采购订单',
                'ordering': ['-order'],
            },
            bases=(public.models.HasChangedMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PurchaseOrderItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('line', public.fields.LineField(blank=True, verbose_name='行')),
                ('name', models.CharField(max_length=20, verbose_name='编号')),
                ('type', models.CharField(default='block', max_length=10, verbose_name='类型')),
                ('batch', models.CharField(blank=True, max_length=10, null=True, verbose_name='批次')),
                ('price', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='单价')),
                ('piece', models.IntegerField(default=1, verbose_name='件')),
                ('quantity', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='数量')),
                ('uom', models.CharField(choices=[('t', '吨'), ('m3', '立方')], default='t', max_length=10, verbose_name='计量单位')),
                ('weight', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True, verbose_name='重量')),
                ('long', models.IntegerField(blank=True, null=True, verbose_name='长')),
                ('width', models.IntegerField(blank=True, null=True, verbose_name='宽')),
                ('height', models.IntegerField(blank=True, null=True, verbose_name='高')),
                ('m3', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True, verbose_name='立方')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='purchase.PurchaseOrder', verbose_name='订单')),
                ('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='product.Product', verbose_name='编号')),
            ],
            options={
                'verbose_name': '采购订单行',
                'ordering': ['line'],
            },
        ),
        migrations.AlterUniqueTogether(
            name='purchaseorderitem',
            unique_together={('order', 'name'), ('order', 'name', 'product')},
        ),
    ]
