# Generated by Django 2.2 on 2019-09-23 07:52

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import jacc.models
import jutil.cache


class Migration(migrations.Migration):

    initial = True
    replaces = [('jacc', '0001_initial'), ('jacc', '0002_auto_20171020_1331'), ('jacc', '0003_auto_20171030_1933'), ('jacc', '0004_auto_20171030_1935'), ('jacc', '0005_auto_20171030_1958'), ('jacc', '0006_account_name'), ('jacc', '0007_invoice_number'), ('jacc', '0008_auto_20180121_1705'), ('jacc', '0009_accountentry_archived'), ('jacc', '0010_auto_20180201_0734'), ('jacc', '0011_auto_20180208_1146'), ('jacc', '0012_auto_20180218_0638'), ('jacc', '0013_auto_20180329_1052'), ('jacc', '0014_auto_20180430_1506'), ('jacc', '0015_auto_20180505_1512'), ('jacc', '0016_auto_20180505_1604'), ('jacc', '0017_auto_20180807_1808'), ('jacc', '0018_auto_20181008_2322'), ('jacc', '0019_entrytype_identifier')]

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Account',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, db_index=True, default='', max_length=32, verbose_name='name')),
                ('currency', models.CharField(blank=True, choices=[('EUR', 'EUR'), ('USD', 'USD')], default='EUR', max_length=3, verbose_name='currency')),
                ('created', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, db_index=True, verbose_name='last modified')),
            ],
            options={
                'verbose_name': 'account',
                'verbose_name_plural': 'accounts',
            },
        ),
        migrations.CreateModel(
            name='AccountEntrySourceFile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, db_index=True, default='', max_length=255, verbose_name='name')),
                ('created', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, db_index=True, verbose_name='last modified')),
            ],
            options={
                'verbose_name': 'account entry source file',
                'verbose_name_plural': 'account entry source files',
            },
        ),
        migrations.CreateModel(
            name='AccountType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(db_index=True, max_length=32, unique=True, verbose_name='code')),
                ('name', models.CharField(db_index=True, max_length=64, unique=True, verbose_name='name')),
                ('is_asset', models.BooleanField(verbose_name='asset')),
                ('created', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, db_index=True, verbose_name='last modified')),
            ],
            options={
                'verbose_name': 'account type',
                'verbose_name_plural': 'account types',
            },
        ),
        migrations.CreateModel(
            name='Contract',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, db_index=True, verbose_name='last modified')),
                ('name', models.CharField(blank=True, db_index=True, default='', max_length=128, verbose_name='name')),
            ],
            options={
                'verbose_name': 'contract',
                'verbose_name_plural': 'contracts',
            },
        ),
        migrations.CreateModel(
            name='EntryType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(db_index=True, max_length=64, unique=True, verbose_name='code')),
                ('identifier', models.CharField(blank=True, db_index=True, default='', max_length=40, verbose_name='identifier')),
                ('name', models.CharField(blank=True, db_index=True, default='', max_length=128, verbose_name='name')),
                ('created', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, db_index=True, verbose_name='last modified')),
                ('payback_priority', models.SmallIntegerField(blank=True, db_index=True, default=0, verbose_name='payback priority')),
                ('is_settlement', models.BooleanField(blank=True, db_index=True, default=False, verbose_name='is settlement')),
                ('is_payment', models.BooleanField(blank=True, db_index=True, default=False, verbose_name='is payment')),
            ],
            options={
                'verbose_name': 'entry type',
                'verbose_name_plural': 'entry types',
            },
        ),
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(blank=True, choices=[('I1', 'Invoice'), ('I2', 'Credit Note')], db_index=True, default='I1', max_length=2, verbose_name='type')),
                ('number', models.CharField(blank=True, db_index=True, default='', max_length=32, verbose_name='invoice number')),
                ('created', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, db_index=True, verbose_name='last modified')),
                ('sent', models.DateTimeField(blank=True, db_index=True, default=None, null=True, verbose_name='sent')),
                ('due_date', models.DateTimeField(db_index=True, default=jacc.models.get_default_due_date, verbose_name='due date')),
                ('notes', models.TextField(blank=True, default='', verbose_name='notes')),
                ('filename', models.CharField(blank=True, db_index=True, default='', max_length=255, verbose_name='filename')),
                ('amount', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=10, verbose_name='amount')),
                ('paid_amount', models.DecimalField(blank=True, db_index=True, decimal_places=2, default=None, editable=False, max_digits=10, null=True, verbose_name='paid amount')),
                ('unpaid_amount', models.DecimalField(blank=True, db_index=True, decimal_places=2, default=None, editable=False, max_digits=10, null=True, verbose_name='unpaid amount')),
                ('overpaid_amount', models.DecimalField(blank=True, db_index=True, decimal_places=2, default=None, editable=False, max_digits=10, null=True, verbose_name='overpaid amount')),
                ('close_date', models.DateTimeField(blank=True, db_index=True, default=None, null=True, verbose_name='close date')),
                ('late_days', models.SmallIntegerField(blank=True, db_index=True, default=None, null=True, verbose_name='late days')),
                ('state', models.CharField(blank=True, choices=[('N', 'Not due yet'), ('D', 'Due'), ('L', 'Late'), ('P', 'Paid')], db_index=True, default='', max_length=1, verbose_name='state')),
            ],
            options={
                'verbose_name': 'invoice',
                'verbose_name_plural': 'invoices',
            },
            bases=(models.Model, jutil.cache.CachedFieldsMixin),
        ),
        migrations.CreateModel(
            name='AccountEntry',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('last_modified', models.DateTimeField(auto_now=True, verbose_name='last modified')),
                ('timestamp', models.DateTimeField(blank=True, db_index=True, default=django.utils.timezone.now, verbose_name='timestamp')),
                ('description', models.CharField(blank=True, default='', max_length=256, verbose_name='description')),
                ('amount', models.DecimalField(blank=True, db_index=True, decimal_places=2, default=None, max_digits=10, null=True, verbose_name='amount')),
                ('archived', models.BooleanField(blank=True, default=False, verbose_name='archived')),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='accountentry_set', to='jacc.Account', verbose_name='record account')),
                ('parent', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='child_set', to='jacc.AccountEntry', verbose_name='account.entry.parent')),
                ('settled_invoice', models.ForeignKey(blank=True, default=None, help_text='For incoming settlements', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='jacc.Invoice', verbose_name='settled invoice')),
                ('settled_item', models.ForeignKey(blank=True, default=None, help_text='For matched settlements', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='settlement_set', to='jacc.AccountEntry', verbose_name='settled item')),
                ('source_file', models.ForeignKey(blank=True, default=None, help_text='Source for account entry, e.g. received payment (if any)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='jacc.AccountEntrySourceFile', verbose_name='account entry source file')),
                ('source_invoice', models.ForeignKey(blank=True, default=None, help_text='For invoice items', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='jacc.Invoice', verbose_name='source invoice')),
                ('type', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='jacc.EntryType', verbose_name='type')),
            ],
            options={
                'verbose_name': 'account entry',
                'verbose_name_plural': 'account entries',
            },
        ),
        migrations.AddField(
            model_name='account',
            name='type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='jacc.AccountType', verbose_name='type'),
        ),
    ]
