<filename>recoup/migrations/0001_initial.py
# Generated by Django 2.0.8 on 2018-08-31 04:20

import datetime
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('registers', '0001_initial'),
        ('organisation', '0005_auto_20180816_1504'),
    ]

    operations = [
        migrations.CreateModel(
            name='Bill',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Product or Service', max_length=320)),
                ('description', models.TextField(default='N/A')),
                ('comment', models.TextField(blank=True, default='')),
                ('quantity', models.CharField(default='1', max_length=320)),
                ('renewal_date', models.DateField(blank=True, null=True)),
                ('cost', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('cost_estimate', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('active', models.BooleanField(default=True)),
            ],
            options={
                'ordering': ('-cost_estimate',),
            },
        ),
        migrations.CreateModel(
            name='Contract',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('vendor', models.CharField(max_length=320)),
                ('brand', models.CharField(default='N/A', max_length=320)),
                ('reference', models.CharField(default='N/A', max_length=320)),
                ('invoice_period', models.CharField(default='Annual', max_length=320)),
                ('start', models.DateField(default=datetime.date.today)),
                ('end', models.DateField(blank=True, null=True)),
                ('active', models.BooleanField(default=True)),
            ],
            options={
                'ordering': ('vendor',),
            },
        ),
        migrations.CreateModel(
            name='Cost',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=320)),
                ('percentage', models.DecimalField(decimal_places=2, default=0, max_digits=5, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)])),
                ('cost', models.DecimalField(decimal_places=2, default=0, editable=False, max_digits=12)),
                ('cost_estimate', models.DecimalField(decimal_places=2, default=0, editable=False, max_digits=12)),
            ],
            options={
                'ordering': ('-percentage',),
            },
        ),
        migrations.CreateModel(
            name='CostCentreLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('user_count', models.PositiveIntegerField(default=0)),
                ('cc', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='organisation.CostCentre')),
            ],
            options={
                'ordering': ('cc__name',),
            },
        ),
        migrations.CreateModel(
            name='Division',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('user_count', models.PositiveIntegerField(default=0)),
                ('position', models.PositiveIntegerField(unique=True)),
                ('org_unit', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='organisation.OrgUnit')),
            ],
            options={
                'ordering': ('position',),
            },
        ),
        migrations.CreateModel(
            name='DivisionITSystem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('cost_centre', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='recoup.CostCentreLink')),
            ],
            options={
                'verbose_name': 'Division IT System',
                'ordering': ('cost_centre__cc__name', 'it_system__name'),
            },
        ),
        migrations.CreateModel(
            name='EndUserService',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=320)),
                ('divisions', models.ManyToManyField(to='recoup.Division')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='FinancialYear',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start', models.DateField()),
                ('end', models.DateField()),
            ],
            options={
                'ordering': ('end',),
            },
        ),
        migrations.CreateModel(
            name='ITPlatform',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=320)),
            ],
            options={
                'verbose_name': 'IT platform',
            },
        ),
        migrations.CreateModel(
            name='ServicePool',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(editable=False, max_length=320, unique=True)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='SystemDependency',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('weighting', models.FloatField(default=1)),
                ('platform', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.ITPlatform')),
                ('system', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.DivisionITSystem')),
            ],
        ),
        migrations.CreateModel(
            name='EndUserCost',
            fields=[
                ('cost_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='recoup.Cost')),
                ('service', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.EndUserService')),
            ],
            options={
                'abstract': False,
            },
            bases=('recoup.cost',),
        ),
        migrations.CreateModel(
            name='ITPlatformCost',
            fields=[
                ('cost_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='recoup.Cost')),
                ('platform', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.ITPlatform')),
            ],
            options={
                'abstract': False,
            },
            bases=('recoup.cost',),
        ),
        migrations.AddField(
            model_name='divisionitsystem',
            name='depends_on',
            field=models.ManyToManyField(through='recoup.SystemDependency', to='recoup.ITPlatform'),
        ),
        migrations.AddField(
            model_name='divisionitsystem',
            name='division',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.Division'),
        ),
        migrations.AddField(
            model_name='divisionitsystem',
            name='it_system',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='registers.ITSystem'),
        ),
        migrations.AddField(
            model_name='costcentrelink',
            name='division',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.Division'),
        ),
        migrations.AddField(
            model_name='cost',
            name='bill',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cost_items', to='recoup.Bill'),
        ),
        migrations.AddField(
            model_name='cost',
            name='service_pool',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.ServicePool'),
        ),
        migrations.AddField(
            model_name='bill',
            name='contract',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.Contract'),
        ),
        migrations.AddField(
            model_name='bill',
            name='year',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='recoup.FinancialYear'),
        ),
        migrations.AlterUniqueTogether(
            name='systemdependency',
            unique_together={('system', 'platform')},
        ),
    ]
