# Generated by Django 5.2.11 on 2026-04-27 15:40

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('expat_life', '0030_platformfeesettings_affiliate_commission_percentage'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='AffiliateMarketingResource',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('resource_type', models.CharField(choices=[('pdf', 'PDF'), ('video', 'Video'), ('business_card', 'Business Card Design'), ('image', 'Image'), ('other', 'Other')], max_length=30)),
                ('language', models.CharField(choices=[('en', 'English'), ('si', 'Sinhala'), ('ta', 'Tamil'), ('ru', 'Russian'), ('de', 'German'), ('fr', 'French'), ('ar', 'Arabic'), ('zh', 'Chinese'), ('other', 'Other')], default='en', max_length=20)),
                ('file', models.FileField(blank=True, null=True, upload_to='affiliate_resources/')),
                ('external_url', models.URLField(blank=True)),
                ('is_active', models.BooleanField(default=True)),
                ('order', models.PositiveIntegerField(default=0)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'verbose_name': 'Affiliate Marketing Resource',
                'verbose_name_plural': 'Affiliate Marketing Resources',
                'ordering': ['order', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='AffiliateProfile',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('affiliate_code', models.CharField(blank=True, help_text='Unique affiliate tracking code.', max_length=30, unique=True)),
                ('full_name', models.CharField(max_length=150)),
                ('phone', models.CharField(blank=True, max_length=30)),
                ('whatsapp', models.CharField(blank=True, max_length=30)),
                ('country', models.CharField(blank=True, max_length=100)),
                ('status', models.CharField(choices=[('pending', 'Pending Approval'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('inactive', 'Inactive')], default='pending', max_length=20)),
                ('is_active', models.BooleanField(default=True)),
                ('bank_name', models.CharField(blank=True, max_length=150)),
                ('bank_account_name', models.CharField(blank=True, max_length=150)),
                ('bank_account_number', models.CharField(blank=True, max_length=100)),
                ('bank_branch', models.CharField(blank=True, max_length=150)),
                ('payout_notes', models.TextField(blank=True)),
                ('total_earned_usd', models.DecimalField(decimal_places=2, default=0, max_digits=12, validators=[django.core.validators.MinValueValidator(0)])),
                ('total_paid_usd', models.DecimalField(decimal_places=2, default=0, max_digits=12, validators=[django.core.validators.MinValueValidator(0)])),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='affiliate_profile', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Affiliate Profile',
                'verbose_name_plural': 'Affiliate Profiles',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='AffiliatePayoutRequest',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('amount_usd', models.DecimalField(decimal_places=2, max_digits=10, validators=[django.core.validators.MinValueValidator(1)])),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('processing', 'Processing'), ('paid', 'Paid'), ('rejected', 'Rejected'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
                ('bank_snapshot', models.TextField(blank=True, help_text='Bank details at the time of payout request.')),
                ('admin_notes', models.TextField(blank=True)),
                ('requested_at', models.DateTimeField(auto_now_add=True)),
                ('processed_at', models.DateTimeField(blank=True, null=True)),
                ('affiliate', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payout_requests', to='affiliates_app.affiliateprofile')),
            ],
            options={
                'verbose_name': 'Affiliate Payout Request',
                'verbose_name_plural': 'Affiliate Payout Requests',
                'ordering': ['-requested_at'],
            },
        ),
        migrations.CreateModel(
            name='AffiliateGuestReferral',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('guest_name', models.CharField(blank=True, max_length=150)),
                ('guest_email', models.EmailField(blank=True, max_length=254)),
                ('guest_phone', models.CharField(blank=True, max_length=30)),
                ('guest_country', models.CharField(blank=True, max_length=100)),
                ('selected_package_name', models.CharField(blank=True, max_length=150)),
                ('selected_package_amount_usd', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('possible_confirmation_commission_usd', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('possible_service_fee_commission_usd', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('total_possible_commission_usd', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('total_earned_commission_usd', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('status', models.CharField(choices=[('signed_up', 'Signed Up'), ('confirmed', 'Confirmed'), ('service_fee_paid', 'Service Fee Paid'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='signed_up', max_length=30)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('foreigner_lead', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='affiliate_referrals', to='expat_life.foreignerlead')),
                ('foreigner_profile', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='affiliate_referrals', to='expat_life.foreignerprofile')),
                ('guest_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='affiliate_guest_referrals', to=settings.AUTH_USER_MODEL)),
                ('affiliate', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='guest_referrals', to='affiliates_app.affiliateprofile')),
            ],
            options={
                'verbose_name': 'Affiliate Guest Referral',
                'verbose_name_plural': 'Affiliate Guest Referrals',
                'ordering': ['-created_at'],
                'unique_together': {('affiliate', 'guest_user')},
            },
        ),
        migrations.CreateModel(
            name='AffiliateCommission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('commission_for', models.CharField(choices=[('guest_confirmation_fee', 'Guest Confirmation Fee'), ('guest_one_time_service_fee', 'Guest One-Time Service Fee')], max_length=50)),
                ('source_amount_usd', models.DecimalField(decimal_places=2, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])),
                ('commission_percentage', models.DecimalField(decimal_places=2, default=20, max_digits=5)),
                ('commission_amount_usd', models.DecimalField(decimal_places=2, max_digits=10, validators=[django.core.validators.MinValueValidator(0)])),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('earned', 'Earned'), ('paid', 'Paid'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
                ('earned_at', models.DateTimeField(blank=True, null=True)),
                ('paid_at', models.DateTimeField(blank=True, null=True)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('referral', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commissions', to='affiliates_app.affiliateguestreferral')),
                ('affiliate', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='commissions', to='affiliates_app.affiliateprofile')),
            ],
            options={
                'verbose_name': 'Affiliate Commission',
                'verbose_name_plural': 'Affiliate Commissions',
                'ordering': ['-created_at'],
                'unique_together': {('referral', 'commission_for')},
            },
        ),
    ]
