# Generated by Django 6.0.2 on 2026-03-17 09:36

import django.db.models.deletion
import django_pymissive.fields
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("django_pymissive", "0002_alter_missivebaseattachment_attachment_file"),
    ]

    operations = [
        migrations.CreateModel(
            name="MissiveBilling",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "comment",
                    models.TextField(
                        blank=True,
                        help_text="Internal comment or note",
                        null=True,
                        verbose_name="Comment",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="Updated At"),
                ),
                (
                    "billing_amount",
                    models.DecimalField(
                        blank=True,
                        decimal_places=4,
                        help_text="Amount billed for this missive or recipient",
                        max_digits=10,
                        null=True,
                        verbose_name="Billing Amount",
                    ),
                ),
                (
                    "estimate_amount",
                    models.DecimalField(
                        blank=True,
                        decimal_places=4,
                        help_text="Estimated amount before sending",
                        max_digits=10,
                        null=True,
                        verbose_name="Estimate Amount",
                    ),
                ),
                (
                    "is_billed",
                    models.BooleanField(
                        default=False,
                        help_text="Indicates if this record has been billed",
                        verbose_name="Billed",
                    ),
                ),
                (
                    "currency",
                    models.CharField(
                        blank=True,
                        help_text="ISO 4217 currency code (e.g. EUR, USD)",
                        max_length=3,
                        null=True,
                        verbose_name="Currency",
                    ),
                ),
                (
                    "invoice",
                    models.TextField(
                        blank=True,
                        help_text="Invoice or billing details from the provider",
                        null=True,
                        verbose_name="Invoice",
                    ),
                ),
                (
                    "trace",
                    models.JSONField(
                        blank=True,
                        help_text="Trace of the billing request",
                        null=True,
                        verbose_name="Trace",
                    ),
                ),
            ],
            options={
                "verbose_name": "Billing",
                "verbose_name_plural": "Billings",
                "ordering": ["-created_at"],
            },
        ),
        migrations.DeleteModel(
            name="MissiveRecipientNotification",
        ),
        migrations.CreateModel(
            name="MissiveRecipientApplication",
            fields=[],
            options={
                "verbose_name": "Application Recipient",
                "verbose_name_plural": "Application Recipients",
                "proxy": True,
                "indexes": [],
                "constraints": [],
            },
            bases=("django_pymissive.missiverecipient",),
        ),
        migrations.RenameField(
            model_name="missivecampaign",
            old_name="acknowledgement_postal",
            new_name="acknowledgement_lre",
        ),
        migrations.RenameField(
            model_name="missivecampaign",
            old_name="priority_postal",
            new_name="priority_lre",
        ),
        migrations.RemoveField(
            model_name="missivecampaign",
            name="body_postal",
        ),
        migrations.RemoveField(
            model_name="missivecampaign",
            name="delivery_mode_postal",
        ),
        migrations.RemoveField(
            model_name="missiveevent",
            name="billing_amount",
        ),
        migrations.RemoveField(
            model_name="missiveevent",
            name="description",
        ),
        migrations.RemoveField(
            model_name="missiveevent",
            name="estimate_amount",
        ),
        migrations.RemoveField(
            model_name="missiveevent",
            name="is_billed",
        ),
        migrations.RemoveField(
            model_name="missiveevent",
            name="provider",
        ),
        migrations.RemoveField(
            model_name="missiveevent",
            name="user_action",
        ),
        migrations.AddField(
            model_name="missivecampaign",
            name="delivery_mode_lre",
            field=models.CharField(
                choices=[
                    ("economic", "Economic"),
                    ("normal", "Normal"),
                    ("premium", "Premium"),
                    ("express", "Express"),
                ],
                default="normal",
                help_text="Delivery mode (economic, normal, premium, express)",
                max_length=50,
                verbose_name="Delivery Mode",
            ),
        ),
        migrations.AddField(
            model_name="missivecampaign",
            name="first_document",
            field=django_pymissive.fields.RichTextField(
                blank=True,
                help_text="First document content (HTML, converted to PDF for LRE)",
                verbose_name="First Document",
            ),
        ),
        migrations.AddField(
            model_name="missiveevent",
            name="client_initiated",
            field=models.BooleanField(
                default=False,
                help_text="True if the event was initiated by django_pymissive (send, resend, cancel, batch, etc.), False if received from a provider webhook.",
                verbose_name="Client Initiated",
            ),
        ),
        migrations.AddField(
            model_name="missiveevent",
            name="reason",
            field=models.TextField(
                blank=True,
                help_text="Reason or details about this event (provider-specific)",
                verbose_name="Reason",
            ),
        ),
        migrations.AlterField(
            model_name="missive",
            name="body_html",
            field=django_pymissive.fields.RichTextField(
                blank=True,
                help_text="HTML message body (email) or rich content (LRE)",
                null=True,
                verbose_name="Body HTML",
            ),
        ),
        migrations.AlterField(
            model_name="missive",
            name="delivery_mode",
            field=models.CharField(
                blank=True,
                choices=[
                    ("economic", "Economic"),
                    ("normal", "Normal"),
                    ("premium", "Premium"),
                    ("express", "Express"),
                ],
                help_text="Delivery mode (economic, normal, premium, express)",
                max_length=50,
                null=True,
                verbose_name="Delivery Mode",
            ),
        ),
        migrations.AlterField(
            model_name="missive",
            name="missive_support",
            field=models.CharField(
                choices=[
                    ("email", "Email"),
                    ("phone", "Phone"),
                    ("address", "Address"),
                    ("application", "Application"),
                ],
                editable=False,
                help_text="Support for the missive (email, phone, address, application)",
                max_length=50,
                verbose_name="Missive Support",
            ),
        ),
        migrations.AlterField(
            model_name="missive",
            name="missive_type",
            field=models.CharField(
                choices=[
                    ("lre", "Electronic registered letter (LRE)"),
                    ("ere", "Electronic registered email (ERE)"),
                    ("email", "Email"),
                    ("email_marketing", "Marketing email"),
                    ("sms", "SMS"),
                    ("rcs", "RCS (Rich SMS)"),
                    ("voice_call", "Automated voice call"),
                    ("notification", "In-app notification"),
                    ("push_notification", "Mobile push notification"),
                    ("branded", "Branded App messaging (WhatsApp, Slack, etc.)"),
                ],
                help_text="Type of missive (email, sms, lre, ere, etc.)",
                max_length=50,
                verbose_name="Missive Type",
            ),
        ),
        migrations.AlterField(
            model_name="missive",
            name="status",
            field=models.CharField(
                choices=[
                    ("draft", "Draft"),
                    ("processing", "Processing"),
                    ("success", "Success"),
                    ("failed", "Failed"),
                    ("partially_success", "Partially success"),
                    ("partially_failed", "Partially failed"),
                    ("error", "Error"),
                    ("cancelled", "Cancelled"),
                ],
                default="draft",
                help_text="Current status of the missive",
                max_length=20,
                verbose_name="Status",
            ),
        ),
        migrations.AlterField(
            model_name="missivebaseattachment",
            name="attachment_object_arguments",
            field=django_pymissive.fields.JSONField(
                blank=True,
                default={"args": [], "kwargs": {}, "method": "retrieve_attachment"},
                help_text="Arguments to pass to the file method (as dict for **kwargs)",
                verbose_name="Attachment Object Arguments",
            ),
        ),
        migrations.AlterField(
            model_name="missiveconfig",
            name="missive_type",
            field=models.CharField(
                choices=[
                    ("lre", "Electronic registered letter (LRE)"),
                    ("ere", "Electronic registered email (ERE)"),
                    ("email", "Email"),
                    ("email_marketing", "Marketing email"),
                    ("sms", "SMS"),
                    ("rcs", "RCS (Rich SMS)"),
                    ("voice_call", "Automated voice call"),
                    ("notification", "In-app notification"),
                    ("push_notification", "Mobile push notification"),
                    ("branded", "Branded App messaging (WhatsApp, Slack, etc.)"),
                ],
                help_text="Type of missive (email, sms, postal, etc.)",
                max_length=50,
                unique=True,
                verbose_name="Missive type",
            ),
        ),
        migrations.AlterField(
            model_name="missiveevent",
            name="event",
            field=models.CharField(
                blank=True,
                choices=[
                    ("delivered", "Delivered"),
                    ("opened", "Opened"),
                    ("read", "Read"),
                    ("clicked", "Clicked"),
                    ("proofs_of_delivery", "Proofs of Delivery"),
                    ("untreated", "Untreated"),
                    ("draft", "Draft"),
                    ("sent", "Sent"),
                    ("accepted", "Accepted"),
                    ("processed", "Processed"),
                    ("deposit_proof", "Deposit proof"),
                    ("proof_of_content", "Proof of content"),
                    ("archived", "Archived"),
                    ("attempted_delivery", "Attempted delivery"),
                    ("prepare", "Prepare"),
                    ("pending", "Pending"),
                    ("processing", "Processing"),
                    ("queued", "Queued"),
                    ("request", "Request"),
                    ("deferred", "Deferred"),
                    ("scheduled", "Scheduled"),
                    ("unknown", "Unknown"),
                    ("failed", "Failed"),
                    ("cancelled", "Cancelled"),
                    ("hard_bounce", "Hard bounce"),
                    ("soft_bounce", "Soft bounce"),
                    ("dropped", "Dropped"),
                    ("spam", "Spam"),
                    ("spam_report", "Spam report"),
                    ("blocked", "Blocked"),
                    ("rejected", "Rejected"),
                    ("refused", "Refused"),
                    ("invalid", "Invalid"),
                    ("carrier_rejected", "Carrier rejected"),
                    ("undelivered", "Undelivered"),
                    ("unsubscribe", "Unsubscribe"),
                    ("suppressed", "Suppressed"),
                    ("mailbox_full", "Mailbox full"),
                    ("domain_not_found", "Domain not found"),
                    ("error", "Error"),
                ],
                help_text="Event type (sent, delivered, read, failed, etc.)",
                max_length=50,
                null=True,
                verbose_name="Event",
            ),
        ),
        migrations.AlterField(
            model_name="missiverecipient",
            name="recipient_support",
            field=models.CharField(
                blank=True,
                choices=[
                    ("email", "Email"),
                    ("phone", "Phone"),
                    ("address", "Address"),
                    ("application", "Application"),
                ],
                help_text="Model of recipient",
                max_length=255,
                null=True,
                verbose_name="Recipient Model",
            ),
        ),
        migrations.AlterField(
            model_name="missiverecipient",
            name="status",
            field=models.CharField(
                choices=[
                    ("draft", "Draft"),
                    ("processing", "Processing"),
                    ("success", "Success"),
                    ("failed", "Failed"),
                    ("partially_success", "Partially success"),
                    ("partially_failed", "Partially failed"),
                    ("error", "Error"),
                    ("cancelled", "Cancelled"),
                ],
                default="draft",
                help_text="Current status of the missive",
                max_length=20,
                verbose_name="Status",
            ),
        ),
        migrations.AddField(
            model_name="missivebilling",
            name="missive",
            field=models.ForeignKey(
                help_text="Missive associated with this billing record",
                on_delete=django.db.models.deletion.CASCADE,
                related_name="to_missivebilling",
                to="django_pymissive.missive",
                verbose_name="Missive",
            ),
        ),
        migrations.AddField(
            model_name="missivebilling",
            name="recipient",
            field=models.ForeignKey(
                blank=True,
                help_text="Recipient when billing is per-recipient; null for missive-level billing",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="to_recipientbilling",
                to="django_pymissive.missiverecipient",
                verbose_name="Recipient",
            ),
        ),
    ]
