# Generated by Django 5.2.19 on 2026-12-02 03:02

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


class Migration(migrations.Migration):

    dependencies = [
        ('accounting', '0010_voucherregisterviewconfig_and_more'),
        ('currency', '0002_currency_unit_exchangerate_approved_by_and_more'),
        ('tenancy', '0003_taxconfig_calculation_rule_taxconfig_category_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='FxSettlement',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('settlement_date', models.DateField(db_index=True)),
                ('currency_code', models.CharField(max_length=3)),
                ('foreign_amount', models.DecimalField(decimal_places=2, max_digits=18)),
                ('booking_rate', models.DecimalField(decimal_places=6, max_digits=14)),
                ('settlement_rate', models.DecimalField(decimal_places=6, max_digits=14)),
                ('realized_gain_loss', models.DecimalField(decimal_places=2, max_digits=18)),
                ('source_reference', models.CharField(blank=True, max_length=120)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='fx_settlements', 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': ['-settlement_date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='CurrencyPolicy',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('context', models.CharField(choices=[('BANK_TXN', 'Bank Transactions'), ('AR_COLLECTION', 'Customer Collections'), ('AP_PAYMENT', 'Supplier Payments'), ('LOAN_VALUATION', 'Foreign Loan Valuation'), ('PERIOD_REVALUATION', 'Period-End Revaluation'), ('REPORTING', 'Financial Reporting')], max_length=24)),
                ('preferred_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)),
                ('rate_side', models.CharField(default='MID', max_length=8)),
                ('allow_manual_override', models.BooleanField(default=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='currency_policies', to='tenancy.company')),
            ],
            options={
                'ordering': ['context'],
                'unique_together': {('company', 'context')},
            },
        ),
    ]
