# Generated by Django 5.0.2 on 2025-07-24 13:22

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='NotificationTemplate',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('template_type', models.CharField(choices=[('sms_payment_received', 'SMS - Payment Received'), ('sms_payment_pending', 'SMS - Payment Pending'), ('sms_invoice_created', 'SMS - Invoice Created'), ('email_payment_received', 'Email - Payment Received'), ('email_payment_pending', 'Email - Payment Pending'), ('email_invoice_created', 'Email - Invoice Created'), ('sms_custom', 'SMS - Custom'), ('email_custom', 'Email - Custom')], max_length=50, unique=True)),
                ('subject', models.CharField(blank=True, help_text='For email templates only', max_length=200)),
                ('content', models.TextField(help_text='Use {{variable}} for dynamic content')),
                ('variables_help', models.TextField(blank=True, help_text='Available variables for this template')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
            options={
                'ordering': ['template_type', 'name'],
            },
        ),
        migrations.CreateModel(
            name='EmailLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('recipient_email', models.EmailField(max_length=254)),
                ('recipient_name', models.CharField(blank=True, max_length=200)),
                ('subject', models.CharField(max_length=500)),
                ('message', models.TextField()),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('sent', 'Sent'), ('failed', 'Failed'), ('delivered', 'Delivered')], default='pending', max_length=20)),
                ('sent_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('delivered_at', models.DateTimeField(blank=True, null=True)),
                ('error_message', models.TextField(blank=True, null=True)),
                ('customer_id', models.PositiveIntegerField(blank=True, null=True)),
                ('payment_id', models.CharField(blank=True, max_length=50, null=True)),
                ('invoice_id', models.PositiveIntegerField(blank=True, null=True)),
                ('sent_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sent_notification_emails', to=settings.AUTH_USER_MODEL)),
                ('template_used', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='notifications.notificationtemplate')),
            ],
            options={
                'verbose_name': 'Email Log',
                'verbose_name_plural': 'Email Logs',
                'ordering': ['-sent_at'],
            },
        ),
        migrations.CreateModel(
            name='SMSLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('recipient_phone', models.CharField(max_length=15)),
                ('recipient_name', models.CharField(blank=True, max_length=200)),
                ('message', models.TextField()),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('sent', 'Sent'), ('failed', 'Failed'), ('delivered', 'Delivered')], default='pending', max_length=20)),
                ('sent_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('delivered_at', models.DateTimeField(blank=True, null=True)),
                ('error_message', models.TextField(blank=True, null=True)),
                ('customer_id', models.PositiveIntegerField(blank=True, null=True)),
                ('payment_id', models.CharField(blank=True, max_length=50, null=True)),
                ('invoice_id', models.PositiveIntegerField(blank=True, null=True)),
                ('sent_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sent_sms_logs', to=settings.AUTH_USER_MODEL)),
                ('template_used', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='notifications.notificationtemplate')),
            ],
            options={
                'verbose_name': 'SMS Log',
                'verbose_name_plural': 'SMS Logs',
                'ordering': ['-sent_at'],
            },
        ),
    ]
