# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-07 07:19
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.db.models.manager
import polymorphic.showfields


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('securities', '0001_initial'),
        ('contenttypes', '0002_remove_content_type_name'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='HoldingDetail',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('day', models.DateField()),
                ('qty', models.DecimalField(decimal_places=6, max_digits=16)),
                ('price', models.DecimalField(decimal_places=6, max_digits=16)),
                ('exch', models.DecimalField(decimal_places=6, max_digits=16)),
                ('cad', models.DecimalField(decimal_places=6, max_digits=16)),
                ('value', models.DecimalField(decimal_places=6, max_digits=16)),
                ('type', models.CharField(max_length=100)),
            ],
            options={
                'db_table': 'financeview_holdingdetail',
                'ordering': ['day', 'security'],
                'get_latest_by': 'day',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Activity',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('tradeDate', models.DateField()),
                ('description', models.CharField(max_length=1000)),
                ('qty', models.DecimalField(decimal_places=6, max_digits=16)),
                ('price', models.DecimalField(decimal_places=6, max_digits=16)),
                ('netAmount', models.DecimalField(decimal_places=2, max_digits=16)),
                ('commission', models.DecimalField(decimal_places=2, default=0, max_digits=16)),
                ('type', models.CharField(choices=[('Deposit', 'Deposit'), ('Dividend', 'Dividend'), ('FX', 'FX'), ('Fee', 'Fee'), ('Interest', 'Interest'), ('Buy', 'Buy'), ('Sell', 'Sell'), ('Tax', 'Tax'), ('Transfer', 'Transfer'), ('Withdrawal', 'Withdrawal'), ('Expiry', 'Expiry'), ('Journal', 'Journal'), ('NotImplemented', 'NotImplemented')], max_length=100)),
            ],
            options={
                'verbose_name_plural': 'Activities',
                'ordering': ['tradeDate'],
                'get_latest_by': 'tradeDate',
            },
        ),
        migrations.CreateModel(
            name='Allocation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('desired_pct', models.DecimalField(decimal_places=4, max_digits=6)),
                ('securities', models.ManyToManyField(to='securities.Security')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='allocations', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='BaseAccount',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(max_length=100)),
                ('account_id', models.CharField(max_length=100)),
                ('taxable', models.BooleanField(default=True)),
                ('display_name', models.CharField(default='', editable=False, max_length=100)),
                ('creation_date', models.DateField(default='2009-01-01')),
            ],
            options={
                'ordering': ['account_id'],
            },
            bases=(polymorphic.showfields.ShowFieldTypeAndContent, models.Model),
        ),
        migrations.CreateModel(
            name='BaseClient',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('display_name', models.CharField(max_length=100, null=True)),
                ('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_finance.baseclient_set+', to='contenttypes.ContentType')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='clients', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
            bases=(polymorphic.showfields.ShowFieldTypeAndContent, models.Model),
        ),
        migrations.CreateModel(
            name='BaseRawActivity',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ],
            options={
                'abstract': False,
            },
            bases=(polymorphic.showfields.ShowFieldTypeAndContent, models.Model),
        ),
        migrations.CreateModel(
            name='Holding',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qty', models.DecimalField(decimal_places=6, max_digits=16)),
                ('startdate', models.DateField()),
                ('enddate', models.DateField(null=True)),
                ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='finance.BaseAccount')),
                ('security', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='holdings', to='securities.Security')),
            ],
            options={
                'get_latest_by': 'startdate',
            },
        ),
        migrations.CreateModel(
            name='UserProfile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('plotly_url', models.CharField(blank=True, max_length=500, null=True)),
                ('plotly_url2', models.CharField(blank=True, max_length=500, null=True)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='ManualRawActivity',
            fields=[
                ('baserawactivity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='finance.BaseRawActivity')),
                ('day', models.DateField()),
                ('symbol', models.CharField(blank=True, default='', max_length=100)),
                ('description', models.CharField(blank=True, default='', max_length=1000)),
                ('currency', models.CharField(max_length=100)),
                ('qty', models.DecimalField(decimal_places=6, default=0, max_digits=16)),
                ('price', models.DecimalField(decimal_places=6, default=0, max_digits=16)),
                ('netAmount', models.DecimalField(decimal_places=2, max_digits=16)),
                ('type', models.CharField(max_length=100)),
            ],
            options={
                'verbose_name_plural': 'Base Raw Activities',
            },
            bases=('finance.baserawactivity',),
            managers=[
                ('objects', django.db.models.manager.Manager()),
                ('base_objects', django.db.models.manager.Manager()),
            ],
        ),
        migrations.AddField(
            model_name='baserawactivity',
            name='account',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rawactivities', to='finance.BaseAccount'),
        ),
        migrations.AddField(
            model_name='baserawactivity',
            name='polymorphic_ctype',
            field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_finance.baserawactivity_set+', to='contenttypes.ContentType'),
        ),
        migrations.AddField(
            model_name='baseaccount',
            name='client',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='accounts', to='finance.BaseClient'),
        ),
        migrations.AddField(
            model_name='baseaccount',
            name='polymorphic_ctype',
            field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_finance.baseaccount_set+', to='contenttypes.ContentType'),
        ),
        migrations.AddField(
            model_name='activity',
            name='account',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='finance.BaseAccount'),
        ),
        migrations.AddField(
            model_name='activity',
            name='cash',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dontaccess_cash', to='securities.Security'),
        ),
        migrations.AddField(
            model_name='activity',
            name='raw',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='finance.BaseRawActivity'),
        ),
        migrations.AddField(
            model_name='activity',
            name='security',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='securities.Security'),
        ),
        migrations.AddIndex(
            model_name='holding',
            index=models.Index(fields=['security_id', 'enddate'], name='finance_hol_securit_935293_idx'),
        ),
        migrations.AddIndex(
            model_name='holding',
            index=models.Index(fields=['enddate'], name='finance_hol_enddate_23f547_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='holding',
            unique_together=set([('account', 'security', 'startdate')]),
        ),
        migrations.AlterUniqueTogether(
            name='activity',
            unique_together=set([('raw', 'type')]),
        ),
    ]
