# Generated by Django 2.1.2 on 2019-03-13 15:20

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 = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('partner', '0001_initial'),
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='Account',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('activate', models.BooleanField(default=True, verbose_name='启用')),
                ('name', models.CharField(max_length=20, verbose_name='账户名称')),
                ('account_number', models.CharField(blank=True, max_length=30, null=True, verbose_name='账号')),
                ('owner', models.CharField(blank=True, max_length=30, null=True, verbose_name='账户人')),
                ('bank', models.CharField(blank=True, max_length=30, null=True, verbose_name='银行名称')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('is_visible', models.BooleanField(default=True, verbose_name='显示')),
            ],
        ),
        migrations.CreateModel(
            name='Assign',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=10, verbose_name='金额')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='登记')),
            ],
            options={
                'verbose_name': '收款分配',
            },
            bases=(public.models.HasChangedMixin, models.Model),
        ),
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('state', models.CharField(choices=[('draft', '草稿'), ('confirm', '确认'), ('cancel', '取消'), ('done', '完成')], default='draft', max_length=10, verbose_name='状态')),
                ('order', public.fields.OrderField(db_index=True, default='New', max_length=26, verbose_name='订单号码')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('object_id', models.PositiveIntegerField()),
                ('date', models.DateField(verbose_name='日期')),
                ('due_date', models.DateField(verbose_name='到期日')),
                ('usage', models.CharField(max_length=50, verbose_name='款项用途')),
                ('type', models.CharField(choices=[('-1', '付款'), ('1', '收款')], default='-1', max_length=2, verbose_name='付款/收款')),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
                ('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invoice_entry', to=settings.AUTH_USER_MODEL, verbose_name='登记')),
                ('partner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoice_partner', to='partner.Partner', verbose_name='对方')),
            ],
            options={
                'verbose_name': '账单',
                'ordering': ('-created',),
            },
            bases=(public.models.HasChangedMixin, models.Model),
        ),
        migrations.CreateModel(
            name='InvoiceDueDateDefaultSet',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('default', models.CharField(choices=[('0', '立刻'), ('7', '7天后'), ('15', '15天后'), ('30', '30天后'), ('end_of_month', '月底'), ('end_of_year', '年底')], max_length=20, verbose_name='默认值选项')),
                ('updated', models.DateField(auto_now=True, verbose_name='更新日期')),
                ('content_type', models.ForeignKey(limit_choices_to={'model__in': ('salesorder', 'purchaseorder', 'movelocationorder', 'productionorder', 'inoutorder', 'inventoryorder')}, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType', unique=True, verbose_name='对应order')),
            ],
            options={
                'verbose_name': '订单账单限期默认设置',
            },
        ),
        migrations.CreateModel(
            name='InvoiceItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(blank=True, null=True)),
                ('line', public.fields.LineField(blank=True, verbose_name='行')),
                ('item', models.CharField(max_length=200, verbose_name='项目')),
                ('quantity', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='数量')),
                ('uom', models.CharField(choices=[('t', '吨'), ('m3', '立方'), ('m2', '平方'), ('cart', '车'), ('part', '夹'), ('piece', '件')], default='m2', max_length=10, verbose_name='计量单位')),
                ('price', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='单价')),
                ('content_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
                ('order', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='items', to='invoice.Invoice', verbose_name='账单')),
            ],
            options={
                'verbose_name': '账单项',
                'ordering': ('line',),
            },
            bases=(public.models.OrderItemSaveCreateCommentMixin, models.Model),
        ),
        migrations.CreateModel(
            name='Payment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField(verbose_name='日期')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('type', models.CharField(choices=[('-1', '付款'), ('1', '收款')], default='-1', max_length=2, verbose_name='支付/收款')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=10, verbose_name='金额')),
                ('confirm', models.BooleanField(default=False, verbose_name='确认款项')),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='invoice.Account', verbose_name='帐户')),
                ('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payment_entry', to=settings.AUTH_USER_MODEL, verbose_name='登记')),
                ('partner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='partner.Partner', verbose_name='对方')),
            ],
            options={
                'verbose_name': '收付款记录',
                'ordering': ('-created', 'confirm'),
            },
            bases=(public.models.HasChangedMixin, models.Model),
        ),
        migrations.AddField(
            model_name='assign',
            name='invoice',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assign_payments', to='invoice.Invoice', verbose_name='账单'),
        ),
        migrations.AddField(
            model_name='assign',
            name='payment',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assign_invoice', to='invoice.Payment', verbose_name='款项'),
        ),
        migrations.CreateModel(
            name='ExpensesInvoice',
            fields=[
            ],
            options={
                'verbose_name': '费用账单',
                'proxy': True,
                'indexes': [],
            },
            bases=('invoice.invoice',),
        ),
        migrations.CreateModel(
            name='PurchaseInvoice',
            fields=[
            ],
            options={
                'verbose_name': '采购账单',
                'proxy': True,
                'indexes': [],
            },
            bases=('invoice.invoice',),
        ),
        migrations.CreateModel(
            name='SalesInvoice',
            fields=[
            ],
            options={
                'verbose_name': '销售账单',
                'proxy': True,
                'indexes': [],
            },
            bases=('invoice.invoice',),
        ),
    ]
