"""
Migration: Add SasaPay models
- SasaPayIPNLog
- SasaPaySTKResult
- SasaPayDisbursementResult
- SasaPayUnknownPayment
"""

from django.db import migrations, models
import uuid


class Migration(migrations.Migration):

    dependencies = [
        ('payments', '0002_unconfirmedpayment'),
    ]

    operations = [
        migrations.CreateModel(
            name='SasaPayIPNLog',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('raw_data', models.JSONField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'sasapay_ipn_logs',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SasaPaySTKResult',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('checkout_request_id', models.CharField(blank=True, max_length=100)),
                ('merchant_loan_ref', models.CharField(blank=True, max_length=100)),
                ('result_code', models.CharField(max_length=20)),
                ('result_desc', models.TextField(blank=True)),
                ('trans_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'sasapay_stk_results',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SasaPayDisbursementResult',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('loan_reference', models.CharField(blank=True, max_length=100)),
                ('sasapay_transaction_id', models.CharField(blank=True, max_length=100)),
                ('mpesa_reference', models.CharField(blank=True, max_length=100)),
                ('result_code', models.CharField(max_length=20)),
                ('result_desc', models.TextField(blank=True)),
                ('trans_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('merchant_balance', models.DecimalField(decimal_places=2, default=0, max_digits=14)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'sasapay_disbursement_results',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SasaPayUnknownPayment',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=12)),
                ('paid_by', models.CharField(blank=True, max_length=200)),
                ('msisdn', models.CharField(blank=True, max_length=20)),
                ('bill_ref', models.CharField(blank=True, max_length=100)),
                ('reference', models.CharField(blank=True, max_length=100)),
                ('notes', models.TextField(blank=True, default='Unrecognised payment')),
                ('resolved', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'sasapay_unknown_payments',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SMSLog',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('sms_type', models.CharField(max_length=30, default='other')),
                ('recipients', models.TextField()),
                ('message', models.TextField()),
                ('sender_id', models.CharField(max_length=20, default='HavGrazuri')),
                ('status', models.CharField(max_length=20, default='sent')),
                ('at_response', models.JSONField(blank=True, null=True)),
                ('error_message', models.TextField(blank=True)),
                ('loan_number', models.CharField(max_length=30, blank=True)),
                ('borrower_name', models.CharField(max_length=200, blank=True)),
                ('amount', models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'sms_logs',
                'ordering': ['-created_at'],
            },
        ),
    ]
