
# Generated migration for enhanced customer management features

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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('customers', '0010_marketingreporttemplate_marketingweeklyreport_and_more'),
    ]

    operations = [
        migrations.AddField(
            model_name='customer',
            name='billing_contact_email',
            field=models.EmailField(blank=True, help_text='Billing contact email', max_length=254),
        ),
        migrations.AddField(
            model_name='customer',
            name='billing_contact_name',
            field=models.CharField(blank=True, help_text='Billing contact person', max_length=200),
        ),
        migrations.AddField(
            model_name='customer',
            name='billing_contact_phone',
            field=models.CharField(blank=True, help_text='Billing contact phone', max_length=15),
        ),
        migrations.AddField(
            model_name='customer',
            name='business_registration_number',
            field=models.CharField(blank=True, help_text='Business registration number', max_length=50, null=True),
        ),
        migrations.AddField(
            model_name='customer',
            name='company_address',
            field=models.TextField(blank=True, help_text='Registered company address'),
        ),
        migrations.AddField(
            model_name='customer',
            name='is_sub_account',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='customer',
            name='last_suspension_date',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='customer',
            name='manual_suspension_override',
            field=models.DateTimeField(blank=True, help_text='Manual override for suspension', null=True),
        ),
        migrations.AddField(
            model_name='customer',
            name='parent_customer',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='sub_accounts', to='customers.customer'),
        ),
        migrations.AddField(
            model_name='customer',
            name='service_start_date',
            field=models.DateTimeField(blank=True, help_text='Actual service start after trial', null=True),
        ),
        migrations.AddField(
            model_name='customer',
            name='service_status',
            field=models.CharField(choices=[('active', 'Active'), ('suspended', 'Suspended'), ('disconnected', 'Disconnected'), ('trial', 'Trial Period'), ('pending_activation', 'Pending Activation')], default='pending_activation', max_length=20),
        ),
        migrations.AddField(
            model_name='customer',
            name='sub_account_number',
            field=models.PositiveIntegerField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='customer',
            name='trial_end_date',
            field=models.DateTimeField(blank=True, help_text='Trial period end', null=True),
        ),
        migrations.AddField(
            model_name='customer',
            name='trial_start_date',
            field=models.DateTimeField(blank=True, help_text='Trial period start', null=True),
        ),
        migrations.AddField(
            model_name='customer',
            name='vat_number',
            field=models.CharField(blank=True, help_text='VAT registration number', max_length=20, null=True),
        ),
        migrations.CreateModel(
            name='CustomerActionLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action_type', models.CharField(choices=[('created', 'Customer Created'), ('updated', 'Customer Updated'), ('suspended', 'Service Suspended'), ('disconnected', 'Service Disconnected'), ('reconnected', 'Service Reconnected'), ('trial_started', 'Trial Period Started'), ('trial_ended', 'Trial Period Ended'), ('service_activated', 'Service Activated'), ('payment_received', 'Payment Received'), ('balance_adjusted', 'Balance Adjusted'), ('service_changed', 'Service Package Changed'), ('notes_updated', 'Notes Updated'), ('credentials_reset', 'Credentials Reset'), ('manual_override', 'Manual Override Applied'), ('sub_account_created', 'Sub-Account Created'), ('linked_to_parent', 'Linked to Parent Account'), ('contact_updated', 'Contact Information Updated'), ('installation_completed', 'Installation Completed')], max_length=30)),
                ('description', models.TextField(help_text='Detailed description of the action')),
                ('old_value', models.JSONField(blank=True, help_text='Previous value (for updates)', null=True)),
                ('new_value', models.JSONField(blank=True, help_text='New value (for updates)', null=True)),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True)),
                ('user_agent', models.TextField(blank=True)),
                ('system_action', models.BooleanField(default=False, help_text='True if action was performed by system')),
                ('reference_id', models.CharField(blank=True, help_text='Reference to related object (payment ID, ticket ID, etc.)', max_length=100)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='action_logs', to='customers.customer')),
                ('performed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='customeractionlog',
            index=models.Index(fields=['customer', '-created_at'], name='customers_cu_custome_8c0b2a_idx'),
        ),
        migrations.AddIndex(
            model_name='customeractionlog',
            index=models.Index(fields=['action_type', '-created_at'], name='customers_cu_action__d2c8f3_idx'),
        ),
        migrations.AddIndex(
            model_name='customeractionlog',
            index=models.Index(fields=['performed_by', '-created_at'], name='customers_cu_perform_ac4915_idx'),
        ),
    ]
