# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-11-01 13:54
from __future__ import unicode_literals

from decimal import Decimal
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import simple_history.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('supplier_app', '0003_merge_20191101_1328'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('message', models.CharField(max_length=200)),
                ('comment_date_received', models.DateTimeField(auto_now_add=True)),
                ('comment_file', models.FileField(blank=True, upload_to='file', validators=[django.core.validators.FileExtensionValidator(allowed_extensions=['pdf'])])),
            ],
        ),
        migrations.CreateModel(
            name='HistoricalInvoice',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('currency', models.CharField(choices=[('ARS', 'ARS'), ('USD', 'USD')], max_length=200, verbose_name='Currency')),
                ('status', models.CharField(choices=[('1', 'APPROVED'), ('2', 'NEW'), ('3', 'CHANGES REQUESTED'), ('4', 'REJECTED'), ('5', 'PAID')], default='2', max_length=40, verbose_name='Status')),
                ('po_number', models.CharField(help_text='ex: 12341234', max_length=200, verbose_name='PO number')),
                ('invoice_date', models.DateField(verbose_name='Invoice date')),
                ('invoice_due_date', models.DateField(verbose_name='Due Date')),
                ('invoice_date_received', models.DateTimeField(blank=True, editable=False, verbose_name='Date Received')),
                ('invoice_number', models.CharField(max_length=20, verbose_name='Invoice Number')),
                ('invoice_type', models.CharField(choices=[('A', 'A'), ('C', 'C')], max_length=200, verbose_name='Invoice Type')),
                ('net_amount', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))], verbose_name='Net amount')),
                ('vat', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))], verbose_name='Tax Liens')),
                ('total_amount', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))], verbose_name='Total')),
                ('invoice_file', models.TextField(blank=True, max_length=100, verbose_name='Invoice File')),
                ('workday_id', models.PositiveIntegerField(blank=True, null=True)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('invoice_eb_entity', models.ForeignKey(blank=True, db_constraint=False, default=None, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='supplier_app.EBEntity')),
                ('taxpayer', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='supplier_app.TaxPayer')),
                ('user', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'historical invoice',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('currency', models.CharField(choices=[('ARS', 'ARS'), ('USD', 'USD')], max_length=200, verbose_name='Currency')),
                ('status', models.CharField(choices=[('1', 'APPROVED'), ('2', 'NEW'), ('3', 'CHANGES REQUESTED'), ('4', 'REJECTED'), ('5', 'PAID')], default='2', max_length=40, verbose_name='Status')),
                ('po_number', models.CharField(help_text='ex: 12341234', max_length=200, verbose_name='PO number')),
                ('invoice_date', models.DateField(verbose_name='Invoice date')),
                ('invoice_due_date', models.DateField(verbose_name='Due Date')),
                ('invoice_date_received', models.DateTimeField(auto_now_add=True, verbose_name='Date Received')),
                ('invoice_number', models.CharField(max_length=20, verbose_name='Invoice Number')),
                ('invoice_type', models.CharField(choices=[('A', 'A'), ('C', 'C')], max_length=200, verbose_name='Invoice Type')),
                ('net_amount', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))], verbose_name='Net amount')),
                ('vat', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.00'))], verbose_name='Tax Liens')),
                ('total_amount', models.DecimalField(decimal_places=2, max_digits=20, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))], verbose_name='Total')),
                ('invoice_file', models.FileField(blank=True, upload_to='file', verbose_name='Invoice File')),
                ('workday_id', models.PositiveIntegerField(blank=True, null=True)),
                ('invoice_eb_entity', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='supplier_app.EBEntity')),
                ('taxpayer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='supplier_app.TaxPayer')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='comment',
            name='invoice',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='invoices_app.Invoice'),
        ),
        migrations.AddField(
            model_name='comment',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='invoice',
            unique_together=set([('taxpayer', 'invoice_number')]),
        ),
    ]
