# Generated by Django 4.2.20 on 2025-07-10 22:39

import NEMO.fields
import NEMO_billing.quotes.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("NEMO", "0112_fix_project_name_uniqueness"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Quote",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(help_text="Name of the quote", max_length=100)),
                (
                    "emails",
                    NEMO.fields.MultiEmailField(
                        blank=True,
                        help_text="Email addresses to send this quote to. A comma-separated list can be used",
                        max_length=2000,
                        null=True,
                    ),
                ),
                ("expiration_date", models.DateField(blank=True, help_text="Date when this quote expires", null=True)),
                (
                    "created_date",
                    models.DateTimeField(auto_now_add=True, help_text="Date and time when this quote was created"),
                ),
                (
                    "updated_date",
                    models.DateTimeField(auto_now=True, help_text="Date and time when this quote was last updated"),
                ),
                (
                    "published_date",
                    models.DateTimeField(
                        blank=True, help_text="Date and time when this quote was published", null=True
                    ),
                ),
                (
                    "last_emails_sent_date",
                    models.DateTimeField(
                        blank=True, help_text="Date and time when the last emails were sent for this quote", null=True
                    ),
                ),
                (
                    "status",
                    models.IntegerField(
                        choices=[(0, "Draft"), (1, "Pending Approval"), (2, "Published")],
                        default=0,
                        help_text="Current status of the quote",
                    ),
                ),
                (
                    "file",
                    models.FileField(
                        blank=True,
                        max_length=255,
                        null=True,
                        upload_to=NEMO_billing.quotes.models.get_quote_document_filename,
                    ),
                ),
                (
                    "file_access_token",
                    models.CharField(
                        blank=True,
                        help_text="A random token used to access the quote file without authentication",
                        max_length=255,
                        null=True,
                    ),
                ),
                (
                    "approved_by",
                    models.ForeignKey(
                        blank=True,
                        help_text="User who approved or published this quote",
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="quotes_approved",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="QuoteConfiguration",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "name",
                    models.CharField(help_text="The name of this quote configuration", max_length=255, unique=True),
                ),
                (
                    "expiration_in_days",
                    models.PositiveIntegerField(
                        default=30, help_text="The default number of days quotes are valid for once published"
                    ),
                ),
                ("email_from", models.EmailField(help_text="The email address used to send quotes", max_length=254)),
                (
                    "email_cc",
                    NEMO.fields.MultiEmailField(
                        blank=True,
                        help_text="Email to cc the quote to. A comma-separated list can be used",
                        max_length=2000,
                        null=True,
                    ),
                ),
                ("merchant_name", models.CharField(max_length=255)),
                (
                    "merchant_details",
                    models.TextField(
                        blank=True,
                        help_text="The merchant details to be included in the quote (address, phone number etc.)",
                        null=True,
                    ),
                ),
                ("merchant_logo", models.ImageField(blank=True, null=True, upload_to="quote_logos")),
                (
                    "terms",
                    models.TextField(
                        blank=True, help_text="Terms and conditions to be included in the quote", null=True
                    ),
                ),
                ("currency", models.CharField(default="USD", max_length=4)),
                ("currency_symbol", models.CharField(blank=True, default="$", max_length=4, null=True)),
                (
                    "tax",
                    models.DecimalField(
                        blank=True,
                        decimal_places=3,
                        help_text="Tax in percent. For 20.5% enter 20.5",
                        max_digits=5,
                        null=True,
                    ),
                ),
                ("tax_name", models.CharField(blank=True, default="VAT", max_length=100, null=True)),
                (
                    "create_permissions",
                    NEMO.fields.MultiRoleGroupPermissionChoiceField(
                        help_text="The roles/groups required for users to create this type of quote"
                    ),
                ),
                (
                    "approval_permissions",
                    NEMO.fields.MultiRoleGroupPermissionChoiceField(
                        blank=True,
                        help_text="The roles/groups required for users to approve this type of quote",
                        null=True,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="QuoteItem",
            fields=[
                ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "quantity",
                    models.DecimalField(decimal_places=0, default=1, help_text="Quantity of the item", max_digits=8),
                ),
                ("amount", models.DecimalField(decimal_places=2, help_text="Amount for this item", max_digits=8)),
                (
                    "minimum_charge",
                    models.DecimalField(
                        blank=True, decimal_places=2, help_text="Minimum amount for this item", max_digits=8, null=True
                    ),
                ),
                ("description", models.CharField(help_text="Description for this item", max_length=255)),
                (
                    "rate_type",
                    models.IntegerField(
                        choices=[(0, "N/A"), (1, "Flat"), (2, "Hourly"), (3, "Daily")],
                        default=0,
                        help_text="Rate type (N/A, Flat, Hourly, Daily) for this item",
                    ),
                ),
                ("quote", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="quotes.quote")),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="quote",
            name="configuration",
            field=models.ForeignKey(
                help_text="Configuration for this quote",
                on_delete=django.db.models.deletion.PROTECT,
                to="quotes.quoteconfiguration",
            ),
        ),
        migrations.AddField(
            model_name="quote",
            name="creator",
            field=models.ForeignKey(
                help_text="User who created this quote",
                on_delete=django.db.models.deletion.PROTECT,
                related_name="quotes_created",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="quote",
            name="project",
            field=models.ForeignKey(
                blank=True,
                help_text="Project associated with this quote",
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                to="NEMO.project",
            ),
        ),
        migrations.AddField(
            model_name="quote",
            name="users",
            field=models.ManyToManyField(
                blank=True, help_text="Users associated with this quote", to=settings.AUTH_USER_MODEL
            ),
        ),
    ]
