# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-01-31 07:32
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='BusinessEntity',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_on', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Created at')),
                ('last_updated_on', models.DateTimeField(auto_now=True, verbose_name='Last updated on')),
                ('name', models.CharField(max_length=255, verbose_name='Name')),
                ('RFC', models.CharField(db_index=True, max_length=255, verbose_name='RFC')),
                ('legal_name', models.CharField(max_length=512, verbose_name='Legal name')),
            ],
            options={
                'ordering': ['-id'],
                'verbose_name': 'Business Entity',
                'verbose_name_plural': 'Business Entities',
            },
        ),
        migrations.CreateModel(
            name='Company',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_on', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Created at')),
                ('last_updated_on', models.DateTimeField(auto_now=True, verbose_name='Last updated on')),
                ('name', models.CharField(max_length=255, verbose_name='Name')),
                ('RFC', models.CharField(db_index=True, max_length=255, verbose_name='RFC')),
                ('legal_name', models.CharField(max_length=512, verbose_name='Legal name')),
                ('tax_private_key', models.CharField(max_length=512, verbose_name='Private Key')),
            ],
            options={
                'ordering': ['-id'],
                'verbose_name': 'Company',
                'verbose_name_plural': 'Companies',
            },
        ),
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_on', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Created at')),
                ('last_updated_on', models.DateTimeField(auto_now=True, verbose_name='Last updated on')),
                ('title', models.CharField(db_index=True, max_length=512, verbose_name='Title')),
                ('slug', models.SlugField(max_length=512, verbose_name='Slug')),
                ('description', models.TextField(blank=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Company')),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='customer', to='core.BusinessEntity')),
            ],
            options={
                'ordering': ['-id'],
                'verbose_name': 'Invoice',
                'verbose_name_plural': 'Invoices',
            },
        ),
        migrations.CreateModel(
            name='InvoicedProduct',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_on', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Created at')),
                ('last_updated_on', models.DateTimeField(auto_now=True, verbose_name='Last updated on')),
                ('quantity', models.DecimalField(decimal_places=2, max_digits=15, verbose_name='Quantity')),
                ('unit_cost', models.DecimalField(decimal_places=2, max_digits=15, verbose_name='Unit cost')),
                ('discount_percentage', models.DecimalField(decimal_places=2, max_digits=15, verbose_name='Discount percentage')),
                ('tax_rate_percentage', models.DecimalField(decimal_places=2, max_digits=15, verbose_name='Tax rate percentage')),
                ('invoice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Invoice')),
            ],
            options={
                'ordering': ['-id'],
                'verbose_name': 'Invoiced product',
                'verbose_name_plural': 'Invoiced products',
            },
        ),
        migrations.CreateModel(
            name='PaymentPlan',
            fields=[
                ('created_on', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Created at')),
                ('last_updated_on', models.DateTimeField(auto_now=True, verbose_name='Last updated on')),
                ('id', models.CharField(max_length=50, primary_key=True, serialize=False, verbose_name='Id')),
                ('name', models.CharField(max_length=100, verbose_name='Name')),
                ('description', models.CharField(blank=True, max_length=255, verbose_name='Description')),
                ('is_active', models.BooleanField(default=True, verbose_name='Active?')),
            ],
            options={
                'ordering': ['-id'],
                'verbose_name': 'Payment plan',
                'verbose_name_plural': 'Payment plans',
            },
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_on', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Created at')),
                ('last_updated_on', models.DateTimeField(auto_now=True, verbose_name='Last updated on')),
                ('name', models.CharField(max_length=255, verbose_name='Name')),
                ('slug', models.SlugField(max_length=255, verbose_name='Slug')),
                ('base_price', models.DecimalField(decimal_places=2, default=0, max_digits=15, verbose_name='Base price')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Company')),
            ],
            options={
                'ordering': ['-id'],
                'verbose_name': 'Product',
                'verbose_name_plural': 'Products',
            },
        ),
        migrations.CreateModel(
            name='Unit',
            fields=[
                ('created_on', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Created at')),
                ('last_updated_on', models.DateTimeField(auto_now=True, verbose_name='Last updated on')),
                ('id', models.CharField(max_length=50, primary_key=True, serialize=False, verbose_name='Id')),
                ('name', models.CharField(max_length=100, verbose_name='Name')),
                ('description', models.CharField(blank=True, max_length=255, verbose_name='Description')),
                ('is_active', models.BooleanField(default=True, verbose_name='Active?')),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Company')),
            ],
            options={
                'ordering': ['-id'],
                'verbose_name': 'Unit',
                'verbose_name_plural': 'Units',
            },
        ),
        migrations.AddField(
            model_name='invoicedproduct',
            name='product',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Product'),
        ),
        migrations.AddField(
            model_name='invoicedproduct',
            name='unit',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Unit'),
        ),
        migrations.AddField(
            model_name='invoice',
            name='products',
            field=models.ManyToManyField(through='core.InvoicedProduct', to='core.Product'),
        ),
        migrations.AddField(
            model_name='company',
            name='payment_plan',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.PaymentPlan'),
        ),
        migrations.AddField(
            model_name='businessentity',
            name='company',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='parent_company', to='core.Company'),
        ),
    ]
