# Generated by Django 5.2.19 on 2026-11-29 02:41

import django.db.models.deletion
import uuid
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('accounting', '0003_remove_voucher_uniq_company_voucher_no_and_more'),
        ('tenancy', '0002_company_multi_currency_enabled'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='FxRevaluationRun',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('revaluation_date', models.DateField()),
                ('currency_code', models.CharField(max_length=3)),
                ('closing_rate', models.DecimalField(decimal_places=6, max_digits=14)),
                ('unrealized_gain_loss', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='fx_revaluations', to='tenancy.company')),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
                ('voucher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='accounting.voucher')),
            ],
            options={
                'ordering': ['-revaluation_date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Currency',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('code', models.CharField(max_length=3)),
                ('name', models.CharField(max_length=64)),
                ('symbol', models.CharField(default='', max_length=8)),
                ('decimal_places', models.PositiveSmallIntegerField(default=2)),
                ('is_active', models.BooleanField(default=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='currencies', to='tenancy.company')),
            ],
            options={
                'verbose_name_plural': 'Currencies',
                'ordering': ['code'],
                'unique_together': {('company', 'code')},
            },
        ),
        migrations.CreateModel(
            name='ExchangeRate',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('from_currency', models.CharField(max_length=3)),
                ('to_currency', models.CharField(default='NPR', max_length=3)),
                ('effective_date', models.DateField(db_index=True)),
                ('rate_source', models.CharField(choices=[('NRB_REF', 'NRB Reference Rate'), ('BANK_ACTUAL', 'Bank Actual Deal Rate'), ('MANUAL', 'Manual Treasury Rate')], default='NRB_REF', max_length=16)),
                ('bank_name', models.CharField(blank=True, max_length=120)),
                ('buy_rate', models.DecimalField(decimal_places=6, max_digits=14)),
                ('sell_rate', models.DecimalField(decimal_places=6, max_digits=14)),
                ('mid_rate', models.DecimalField(decimal_places=6, max_digits=14)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exchange_rates', to='tenancy.company')),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-effective_date', 'from_currency'],
                'unique_together': {('company', 'from_currency', 'to_currency', 'effective_date', 'rate_source', 'bank_name')},
            },
        ),
    ]
