# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-08 19:46
from __future__ import unicode_literals

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

def load_sql():
    from CdsTestProj.settings import BASE_DIR, DBTYPE
    import os

    f = open(os.path.join(BASE_DIR, 'accounts/sql/{}/__init__.sql'.format(DBTYPE)), 'r')
    sql_statements = f.read()
    f.close()
    return sql_statements


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Account',
            fields=[
                ('id', models.IntegerField(editable=False, primary_key=True, serialize=False, verbose_name='Account no.')),
                ('currency', models.CharField(choices=[('USD', 'US Dollars'), ('EUR', 'Euro'), ('GBP', 'British Pounds'), ('CHF', 'Swiss Francs')], max_length=3, verbose_name='Currency code')),
                ('balance', accounts.models.CurrencyAmountField(decimal_places=2, default=0, editable=False, max_digits=18, verbose_name='Current balance')),
            ],
        ),
        migrations.CreateModel(
            name='Transaction',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('src_amount', accounts.models.CurrencyAmountField(decimal_places=2, default=0, max_digits=18, validators=[django.core.validators.MinValueValidator(0, 'Amount cannot be negative')], verbose_name="Amount (in source account's currency)")),
                ('dst_amount', accounts.models.CurrencyAmountField(decimal_places=2, default=0, max_digits=18, validators=[django.core.validators.MinValueValidator(0, 'Amount cannot be negative')], verbose_name="Amount (in destination account's currency)")),
                ('create_timestamp', models.DateTimeField(auto_now_add=True, verbose_name='Created at')),
                ('dst_account', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.PROTECT, related_name='dst_account', to='accounts.Account', verbose_name='Destination account')),
                ('src_account', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.PROTECT, related_name='src_account', to='accounts.Account', verbose_name='Source account')),
            ],
        ),
        migrations.RunSQL(load_sql()),
    ]
