# Generated by Django 5.2.7 on 2025-11-05 07:21

import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('loans', '0020_alter_mpesatransaction_status'),
        ('payments', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='UnconfirmedPayment',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('payment_phone', models.CharField(blank=True, help_text='Phone number from payment', max_length=17, null=True)),
                ('payment_id_number', models.CharField(blank=True, help_text='ID number from payment', max_length=50, null=True)),
                ('match_type', models.CharField(choices=[('id_only', "ID Number Matches (Phone Doesn't)"), ('phone_only', "Phone Matches (ID Doesn't)"), ('none', 'No Match Found')], default='none', max_length=20)),
                ('status', models.CharField(choices=[('pending', 'Pending Approval'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('processed', 'Processed')], default='pending', max_length=20)),
                ('approved_at', models.DateTimeField(blank=True, null=True)),
                ('rejection_reason', models.TextField(blank=True, null=True)),
                ('admin_notes', models.TextField(blank=True, null=True)),
                ('notes', models.TextField(blank=True, help_text='System notes about the mismatch', null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='approved_unconfirmed_payments', to=settings.AUTH_USER_MODEL)),
                ('mpesa_transaction', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='unconfirmed_payment', to='loans.mpesatransaction')),
                ('suggested_borrower', models.ForeignKey(blank=True, help_text='Borrower suggested by system', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='unconfirmed_payments', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Unconfirmed Payment',
                'verbose_name_plural': 'Unconfirmed Payments',
                'db_table': 'unconfirmed_payments',
                'ordering': ['-created_at'],
            },
        ),
    ]
