# Generated by Django 5.2.11 on 2026-04-06 20:51

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('companies', '0004_companysettings_enable_unlimited_stock'),
        ('inventory', '0009_add_company_fk'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Insight',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('description', models.TextField()),
                ('category', models.CharField(choices=[('sales', 'Sales'), ('inventory', 'Inventory'), ('customers', 'Customers'), ('staff', 'Staff'), ('branch', 'Branch'), ('financial', 'Financial')], db_index=True, max_length=20)),
                ('priority', models.CharField(choices=[('low', 'Low'), ('medium', 'Medium'), ('high', 'High')], default='medium', max_length=10)),
                ('color', models.CharField(choices=[('green', 'Green'), ('yellow', 'Yellow'), ('red', 'Red'), ('blue', 'Blue')], default='blue', max_length=10)),
                ('icon', models.CharField(blank=True, default='fa-lightbulb', max_length=50)),
                ('is_read', models.BooleanField(db_index=True, default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='insights', to='companies.company')),
            ],
            options={
                'verbose_name': 'Insight',
                'verbose_name_plural': 'Insights',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['company', 'is_read'], name='analytics_i_company_11d729_idx'), models.Index(fields=['company', 'category'], name='analytics_i_company_4aa5d8_idx')],
            },
        ),
        migrations.CreateModel(
            name='Notification',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('message', models.TextField()),
                ('notification_type', models.CharField(choices=[('info', 'Info'), ('warning', 'Warning'), ('danger', 'Danger'), ('success', 'Success')], default='info', max_length=10)),
                ('icon', models.CharField(blank=True, default='fa-bell', max_length=50)),
                ('is_read', models.BooleanField(db_index=True, default=False)),
                ('url', models.CharField(blank=True, help_text='Optional action URL', max_length=400)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifications', to='companies.company')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notifications', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Notification',
                'verbose_name_plural': 'Notifications',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['company', 'is_read'], name='analytics_n_company_efac99_idx')],
            },
        ),
        migrations.CreateModel(
            name='RolePermission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role', models.CharField(choices=[('cashier', 'Cashier'), ('manager', 'Manager'), ('admin', 'Admin')], max_length=20)),
                ('can_delete_orders', models.BooleanField(default=False)),
                ('can_reverse_orders', models.BooleanField(default=False)),
                ('can_change_price_at_pos', models.BooleanField(default=False)),
                ('can_apply_discount', models.BooleanField(default=True)),
                ('can_view_profit', models.BooleanField(default=False)),
                ('can_view_pnl', models.BooleanField(default=False)),
                ('can_view_analytics', models.BooleanField(default=False)),
                ('can_export_data', models.BooleanField(default=False)),
                ('can_manage_products', models.BooleanField(default=False)),
                ('can_manage_customers', models.BooleanField(default=True)),
                ('can_change_settings', models.BooleanField(default=False)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='role_permissions', to='companies.company')),
            ],
            options={
                'verbose_name': 'Role Permission',
                'verbose_name_plural': 'Role Permissions',
                'unique_together': {('company', 'role')},
            },
        ),
        migrations.CreateModel(
            name='StockForecast',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('avg_daily_sales', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('days_until_stockout', models.IntegerField(blank=True, help_text='Estimated days until stock reaches zero. NULL = no recent sales.', null=True)),
                ('recommended_restock_qty', models.PositiveIntegerField(default=0)),
                ('stock_health', models.CharField(choices=[('healthy', 'Healthy'), ('low_risk', 'Low Stock Risk'), ('critical', 'Critical - Restock Now'), ('dead', 'Dead Stock'), ('overstock', 'Overstock')], default='healthy', max_length=15)),
                ('generated_at', models.DateTimeField(auto_now=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_forecasts', to='companies.company')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='forecast', to='inventory.product')),
            ],
            options={
                'verbose_name': 'Stock Forecast',
                'verbose_name_plural': 'Stock Forecasts',
                'ordering': ['days_until_stockout'],
                'unique_together': {('company', 'product')},
            },
        ),
    ]
