# Generated by Django 3.2.5 on 2023-03-02 07:04

from django.db import migrations, models
from financemodule.enum import ExchangeRateCurrency , ExchangeMidrate 



def create_exchangerates(apps, schema_editor):
    exchange_rate = apps.get_model("financemodule.Exchangerate")
    db_alias = schema_editor.connection.alias
    exchange_rate.objects.using(db_alias).bulk_create([
    exchange_rate(rate_currency = ExchangeRateCurrency.SGD.value, rate_mid = ExchangeMidrate.SGD_RATE.value),
    exchange_rate(rate_currency = ExchangeRateCurrency.HKD.value,  rate_mid = ExchangeMidrate.HKD_RATE.value),
    exchange_rate(rate_currency = ExchangeRateCurrency.CNY.value,  rate_mid = ExchangeMidrate.CNY_RATE.value),
    exchange_rate(rate_currency = ExchangeRateCurrency.AED.value,  rate_mid = ExchangeMidrate.AED_RATE.value),
    exchange_rate(rate_currency = ExchangeRateCurrency.EUR.value,  rate_mid = ExchangeMidrate.EUR_RATE.value),
    exchange_rate(rate_currency = ExchangeRateCurrency.USD.value,  rate_mid = ExchangeMidrate.USD_RATE.value)])



class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Exchangerate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('bank_entity', models.IntegerField(blank=True, null=True)),
                ('rate_base_currency', models.CharField(blank=True, max_length=255, null=True)),
                ('rate_currency', models.CharField(blank=True, max_length=255, null=True)),
                ('rate_date', models.DateField(blank=True, null=True)),
                ('rate_previous_day', models.DateField(blank=True, null=True)),
                ('rate_buy', models.FloatField(blank=True, null=True)),
                ('rate_sell', models.FloatField(blank=True, null=True)),
                ('rate_mid', models.FloatField(blank=True, null=True)),
                ('created_date', models.DateTimeField(auto_now_add=True)),
            ],
        ),
        migrations.RunPython(create_exchangerates),
        migrations.CreateModel(
            name='Finance',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('finance_id', models.CharField(blank=True, max_length=255, null=True)),
                ('finance_date', models.DateField(blank=True, null=True)),
                ('finance_request_id', models.IntegerField(blank=True, null=True)),
                ('program_type', models.CharField(blank=True, max_length=255, null=True)),
                ('anchor_party', models.IntegerField(blank=True, null=True)),
                ('counterparty', models.IntegerField(blank=True, null=True)),
                ('due_date', models.DateField(blank=True, null=True)),
                ('invoice_currency', models.CharField(max_length=255)),
                ('invoice_amount', models.IntegerField(blank=True, null=True)),
                ('finance_currency', models.CharField(max_length=255)),
                ('finance_amount', models.IntegerField(blank=True, null=True)),
                ('settlement_currency', models.CharField(blank=True, max_length=255, null=True)),
                ('settlement_amount', models.IntegerField(blank=True, null=True)),
                ('repayment_acc_currency', models.CharField(max_length=255)),
                ('repayment_account', models.CharField(max_length=255)),
                ('interest_type', models.CharField(max_length=255)),
                ('interest_rate_type', models.CharField(max_length=255)),
                ('margin', models.FloatField(blank=True, null=True)),
                ('interest_rate', models.FloatField(blank=True, null=True)),
                ('interest_amount', models.IntegerField(blank=True, null=True)),
                ('interest_paid_by', models.CharField(max_length=255)),
                ('own_party_account_info', models.JSONField(blank=True, null=True)),
                ('remittance_info', models.JSONField(blank=True, null=True)),
                ('status', models.CharField(blank=True, max_length=255, null=True)),
                ('created_date', models.DateTimeField(auto_now_add=True)),
            ],
        ),
        migrations.CreateModel(
            name='FinanceAccounting',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('contract_ref', models.CharField(blank=True, max_length=155, null=True)),
                ('stage', models.CharField(blank=True, max_length=155, null=True)),
                ('type', models.CharField(blank=True, max_length=155, null=True)),
                ('currency', models.CharField(blank=True, max_length=155, null=True)),
                ('amount', models.IntegerField(blank=True, null=True)),
                ('account', models.CharField(blank=True, max_length=255, null=True)),
                ('account_type', models.CharField(blank=True, max_length=155, null=True)),
                ('base_currency', models.CharField(blank=True, max_length=155, null=True)),
                ('base_currency_amount', models.IntegerField(blank=True, null=True)),
                ('exch_rate', models.FloatField(blank=True, null=True)),
                ('created_date', models.DateTimeField(auto_now_add=True)),
            ],
        ),
    ]
