# Generated by Django 5.2.4 on 2025-09-25 05:12

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


class Migration(migrations.Migration):

    dependencies = [
        ('loans', '0015_alter_loanproduct_late_payment_penalty_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='mpesatransaction',
            name='bill_ref_number',
            field=models.CharField(blank=True, help_text='Account number used', max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='borrower',
            field=models.ForeignKey(blank=True, help_text='Matched borrower', null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='business_short_code',
            field=models.CharField(blank=True, max_length=10, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='first_name',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='invoice_number',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='last_name',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='middle_name',
            field=models.CharField(blank=True, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='msisdn',
            field=models.CharField(blank=True, help_text='Customer phone number (masked)', max_length=20, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='org_account_balance',
            field=models.DecimalField(blank=True, decimal_places=2, max_digits=15, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='processed_at',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='processed_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='processed_mpesa_transactions', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='processing_notes',
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='raw_confirmation_data',
            field=models.JSONField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='raw_validation_data',
            field=models.JSONField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='third_party_trans_id',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='trans_id',
            field=models.CharField(blank=True, help_text='M-Pesa C2B transaction ID', max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='mpesatransaction',
            name='trans_time',
            field=models.CharField(blank=True, help_text='Transaction timestamp from M-Pesa', max_length=20, null=True),
        ),
        migrations.AlterField(
            model_name='mpesatransaction',
            name='loan',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mpesa_transactions', to='loans.Loan'),
        ),
        migrations.AlterField(
            model_name='mpesatransaction',
            name='mpesa_transaction_id',
            field=models.CharField(blank=True, help_text='M-Pesa transaction ID', max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='mpesatransaction',
            name='repayment',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mpesa_transactions', to='loans.repayment'),
        ),
        migrations.AlterField(
            model_name='mpesatransaction',
            name='status',
            field=models.CharField(choices=[('pending', 'Pending'), ('validated', 'Validated'), ('confirmed', 'Confirmed'), ('success', 'Success'), ('processed', 'Processed'), ('failed', 'Failed'), ('cancelled', 'Cancelled'), ('rejected', 'Rejected')], default='pending', max_length=20),
        ),
        migrations.AlterField(
            model_name='mpesatransaction',
            name='transaction_type',
            field=models.CharField(choices=[('c2b', 'Customer to Business'), ('b2c', 'Business to Customer'), ('stk_push', 'STK Push'), ('Pay Bill', 'Pay Bill'), ('Buy Goods', 'Buy Goods')], max_length=20),
        ),
        migrations.AddIndex(
            model_name='mpesatransaction',
            index=models.Index(fields=['trans_id'], name='mpesa_trans_trans_i_b174a3_idx'),
        ),
        migrations.AddIndex(
            model_name='mpesatransaction',
            index=models.Index(fields=['mpesa_transaction_id'], name='mpesa_trans_mpesa_t_246d97_idx'),
        ),
        migrations.AddIndex(
            model_name='mpesatransaction',
            index=models.Index(fields=['phone_number'], name='mpesa_trans_phone_n_93d554_idx'),
        ),
        migrations.AddIndex(
            model_name='mpesatransaction',
            index=models.Index(fields=['msisdn'], name='mpesa_trans_msisdn_2a76c6_idx'),
        ),
        migrations.AddIndex(
            model_name='mpesatransaction',
            index=models.Index(fields=['bill_ref_number'], name='mpesa_trans_bill_re_7a9bf7_idx'),
        ),
        migrations.AddIndex(
            model_name='mpesatransaction',
            index=models.Index(fields=['status'], name='mpesa_trans_status_797175_idx'),
        ),
        migrations.AddIndex(
            model_name='mpesatransaction',
            index=models.Index(fields=['borrower'], name='mpesa_trans_borrowe_013732_idx'),
        ),
    ]
