# Generated by Django 5.2.4 on 2025-07-20 04:14

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('loans', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='DocumentTemplate',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=200)),
                ('template_type', models.CharField(choices=[('offer_letter', 'Offer Letter'), ('receipt', 'Receipt'), ('statement', 'Loan Statement'), ('agreement', 'Loan Agreement'), ('welcome_letter', 'Welcome Letter')], max_length=30)),
                ('description', models.TextField(blank=True, null=True)),
                ('html_template', models.TextField()),
                ('css_styles', models.TextField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('is_default', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'document_templates',
                'ordering': ['template_type', 'name'],
            },
        ),
        migrations.CreateModel(
            name='EmailTemplate',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=200)),
                ('template_type', models.CharField(choices=[('welcome', 'Welcome Email'), ('loan_approved', 'Loan Approved'), ('loan_rejected', 'Loan Rejected'), ('payment_reminder', 'Payment Reminder'), ('overdue_alert', 'Overdue Alert'), ('offer_letter', 'Offer Letter'), ('password_reset', 'Password Reset')], max_length=30)),
                ('subject', models.CharField(max_length=200)),
                ('html_content', models.TextField()),
                ('text_content', models.TextField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('is_default', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'email_templates',
                'ordering': ['template_type', 'name'],
            },
        ),
        migrations.CreateModel(
            name='SMSTemplate',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=200)),
                ('template_type', models.CharField(choices=[('welcome', 'Welcome SMS'), ('loan_approved', 'Loan Approved'), ('loan_rejected', 'Loan Rejected'), ('payment_reminder', 'Payment Reminder'), ('overdue_alert', 'Overdue Alert'), ('otp', 'OTP Verification')], max_length=30)),
                ('message_template', models.TextField()),
                ('is_active', models.BooleanField(default=True)),
                ('is_default', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'sms_templates',
                'ordering': ['template_type', 'name'],
            },
        ),
        migrations.CreateModel(
            name='LoanStatement',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('statement_number', models.CharField(max_length=20, unique=True)),
                ('statement_date', models.DateTimeField(auto_now_add=True)),
                ('period_from', models.DateTimeField()),
                ('period_to', models.DateTimeField()),
                ('principal_amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('interest_amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('total_amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('amount_paid', models.DecimalField(decimal_places=2, max_digits=12)),
                ('outstanding_balance', models.DecimalField(decimal_places=2, max_digits=12)),
                ('pdf_file', models.FileField(blank=True, null=True, upload_to='loan_statements/')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('borrower', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('loan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='loans.Loan')),
            ],
            options={
                'db_table': 'loan_statements',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='OfferLetter',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('offer_number', models.CharField(max_length=20, unique=True)),
                ('loan_amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('interest_rate', models.DecimalField(decimal_places=2, max_digits=5)),
                ('duration_days', models.PositiveIntegerField()),
                ('processing_fee', models.DecimalField(decimal_places=2, max_digits=12)),
                ('total_amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('terms_conditions', models.TextField()),
                ('special_conditions', models.TextField(blank=True, null=True)),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('sent', 'Sent'), ('signed', 'Signed'), ('expired', 'Expired'), ('cancelled', 'Cancelled')], default='draft', max_length=20)),
                ('valid_until', models.DateTimeField()),
                ('pdf_file', models.FileField(blank=True, null=True, upload_to='offer_letters/')),
                ('borrower_signature', models.TextField(blank=True, null=True)),
                ('signed_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('sent_at', models.DateTimeField(blank=True, null=True)),
                ('application', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='loans.loanapplication')),
                ('borrower', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'offer_letters',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Receipt',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('receipt_number', models.CharField(max_length=20, unique=True)),
                ('amount_paid', models.DecimalField(decimal_places=2, max_digits=12)),
                ('payment_method', models.CharField(max_length=20)),
                ('payment_date', models.DateTimeField()),
                ('previous_balance', models.DecimalField(decimal_places=2, max_digits=12)),
                ('new_balance', models.DecimalField(decimal_places=2, max_digits=12)),
                ('pdf_file', models.FileField(blank=True, null=True, upload_to='receipts/')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('borrower', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('loan', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='loans.Loan')),
                ('repayment', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='loans.repayment')),
            ],
            options={
                'db_table': 'receipts',
                'ordering': ['-created_at'],
            },
        ),
    ]
