# Generated by Django 4.2.21 on 2025-06-26 20:39

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


class Migration(migrations.Migration):

    dependencies = [
        ('referrals', '0002_alter_referralreward_payment_gateway_and_more'),
        ('customers', '0014_alter_customer_options'),
        ('users', '0015_alter_crmuser_options'),
        ('ib_commission', '0003_clientibmapping_idx_client_mapping_lookup_and_more'),
    ]

    operations = [
        migrations.CreateModel(
            name='IBOnboardingStatus',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.CharField(blank=True, max_length=255, null=True)),
                ('updated_by', models.CharField(blank=True, max_length=255, null=True)),
                ('ib_account_created', models.BooleanField(default=False, help_text='IB account has been created in MT5')),
                ('hierarchy_created', models.BooleanField(default=False, help_text='IB has been positioned in hierarchy (standalone or under parent)')),
                ('agreement_assigned', models.BooleanField(default=False, help_text='IB has been assigned to at least one commission agreement')),
                ('referral_source_created', models.BooleanField(default=False, help_text='IB referral code has been created for client onboarding')),
                ('completed_at', models.DateTimeField(blank=True, help_text='Timestamp when all onboarding steps were completed', null=True)),
                ('notes', models.TextField(blank=True, help_text="Any notes or special instructions for this IB's onboarding")),
                ('agreement', models.ForeignKey(blank=True, help_text='Primary agreement assigned to the IB', null=True, on_delete=django.db.models.deletion.SET_NULL, to='ib_commission.ibagreement')),
                ('completed_by', models.ForeignKey(blank=True, help_text='CRM user who completed the onboarding', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='completed_ib_onboardings', to='users.crmuser')),
                ('customer', models.OneToOneField(help_text='The IB customer being onboarded', on_delete=django.db.models.deletion.CASCADE, related_name='ib_onboarding_status', to='customers.customer')),
                ('hierarchy', models.ForeignKey(blank=True, help_text='Reference to the created hierarchy entry', null=True, on_delete=django.db.models.deletion.SET_NULL, to='ib_commission.ibhierarchy')),
                ('referral_source', models.ForeignKey(blank=True, help_text='Primary referral source created for the IB', null=True, on_delete=django.db.models.deletion.SET_NULL, to='referrals.referralsource')),
            ],
            options={
                'verbose_name': 'IB Onboarding Status',
                'verbose_name_plural': 'IB Onboarding Statuses',
                'db_table': 'ib_onboarding_status',
                'indexes': [models.Index(fields=['customer'], name='ib_onboardi_custome_365a37_idx'), models.Index(fields=['completed_at'], name='ib_onboardi_complet_70bfe3_idx'), models.Index(fields=['ib_account_created', 'hierarchy_created', 'agreement_assigned', 'referral_source_created'], name='ib_onboardi_ib_acco_8e5756_idx')],
            },
        ),
    ]
