# Generated by Django 5.2.7 on 2026-06-09 08:46

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


class Migration(migrations.Migration):

    dependencies = [
        ('restaurant', '0014_loyalty_phase1'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='DeadHourDrop',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('message', models.TextField()),
                ('discount_code', models.CharField(blank=True, max_length=50)),
                ('valid_until', models.DateTimeField(blank=True, null=True)),
                ('total_recipients', models.IntegerField(default=0)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
                ('restaurant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dead_hour_drops', to='restaurant.restaurant')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='KhataAccount',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('lifelines_total', models.IntegerField(default=5)),
                ('lifelines_used', models.IntegerField(default=0)),
                ('current_tab_amount', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('tab_due_date', models.DateField(blank=True, null=True)),
                ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('OVERDUE', 'Overdue'), ('BLOCKED', 'Blocked')], default='ACTIVE', max_length=20)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('wallet', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='khata', to='restaurant.customerwallet')),
            ],
        ),
        migrations.CreateModel(
            name='KhataTransaction',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=10)),
                ('is_cleared', models.BooleanField(default=False)),
                ('cleared_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('booking', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='restaurant.booking')),
                ('khata', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='khata_transactions', to='restaurant.khataaccount')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='LoyaltyGroup',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('group_name', models.CharField(max_length=200)),
                ('vault_balance', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('vault_percentage', models.DecimalField(decimal_places=2, default=5.0, help_text='% of each member bill added to vault', max_digits=5)),
                ('semester_start', models.DateField(blank=True, null=True)),
                ('semester_end', models.DateField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('admin', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='managed_groups', to=settings.AUTH_USER_MODEL)),
                ('restaurant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='loyalty_groups', to='restaurant.restaurant')),
            ],
        ),
        migrations.CreateModel(
            name='LoyaltySubscription',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('amount_paid', models.DecimalField(decimal_places=2, max_digits=8)),
                ('payment_reference', models.CharField(blank=True, max_length=100)),
                ('valid_from', models.DateField()),
                ('valid_until', models.DateField()),
                ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('EXPIRED', 'Expired'), ('CANCELLED', 'Cancelled')], default='ACTIVE', max_length=20)),
                ('last_used_date', models.DateField(blank=True, null=True)),
                ('total_uses', models.IntegerField(default=0)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('rule', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='restaurant.loyaltyrule')),
                ('wallet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subscriptions', to='restaurant.customerwallet')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='WalletTopup',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('cash_paid', models.DecimalField(decimal_places=2, max_digits=8)),
                ('coins_credited', models.DecimalField(decimal_places=2, max_digits=10)),
                ('payment_reference', models.CharField(blank=True, max_length=100)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('rule', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='restaurant.loyaltyrule')),
                ('wallet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='topups', to='restaurant.customerwallet')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='LoyaltyGroupMember',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('joined_at', models.DateTimeField(auto_now_add=True)),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='restaurant.loyaltygroup')),
                ('wallet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='group_memberships', to='restaurant.customerwallet')),
            ],
            options={
                'unique_together': {('group', 'wallet')},
            },
        ),
    ]
