# Generated by Django 3.2.20 on 2023-07-12 13:10
import uuid

import agir.lib.model_fields
import agir.payments.model_fields
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import dynamic_filenames


class Migration(migrations.Migration):
    dependencies = [
        ("people", "0031_remove_unused_options_for_newsletters"),
        ("events", "0034_eventsubtype_for_supportgroups"),
        ("groups", "0018_membership_has_finance_managing_privilege"),
        ("donations", "0024_auto_20230411_1701"),
    ]

    operations = [
        migrations.RenameField(
            model_name="spendingrequest",
            old_name="provider",
            new_name="bank_account_name",
        ),
        migrations.RenameField(
            model_name="spendingrequest",
            old_name="iban",
            new_name="bank_account_iban",
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="creator",
            field=models.ForeignKey(
                blank=True,
                default=None,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="own_spending_requests",
                related_query_name="own_spending_request",
                to="people.person",
                verbose_name="Créateur·ice de la demande",
            ),
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="bank_account_bic",
            field=agir.lib.model_fields.BICField(
                default="", verbose_name="BIC", blank=True
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="bank_account_rib",
            field=models.FileField(
                blank=True,
                null=True,
                upload_to=dynamic_filenames.FilePattern(
                    filename_pattern="{app_label}/{model_name}/{instance.id}/{uuid:.8base32}{ext}"
                ),
                validators=[
                    django.core.validators.FileExtensionValidator(
                        ["pdf", "png", "jpeg", "jpg"]
                    )
                ],
                verbose_name="RIB",
            ),
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="campaign",
            field=models.BooleanField(
                default=False,
                verbose_name="Dépense effectuée dans le cadre d'une campagne éléctorale",
            ),
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="timing",
            field=models.CharField(
                blank=True,
                choices=[("P", "Passée"), ("U", "Future")],
                default="",
                max_length=1,
                verbose_name="Type de dépense",
            ),
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="contact_email",
            field=models.EmailField(
                blank=True,
                default="",
                max_length=254,
                verbose_name="Adresse e-mail du contact",
            ),
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="contact_name",
            field=models.CharField(
                blank=True, default="", max_length=255, verbose_name="Nom du contact"
            ),
        ),
        migrations.AddField(
            model_name="spendingrequest",
            name="contact_phone",
            field=models.CharField(
                blank=True,
                default="",
                max_length=30,
                verbose_name="Numéro de téléphone du contact",
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="id",
            field=models.UUIDField(
                default=uuid.uuid4,
                editable=False,
                primary_key=True,
                serialize=False,
                verbose_name="Identifiant",
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="status",
            field=models.CharField(
                choices=[
                    ("D", "Brouillon à compléter"),
                    ("G", "En attente de vérification par une autre personne"),
                    (
                        "R",
                        "En attente de vérification par l'équipe de suivi des questions financières",
                    ),
                    ("I", "Informations supplémentaires requises"),
                    (
                        "V",
                        "Validée par l'équipe de suivi des questions financières, en attente des fonds",
                    ),
                    ("T", "Décomptée de l'allocation du groupe, à payer"),
                    ("P", "Payée"),
                    ("B", "Cette demande a été refusée"),
                ],
                default="D",
                max_length=1,
                verbose_name="Statut",
            ),
        ),
        migrations.AlterField(
            model_name="document",
            name="request",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="documents",
                related_query_name="document",
                to="donations.spendingrequest",
                verbose_name="Demande de dépense",
            ),
        ),
        migrations.AlterField(
            model_name="document",
            name="type",
            field=models.CharField(
                choices=[
                    ("E", "Devis"),
                    ("I", "Facture"),
                    ("B", "Impression"),
                    (
                        "P",
                        "Photo ou illustration de l'événement, de la salle, du matériel",
                    ),
                    ("O", "Autre type de justificatif"),
                ],
                max_length=1,
                verbose_name="Type de document",
            ),
        ),
        migrations.AlterField(
            model_name="document",
            name="file",
            field=models.FileField(
                upload_to=dynamic_filenames.FilePattern(
                    filename_pattern="{app_label}/{model_name}/{instance.request_id}/{uuid:.8base32}{ext}"
                ),
                validators=[
                    django.core.validators.FileExtensionValidator(
                        [
                            "doc",
                            "docx",
                            "odt",
                            "xls",
                            "xlsx",
                            "ods",
                            "pdf",
                            "png",
                            "jpeg",
                            "jpg",
                            "gif",
                        ]
                    )
                ],
                verbose_name="Fichier",
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="amount",
            field=agir.payments.model_fields.AmountField(
                verbose_name="Montant de la dépense"
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="category",
            field=models.CharField(
                choices=[
                    ("H", "[Obsolète] Matériel militant"),
                    ("S", "[Obsolète] Prestation de service"),
                    ("V", "[Obsolète] Location de salle"),
                    ("O", "[Obsolète] Autres"),
                    ("IM", "Impressions"),
                    ("CO", "Achat de consommables (colles, feutres, … )"),
                    (
                        "AC",
                        "Achat de matériel (quincaillerie, matériel de collage, … )",
                    ),
                    ("DE", "Déplacement"),
                    ("HE", "Hébergement"),
                    ("SA", "Location de salle"),
                    ("MA", "Location de matériel (mobilier, vaisselle, … )"),
                    ("TE", "Location de matériel technique (sono, vidéo)"),
                    ("VE", "Location de véhicule"),
                ],
                max_length=2,
                verbose_name="Catégorie",
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="category_precisions",
            field=models.CharField(
                blank=True,
                max_length=260,
                verbose_name="Précisions sur le type de demande",
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="event",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="spending_requests",
                related_query_name="spending_request",
                to="events.event",
                verbose_name="Événement lié à la dépense",
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="explanation",
            field=models.TextField(
                max_length=1500, verbose_name="Motif de l'achat", blank=True
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="group",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="spending_requests",
                related_query_name="spending_request",
                to="groups.supportgroup",
                verbose_name="Groupe lié la dépense",
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="payer_name",
            field=models.CharField(
                max_length=200,
                verbose_name="[Obsolète] Personne à payer",
                null=True,
                blank=True,
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="spending_date",
            field=models.DateField(
                help_text="Si l'achat n'a pas encore été effectué, merci d'indiquer la date probable à laquelle celui-ci surviendra.",
                verbose_name="Date de l'achat",
                blank=True,
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="bank_account_iban",
            field=agir.lib.model_fields.IBANField(
                allowed_countries=["FR"],
                max_length=34,
                verbose_name="IBAN",
                blank=True,
            ),
        ),
        migrations.AlterField(
            model_name="spendingrequest",
            name="bank_account_name",
            field=models.CharField(
                max_length=200, verbose_name="Titulaire du compte bancaire", blank=True
            ),
        ),
    ]
