# Generated by Django 5.0 on 2025-11-16 23:56

import datetime
import django.core.validators
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('app', '0071_productcategory_product'),
        ('userapp', '0015_alter_costumuser_type'),
    ]

    operations = [
        migrations.AlterField(
            model_name='projectactivity',
            name='activity_type',
            field=models.CharField(choices=[('DESIGN', 'Design/Conception'), ('PLANNING', 'Planification'), ('CONSTRUCTION', 'Construction'), ('INSPECTION', 'Inspection'), ('DOCUMENTATION', 'Documentation'), ('MEETING', 'Réunion'), ('FACTURE', 'Facture'), ('NOTE', 'Note'), ('DEVIS', 'Devis'), ('JUSTIFICATIF', 'Justificatif'), ('ETUDE', 'Étude'), ('REALISATION', 'Réalisation'), ('CONTROLE', 'Contrôle'), ('VALIDATION', 'Validation'), ('FINITION', 'Finition'), ('LIVRAISON', 'Livraison'), ('SAV', 'SAV'), ('OTHER', 'Autre')], max_length=15, verbose_name="Type d'activité"),
        ),
        migrations.CreateModel(
            name='Decompte',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('label', models.CharField(max_length=180, verbose_name='Libellé')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=14, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant')),
                ('date', models.DateField(default=datetime.date.today, verbose_name='Date')),
                ('period_start', models.DateField(blank=True, null=True, verbose_name='Période début')),
                ('period_end', models.DateField(blank=True, null=True, verbose_name='Période fin')),
                ('status', models.CharField(choices=[('DRAFT', 'Brouillon'), ('SUBMITTED', 'Soumis'), ('APPROVED', 'Approuvé'), ('REJECTED', 'Rejeté'), ('INVOICED', 'Facturé'), ('PAID', 'Payé')], default='DRAFT', max_length=12, verbose_name='Statut')),
                ('note', models.TextField(blank=True, verbose_name='Note')),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='decomptes', to='app.dashboardproject', verbose_name='Projet')),
            ],
            options={
                'verbose_name': 'Décompte',
                'verbose_name_plural': 'Décomptes',
                'ordering': ['-date'],
            },
        ),
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('number', models.CharField(max_length=50, verbose_name='Numéro')),
                ('date', models.DateField(default=datetime.date.today, verbose_name='Date')),
                ('due_date', models.DateField(blank=True, null=True, verbose_name='Échéance')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=14, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant')),
                ('status', models.CharField(choices=[('DRAFT', 'Brouillon'), ('SENT', 'Envoyée'), ('PAID', 'Payée'), ('CANCELLED', 'Annulée')], default='DRAFT', max_length=10, verbose_name='Statut')),
                ('file', models.FileField(blank=True, null=True, upload_to='dashboard/invoices/', verbose_name='Fichier')),
                ('paid_date', models.DateField(blank=True, null=True, verbose_name='Date de paiement')),
                ('decompte', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='invoices', to='app.decompte', verbose_name='Décompte')),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invoices', to='app.dashboardproject', verbose_name='Projet')),
            ],
            options={
                'verbose_name': 'Facture',
                'verbose_name_plural': 'Factures',
                'ordering': ['-date'],
            },
        ),
        migrations.CreateModel(
            name='ProjectPayment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('type', models.CharField(choices=[('ADVANCE', 'Avance'), ('PARTIAL', 'Partiel'), ('FINAL', 'Solde'), ('RETENTION_RELEASE', 'Libération rétention')], max_length=20, verbose_name='Type')),
                ('amount', models.DecimalField(decimal_places=2, max_digits=14, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant')),
                ('date', models.DateField(default=datetime.date.today, verbose_name='Date')),
                ('method', models.CharField(choices=[('CASH', 'Espèces'), ('BANK', 'Virement bancaire'), ('CHEQUE', 'Chèque'), ('OTHER', 'Autre')], default='BANK', max_length=10, verbose_name='Méthode')),
                ('reference', models.CharField(blank=True, max_length=120, verbose_name='Référence')),
                ('note', models.TextField(blank=True, verbose_name='Note')),
                ('decompte', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='payments', to='app.decompte', verbose_name='Décompte')),
                ('invoice', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='payments', to='app.invoice', verbose_name='Facture')),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='payments', to='app.dashboardproject', verbose_name='Projet')),
            ],
            options={
                'verbose_name': 'Paiement',
                'verbose_name_plural': 'Paiements',
                'ordering': ['-date'],
            },
        ),
        migrations.CreateModel(
            name='ProjectPhase',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.PositiveSmallIntegerField(choices=[(1, 'Phase 1 - Études'), (2, 'Phase 2 - Fondations'), (3, 'Phase 3 - Soubassement'), (4, 'Phase 4 - Élévations (Gros Œuvre)'), (5, 'Phase 5 - Second Œuvre'), (6, 'Phase 6 - Finitions'), (7, 'Phase 7 - Livraison'), (8, 'Phase 8 - SAV / Garantie')], verbose_name='Numéro/Phase')),
                ('name', models.CharField(max_length=120, verbose_name='Nom de la phase')),
                ('status', models.CharField(choices=[('NOT_STARTED', 'Non démarrée'), ('IN_PROGRESS', 'En cours'), ('COMPLETED', 'Terminée'), ('ON_HOLD', 'En pause')], default='NOT_STARTED', max_length=12, verbose_name='Statut')),
                ('weight', models.DecimalField(decimal_places=2, default=0.0, max_digits=5, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Poids (%)')),
                ('progress_percent', models.PositiveSmallIntegerField(default=0, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Avancement (%)')),
                ('start_planned', models.DateField(blank=True, null=True, verbose_name='Début (prévu)')),
                ('end_planned', models.DateField(blank=True, null=True, verbose_name='Fin (prévue)')),
                ('start_actual', models.DateField(blank=True, null=True, verbose_name='Début (réel)')),
                ('end_actual', models.DateField(blank=True, null=True, verbose_name='Fin (réelle)')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='phases', to='app.dashboardproject', verbose_name='Projet')),
            ],
            options={
                'verbose_name': 'Phase du projet',
                'verbose_name_plural': 'Phases du projet',
                'ordering': ['order'],
            },
        ),
        migrations.AddField(
            model_name='decompte',
            name='phase',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='decomptes', to='app.projectphase', verbose_name='Phase'),
        ),
        migrations.CreateModel(
            name='ProjectRetention',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rate_percent', models.PositiveSmallIntegerField(default=5, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Taux (%)')),
                ('amount_held', models.DecimalField(decimal_places=2, default=0, max_digits=14, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant retenu')),
                ('is_released', models.BooleanField(default=False, verbose_name='Libérée')),
                ('release_date', models.DateField(blank=True, null=True, verbose_name='Date de libération')),
                ('note', models.TextField(blank=True, verbose_name='Note')),
                ('project', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='retention', to='app.dashboardproject', verbose_name='Projet')),
            ],
            options={
                'verbose_name': 'Rétention',
                'verbose_name_plural': 'Rétentions',
            },
        ),
        migrations.CreateModel(
            name='ProjectSubphase',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=120, verbose_name='Nom')),
                ('type', models.CharField(choices=[('STANDARD', 'Standard'), ('ELEVATION', 'Élévation (niveau)'), ('SOUS_SOL', 'Sous-sol')], default='STANDARD', max_length=12, verbose_name='Type')),
                ('order', models.PositiveSmallIntegerField(default=0, verbose_name='Ordre')),
                ('weight', models.DecimalField(decimal_places=2, default=0.0, max_digits=5, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Poids (%)')),
                ('progress_percent', models.PositiveSmallIntegerField(default=0, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Avancement (%)')),
                ('level_index', models.IntegerField(blank=True, null=True, verbose_name='Indice niveau (ex: 0 pour RDC)')),
                ('level_label', models.CharField(blank=True, max_length=20, verbose_name='Libellé niveau (ex: RDC, R+1)')),
                ('start_planned', models.DateField(blank=True, null=True, verbose_name='Début (prévu)')),
                ('end_planned', models.DateField(blank=True, null=True, verbose_name='Fin (prévue)')),
                ('start_actual', models.DateField(blank=True, null=True, verbose_name='Début (réel)')),
                ('end_actual', models.DateField(blank=True, null=True, verbose_name='Fin (réelle)')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('phase', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subphases', to='app.projectphase', verbose_name='Phase')),
            ],
            options={
                'verbose_name': 'Sous-phase',
                'verbose_name_plural': 'Sous-phases',
                'ordering': ['phase', 'order'],
            },
        ),
        migrations.CreateModel(
            name='ProjectDocument',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=180, verbose_name='Titre')),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('doc_type', models.CharField(choices=[('PLAN', 'Plan'), ('PV', 'Procès-verbal'), ('PHOTO', 'Photo'), ('VIDEO', 'Vidéo'), ('RAPPORT', 'Rapport'), ('CONTRAT', 'Contrat'), ('AUTRE', 'Autre')], default='PLAN', max_length=10, verbose_name='Type')),
                ('file', models.FileField(blank=True, null=True, upload_to='dashboard/documents/', verbose_name='Fichier')),
                ('tags', models.CharField(blank=True, max_length=250, verbose_name='Tags (séparés par des virgules)')),
                ('is_public', models.BooleanField(default=False, verbose_name='Visible par le client')),
                ('version', models.PositiveIntegerField(default=1, verbose_name='Version')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Créé le')),
                ('published_at', models.DateTimeField(blank=True, null=True, verbose_name='Publié le')),
                ('previous_version', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='next_versions', to='app.projectdocument', verbose_name='Version précédente')),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='app.dashboardproject', verbose_name='Projet')),
                ('uploaded_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='project_documents', to='userapp.costumuser', verbose_name='Uploadé par')),
                ('phase', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='documents', to='app.projectphase', verbose_name='Phase')),
                ('subphase', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='documents', to='app.projectsubphase', verbose_name='Sous-phase')),
            ],
            options={
                'verbose_name': 'Document',
                'verbose_name_plural': 'Documents',
                'ordering': ['-created_at'],
            },
        ),
        migrations.AddField(
            model_name='decompte',
            name='subphase',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='decomptes', to='app.projectsubphase', verbose_name='Sous-phase'),
        ),
        migrations.CreateModel(
            name='SavTicket',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=180, verbose_name='Titre')),
                ('description', models.TextField(verbose_name='Description')),
                ('status', models.CharField(choices=[('OPEN', 'Ouvert'), ('IN_PROGRESS', 'En cours'), ('RESOLVED', 'Résolu'), ('CLOSED', 'Fermé')], default='OPEN', max_length=12, verbose_name='Statut')),
                ('priority', models.CharField(choices=[('LOW', 'Basse'), ('MEDIUM', 'Moyenne'), ('HIGH', 'Haute'), ('URGENT', 'Urgent')], default='MEDIUM', max_length=10, verbose_name='Priorité')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Créé le')),
                ('closed_at', models.DateTimeField(blank=True, null=True, verbose_name='Clôturé le')),
                ('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sav_assigned', to='userapp.costumuser', verbose_name='Assigné à')),
                ('opened_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sav_opened', to='userapp.costumuser', verbose_name='Ouvert par')),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sav_tickets', to='app.dashboardproject', verbose_name='Projet')),
            ],
            options={
                'verbose_name': 'Ticket SAV',
                'verbose_name_plural': 'Tickets SAV',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='SavRepairPV',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.TextField(blank=True, verbose_name='Description')),
                ('date', models.DateField(default=datetime.date.today, verbose_name='Date')),
                ('file', models.FileField(blank=True, null=True, upload_to='dashboard/sav/pv/', verbose_name='Fichier')),
                ('signed_by_client', models.CharField(blank=True, max_length=120, verbose_name='Signé par (client)')),
                ('signed_by_staff', models.CharField(blank=True, max_length=120, verbose_name='Signé par (équipe)')),
                ('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='repair_pvs', to='app.savticket', verbose_name='Ticket')),
            ],
            options={
                'verbose_name': 'PV de réparation',
                'verbose_name_plural': 'PV de réparation',
            },
        ),
        migrations.CreateModel(
            name='SavWarranty',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateField(blank=True, null=True, verbose_name='Début garantie')),
                ('end_date', models.DateField(blank=True, null=True, verbose_name='Fin garantie')),
                ('notes', models.TextField(blank=True, verbose_name='Notes')),
                ('project', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='sav_warranty', to='app.dashboardproject', verbose_name='Projet')),
            ],
            options={
                'verbose_name': 'Garantie SAV',
                'verbose_name_plural': 'Garanties SAV',
            },
        ),
    ]
