# Generated by Django 5.2.7 on 2026-01-14 11:26

import django.core.validators
import django.db.models.deletion
import django.utils.timezone
from decimal import Decimal
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("business", "0001_initial"),
        ("inventory", "0001_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="CashDrawer",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "drawer_number",
                    models.CharField(db_index=True, max_length=50, unique=True),
                ),
                ("opened_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("closed_at", models.DateTimeField(blank=True, null=True)),
                (
                    "opening_balance",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Starting cash amount (float)",
                        max_digits=12,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.00"))
                        ],
                    ),
                ),
                (
                    "expected_balance",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Calculated expected balance",
                        max_digits=12,
                    ),
                ),
                (
                    "actual_closing_balance",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        help_text="Actual cash counted at closing",
                        max_digits=12,
                        null=True,
                    ),
                ),
                (
                    "variance",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Difference between expected and actual",
                        max_digits=12,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("OPEN", "Open"),
                            ("CLOSED", "Closed"),
                            ("RECONCILED", "Reconciled"),
                        ],
                        db_index=True,
                        default="OPEN",
                        max_length=20,
                    ),
                ),
                ("reconciled_at", models.DateTimeField(blank=True, null=True)),
                ("reconciliation_notes", models.TextField(blank=True)),
                ("opening_notes", models.TextField(blank=True)),
                ("closing_notes", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="cash_drawers",
                        to="business.business",
                    ),
                ),
                (
                    "closed_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="cash_drawers_closed",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "location",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="cash_drawers",
                        to="business.location",
                    ),
                ),
                (
                    "opened_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="cash_drawers_opened",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "reconciled_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="cash_drawers_reconciled",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-opened_at"],
            },
        ),
        migrations.CreateModel(
            name="CashDrawerAuditLog",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "action",
                    models.CharField(
                        choices=[
                            ("OPENED", "Drawer Opened"),
                            ("CLOSED", "Drawer Closed"),
                            ("RECONCILED", "Drawer Reconciled"),
                            ("TRANSACTION_ADDED", "Transaction Added"),
                            ("ADJUSTMENT_MADE", "Adjustment Made"),
                            ("ACCESSED", "Drawer Accessed"),
                        ],
                        max_length=50,
                    ),
                ),
                (
                    "details",
                    models.JSONField(
                        default=dict, help_text="Additional details about the action"
                    ),
                ),
                ("notes", models.TextField(blank=True)),
                (
                    "timestamp",
                    models.DateTimeField(
                        db_index=True, default=django.utils.timezone.now
                    ),
                ),
                ("ip_address", models.GenericIPAddressField(blank=True, null=True)),
                (
                    "cash_drawer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="audit_logs",
                        to="sales.cashdrawer",
                    ),
                ),
                (
                    "performed_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-timestamp"],
            },
        ),
        migrations.CreateModel(
            name="CashDrawerDenomination",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "denomination_value",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Value of the denomination (e.g., 1000, 500, 100)",
                        max_digits=10,
                    ),
                ),
                (
                    "count",
                    models.PositiveIntegerField(
                        default=0, help_text="Number of notes/coins"
                    ),
                ),
                (
                    "total_value",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "count_type",
                    models.CharField(
                        choices=[
                            ("OPENING", "Opening Count"),
                            ("CLOSING", "Closing Count"),
                        ],
                        max_length=20,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "cash_drawer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="denominations",
                        to="sales.cashdrawer",
                    ),
                ),
            ],
            options={
                "ordering": ["-denomination_value"],
            },
        ),
        migrations.CreateModel(
            name="Customer",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=200)),
                ("email", models.EmailField(blank=True, max_length=254, null=True)),
                ("phone", models.CharField(max_length=20)),
                (
                    "secondary_phone",
                    models.CharField(blank=True, max_length=20, null=True),
                ),
                ("address", models.TextField(blank=True, null=True)),
                ("id_number", models.CharField(blank=True, max_length=50, null=True)),
                (
                    "credit_enabled",
                    models.BooleanField(
                        default=False,
                        help_text="Whether credit facility is enabled for this customer",
                    ),
                ),
                (
                    "credit_limit",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Maximum credit amount allowed",
                        max_digits=10,
                        validators=[django.core.validators.MinValueValidator(0)],
                    ),
                ),
                (
                    "current_credit_balance",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        max_digits=10,
                        validators=[django.core.validators.MinValueValidator(0)],
                    ),
                ),
                (
                    "credit_approval_date",
                    models.DateTimeField(
                        blank=True,
                        help_text="When credit was first approved",
                        null=True,
                    ),
                ),
                (
                    "last_credit_review_date",
                    models.DateTimeField(
                        blank=True,
                        help_text="Last time credit limit was reviewed/changed",
                        null=True,
                    ),
                ),
                (
                    "credit_status",
                    models.CharField(
                        choices=[
                            ("GOOD", "Good Standing"),
                            ("WARNING", "Warning - Near Limit"),
                            ("SUSPENDED", "Suspended"),
                            ("BLOCKED", "Blocked - Overdue"),
                        ],
                        default="GOOD",
                        max_length=20,
                    ),
                ),
                (
                    "total_credit_sales",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Total historical credit sales",
                        max_digits=12,
                    ),
                ),
                (
                    "total_credit_payments",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Total credit payments made",
                        max_digits=12,
                    ),
                ),
                (
                    "credit_payment_history_score",
                    models.IntegerField(
                        default=0,
                        help_text="Score from 0-100 based on payment behavior",
                    ),
                ),
                (
                    "overdue_count",
                    models.IntegerField(
                        default=0, help_text="Number of times payment was overdue"
                    ),
                ),
                (
                    "payment_terms",
                    models.CharField(
                        choices=[
                            ("NET_7", "Net 7 Days"),
                            ("NET_15", "Net 15 Days"),
                            ("NET_30", "Net 30 Days"),
                            ("NET_45", "Net 45 Days"),
                            ("NET_60", "Net 60 Days"),
                            ("CUSTOM", "Custom Terms"),
                        ],
                        default="NET_30",
                        help_text="Payment due period for credit transactions",
                        max_length=50,
                    ),
                ),
                (
                    "credit_risk_level",
                    models.CharField(
                        choices=[
                            ("LOW", "Low Risk"),
                            ("MEDIUM", "Medium Risk"),
                            ("HIGH", "High Risk"),
                            ("CRITICAL", "Critical Risk"),
                        ],
                        default="MEDIUM",
                        max_length=20,
                    ),
                ),
                (
                    "average_days_to_payment",
                    models.IntegerField(
                        default=0,
                        help_text="Average number of days customer takes to pay",
                    ),
                ),
                (
                    "last_payment_date",
                    models.DateTimeField(
                        blank=True,
                        help_text="Date of most recent credit payment",
                        null=True,
                    ),
                ),
                (
                    "total_overdue_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Total amount that is past due date",
                        max_digits=12,
                    ),
                ),
                (
                    "oldest_overdue_date",
                    models.DateField(
                        blank=True,
                        help_text="Date of oldest unpaid overdue transaction",
                        null=True,
                    ),
                ),
                (
                    "peak_credit_utilization",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Highest credit utilization percentage ever reached",
                        max_digits=5,
                    ),
                ),
                (
                    "auto_credit_eligible",
                    models.BooleanField(
                        default=False,
                        help_text="Whether customer qualifies for auto credit approval",
                    ),
                ),
                (
                    "auto_credit_eligible_date",
                    models.DateTimeField(
                        blank=True,
                        help_text="Date when customer became eligible for auto credit",
                        null=True,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                ("is_active", models.BooleanField(default=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="customers",
                        to="business.business",
                    ),
                ),
                (
                    "credit_approved_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="credit_approvals",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="CreditLimitHistory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("old_limit", models.DecimalField(decimal_places=2, max_digits=10)),
                ("new_limit", models.DecimalField(decimal_places=2, max_digits=10)),
                ("reason", models.TextField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "changed_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="credit_limit_history",
                        to="sales.customer",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Credit Limit Histories",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="PaymentMode",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        choices=[
                            ("CASH", "Cash"),
                            ("MPESA", "M-Pesa"),
                            ("BANK", "Bank Transfer"),
                            ("CREDIT", "Credit"),
                            ("CHEQUE", "Cheque"),
                        ],
                        max_length=50,
                    ),
                ),
                ("is_active", models.BooleanField(default=True)),
                ("requires_reference", models.BooleanField(default=False)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="payment_modes",
                        to="business.business",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="PaymentPlan",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "plan_name",
                    models.CharField(
                        help_text="Descriptive name for the plan", max_length=200
                    ),
                ),
                (
                    "total_amount",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Total amount to be paid",
                        max_digits=12,
                    ),
                ),
                (
                    "remaining_balance",
                    models.DecimalField(
                        decimal_places=2, help_text="Amount still owed", max_digits=12
                    ),
                ),
                (
                    "installment_amount",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Amount per installment",
                        max_digits=10,
                    ),
                ),
                (
                    "installment_frequency",
                    models.CharField(
                        choices=[
                            ("WEEKLY", "Weekly"),
                            ("BIWEEKLY", "Bi-weekly"),
                            ("MONTHLY", "Monthly"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "number_of_installments",
                    models.IntegerField(
                        help_text="Total number of planned installments"
                    ),
                ),
                (
                    "installments_paid",
                    models.IntegerField(
                        default=0, help_text="Number of installments paid so far"
                    ),
                ),
                ("start_date", models.DateField()),
                ("end_date", models.DateField()),
                (
                    "next_due_date",
                    models.DateField(
                        blank=True, help_text="Date of next installment", null=True
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("ACTIVE", "Active"),
                            ("COMPLETED", "Completed"),
                            ("DEFAULTED", "Defaulted"),
                            ("CANCELLED", "Cancelled"),
                        ],
                        db_index=True,
                        default="ACTIVE",
                        max_length=20,
                    ),
                ),
                (
                    "missed_payments_count",
                    models.IntegerField(
                        default=0, help_text="Number of missed/late payments"
                    ),
                ),
                (
                    "late_fee_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Fee charged for late payments",
                        max_digits=10,
                    ),
                ),
                (
                    "grace_period_days",
                    models.IntegerField(
                        default=3,
                        help_text="Days after due date before late fee applies",
                    ),
                ),
                ("notes", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="business.business",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="payment_plans_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="payment_plans",
                        to="sales.customer",
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="PaymentPlanInstallment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "installment_number",
                    models.IntegerField(
                        help_text="Sequential number of this installment"
                    ),
                ),
                ("due_date", models.DateField(db_index=True)),
                ("amount", models.DecimalField(decimal_places=2, max_digits=10)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("PAID", "Paid"),
                            ("LATE", "Late"),
                            ("MISSED", "Missed"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                ("paid_date", models.DateField(blank=True, null=True)),
                (
                    "paid_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                ("payment_reference", models.CharField(blank=True, max_length=100)),
                (
                    "late_fee_charged",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "payment_plan",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="installments",
                        to="sales.paymentplan",
                    ),
                ),
            ],
            options={
                "ordering": ["installment_number"],
            },
        ),
        migrations.CreateModel(
            name="Quote",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "quote_number",
                    models.CharField(db_index=True, max_length=50, unique=True),
                ),
                ("quote_date", models.DateField(default=django.utils.timezone.now)),
                (
                    "valid_until",
                    models.DateField(help_text="Date until which the quote is valid"),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("DRAFT", "Draft"),
                            ("SENT", "Sent"),
                            ("ACCEPTED", "Accepted"),
                            ("REJECTED", "Rejected"),
                            ("EXPIRED", "Expired"),
                            ("CONVERTED", "Converted to Sale"),
                        ],
                        db_index=True,
                        default="DRAFT",
                        max_length=20,
                    ),
                ),
                (
                    "subtotal",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        max_digits=12,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.00"))
                        ],
                    ),
                ),
                (
                    "discount_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        max_digits=10,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.00"))
                        ],
                    ),
                ),
                (
                    "tax_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        max_digits=10,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.00"))
                        ],
                    ),
                ),
                (
                    "total_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        max_digits=12,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.00"))
                        ],
                    ),
                ),
                ("notes", models.TextField(blank=True, help_text="Internal notes")),
                (
                    "terms_and_conditions",
                    models.TextField(
                        blank=True, help_text="Terms and conditions shown to customer"
                    ),
                ),
                (
                    "customer_notes",
                    models.TextField(blank=True, help_text="Notes visible to customer"),
                ),
                ("converted_date", models.DateTimeField(blank=True, null=True)),
                ("sent_date", models.DateTimeField(blank=True, null=True)),
                ("accepted_date", models.DateTimeField(blank=True, null=True)),
                ("rejected_date", models.DateTimeField(blank=True, null=True)),
                ("rejection_reason", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="quotes",
                        to="business.business",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="quotes_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="quotes",
                        to="sales.customer",
                    ),
                ),
                (
                    "location",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="quotes",
                        to="business.location",
                    ),
                ),
            ],
            options={
                "ordering": ["-quote_date", "-created_at"],
            },
        ),
        migrations.CreateModel(
            name="QuoteFollowUp",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "follow_up_type",
                    models.CharField(
                        choices=[
                            ("CALL", "Phone Call"),
                            ("EMAIL", "Email"),
                            ("MEETING", "Meeting"),
                            ("MESSAGE", "Message"),
                            ("OTHER", "Other"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "follow_up_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("notes", models.TextField()),
                (
                    "next_follow_up_date",
                    models.DateField(
                        blank=True, help_text="Schedule next follow-up", null=True
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "followed_up_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="quote_follow_ups",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "quote",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="follow_ups",
                        to="sales.quote",
                    ),
                ),
            ],
            options={
                "ordering": ["-follow_up_date"],
            },
        ),
        migrations.CreateModel(
            name="QuoteItem",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("item_name", models.CharField(max_length=200)),
                (
                    "description",
                    models.TextField(
                        blank=True, help_text="Additional description for the customer"
                    ),
                ),
                (
                    "quantity",
                    models.PositiveIntegerField(
                        validators=[django.core.validators.MinValueValidator(1)]
                    ),
                ),
                (
                    "unit_price",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=10,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.01"))
                        ],
                    ),
                ),
                (
                    "discount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        max_digits=10,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.00"))
                        ],
                    ),
                ),
                (
                    "total_price",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=12,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.00"))
                        ],
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "inventory_item",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="quote_items",
                        to="inventory.inventoryitem",
                    ),
                ),
                (
                    "quote",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="items",
                        to="sales.quote",
                    ),
                ),
            ],
            options={
                "ordering": ["created_at"],
            },
        ),
        migrations.CreateModel(
            name="Sale",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("sale_number", models.CharField(max_length=50, unique=True)),
                ("sale_date", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("COMPLETED", "Completed"),
                            ("PARTIALLY_RETURNED", "Partially Returned"),
                            ("FULLY_RETURNED", "Fully Returned"),
                            ("PENDING", "Pending"),
                            ("CANCELLED", "Cancelled"),
                        ],
                        default="COMPLETED",
                        max_length=20,
                    ),
                ),
                (
                    "subtotal",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "discount_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                (
                    "tax_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                ("total_amount", models.DecimalField(decimal_places=2, max_digits=12)),
                (
                    "amount_paid",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Total amount paid for this sale",
                        max_digits=12,
                    ),
                ),
                (
                    "amount_due",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Remaining amount to be paid",
                        max_digits=12,
                    ),
                ),
                (
                    "commission_rate",
                    models.DecimalField(
                        decimal_places=5, default=Decimal("0.00007"), max_digits=5
                    ),
                ),
                (
                    "commission_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                ("commission_paid", models.BooleanField(default=False)),
                ("notes", models.TextField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="sales",
                        to="business.business",
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="purchases",
                        to="sales.customer",
                    ),
                ),
                (
                    "location",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="sales",
                        to="business.location",
                    ),
                ),
                (
                    "salesperson",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sales_made",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-sale_date"],
            },
        ),
        migrations.AddField(
            model_name="quote",
            name="converted_sale",
            field=models.OneToOneField(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="original_quote",
                to="sales.sale",
            ),
        ),
        migrations.CreateModel(
            name="CreditTransaction",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "transaction_type",
                    models.CharField(
                        choices=[
                            ("SALE", "Sale on Credit"),
                            ("PAYMENT", "Credit Payment"),
                            ("ADJUSTMENT", "Adjustment"),
                            ("INTEREST", "Interest Charge"),
                            ("FEE", "Late Fee"),
                            ("WRITE_OFF", "Write-off"),
                            ("OVERDUE", "Overdue Marker"),
                        ],
                        max_length=20,
                    ),
                ),
                ("amount", models.DecimalField(decimal_places=2, max_digits=12)),
                ("balance_after", models.DecimalField(decimal_places=2, max_digits=12)),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "transaction_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "days_overdue",
                    models.IntegerField(
                        default=0, help_text="Number of days payment is overdue"
                    ),
                ),
                (
                    "is_overdue_notification_sent",
                    models.BooleanField(
                        default=False, help_text="Whether overdue notification was sent"
                    ),
                ),
                (
                    "overdue_notification_date",
                    models.DateTimeField(blank=True, null=True),
                ),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="business.business",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="credit_transactions",
                        to="sales.customer",
                    ),
                ),
                (
                    "related_payment_plan",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="credit_transactions",
                        to="sales.paymentplan",
                    ),
                ),
                (
                    "sale",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="credit_records",
                        to="sales.sale",
                    ),
                ),
            ],
            options={
                "ordering": ["-transaction_date"],
            },
        ),
        migrations.CreateModel(
            name="Commission",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("amount", models.DecimalField(decimal_places=2, max_digits=10)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("PENDING", "Pending"),
                            ("PAID", "Paid"),
                            ("REVERSED", "Reversed"),
                        ],
                        default="PENDING",
                        max_length=20,
                    ),
                ),
                ("paid_date", models.DateTimeField(blank=True, null=True)),
                (
                    "payment_reference",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                (
                    "returned_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                (
                    "net_commission",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="business.business",
                    ),
                ),
                (
                    "salesperson",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="commissions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "sale",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="commission_record",
                        to="sales.sale",
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="SaleItem",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "item_type",
                    models.CharField(
                        choices=[
                            ("inventory_item", "Inventory Item"),
                            ("accessory_item", "Accessory Item"),
                        ],
                        default="inventory_item",
                        help_text="Type of item being sold",
                        max_length=20,
                    ),
                ),
                ("item_name", models.CharField(max_length=200)),
                (
                    "quantity",
                    models.PositiveIntegerField(
                        default=1,
                        validators=[django.core.validators.MinValueValidator(1)],
                    ),
                ),
                ("unit_price", models.DecimalField(decimal_places=2, max_digits=10)),
                (
                    "discount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                ("total_price", models.DecimalField(decimal_places=2, max_digits=12)),
                ("purchase_cost", models.DecimalField(decimal_places=2, max_digits=10)),
                (
                    "profit",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[("SOLD", "Sold"), ("RETURNED", "Returned")],
                        default="SOLD",
                        max_length=20,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "accessory_item",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sale_items",
                        to="inventory.accessory",
                    ),
                ),
                (
                    "inventory_item",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sale_items",
                        to="inventory.inventoryitem",
                    ),
                ),
                (
                    "sale",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="items",
                        to="sales.sale",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="SalePayment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=12,
                        validators=[django.core.validators.MinValueValidator(0.01)],
                    ),
                ),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                (
                    "payment_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "payment_mode",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="sales.paymentmode",
                    ),
                ),
                (
                    "sale",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="payments",
                        to="sales.sale",
                    ),
                ),
            ],
            options={
                "ordering": ["-payment_date"],
            },
        ),
        migrations.CreateModel(
            name="CreditLedger",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "transaction_type",
                    models.CharField(
                        choices=[
                            ("SALE", "Sale on Credit"),
                            ("PAYMENT", "Credit Payment"),
                            ("ADJUSTMENT", "Manual Adjustment"),
                            ("INTEREST", "Interest Charge"),
                            ("FEE", "Late Fee"),
                            ("WRITE_OFF", "Write-off"),
                            ("REFUND", "Refund/Return"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "transaction_date",
                    models.DateTimeField(
                        db_index=True, default=django.utils.timezone.now
                    ),
                ),
                (
                    "debit_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Amount increasing customer balance (sales, fees)",
                        max_digits=12,
                    ),
                ),
                (
                    "credit_amount",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Amount decreasing customer balance (payments)",
                        max_digits=12,
                    ),
                ),
                (
                    "balance_after",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Customer balance after this transaction",
                        max_digits=12,
                    ),
                ),
                (
                    "due_date",
                    models.DateField(
                        blank=True,
                        help_text="When payment is due for this entry",
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("CURRENT", "Current"),
                            ("OVERDUE", "Overdue"),
                            ("PAID", "Paid"),
                            ("WRITTEN_OFF", "Written Off"),
                        ],
                        db_index=True,
                        default="CURRENT",
                        max_length=20,
                    ),
                ),
                (
                    "reference_id",
                    models.CharField(
                        blank=True,
                        help_text="External reference (receipt number, etc.)",
                        max_length=100,
                    ),
                ),
                (
                    "description",
                    models.TextField(help_text="Human-readable description"),
                ),
                ("notes", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="business.business",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="credit_ledger_entries",
                        to="sales.customer",
                    ),
                ),
                (
                    "sale",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="credit_ledger_entries",
                        to="sales.sale",
                    ),
                ),
                (
                    "payment",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="sales.salepayment",
                    ),
                ),
            ],
            options={
                "ordering": ["-transaction_date"],
            },
        ),
        migrations.CreateModel(
            name="SaleReturn",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("return_number", models.CharField(max_length=50, unique=True)),
                (
                    "return_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "reason",
                    models.CharField(
                        choices=[
                            ("DEFECTIVE", "Defective Product"),
                            ("CUSTOMER_REQUEST", "Customer Request"),
                            ("CHANGED_MIND", "Customer Changed Mind"),
                            ("WRONG_ITEM", "Wrong Item"),
                            ("DAMAGED", "Damaged"),
                            ("OTHER", "Other"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "total_refund_amount",
                    models.DecimalField(decimal_places=2, max_digits=12),
                ),
                (
                    "commission_reversed",
                    models.DecimalField(decimal_places=2, default=0, max_digits=10),
                ),
                ("commission_reversal_processed", models.BooleanField(default=False)),
                ("notes", models.TextField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "business",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="business.business",
                    ),
                ),
                (
                    "location",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="business.location",
                    ),
                ),
                (
                    "original_sale",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="returns",
                        to="sales.sale",
                    ),
                ),
                (
                    "processed_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="returns_processed",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-return_date"],
            },
        ),
        migrations.CreateModel(
            name="CashDrawerTransaction",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "type",
                    models.CharField(
                        choices=[
                            ("SALE", "Cash Sale"),
                            ("RETURN", "Cash Return"),
                            ("DEPOSIT", "Cash Deposit"),
                            ("WITHDRAWAL", "Cash Withdrawal"),
                            ("ADJUSTMENT", "Adjustment"),
                        ],
                        db_index=True,
                        max_length=20,
                    ),
                ),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=12,
                        validators=[
                            django.core.validators.MinValueValidator(Decimal("0.01"))
                        ],
                    ),
                ),
                (
                    "reference",
                    models.CharField(
                        help_text="Reference number (sale number, etc.)", max_length=100
                    ),
                ),
                ("description", models.TextField(blank=True)),
                ("notes", models.TextField(blank=True)),
                (
                    "timestamp",
                    models.DateTimeField(
                        db_index=True, default=django.utils.timezone.now
                    ),
                ),
                (
                    "cash_drawer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="transactions",
                        to="sales.cashdrawer",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="cash_drawer_transactions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "sale",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="cash_drawer_transactions",
                        to="sales.sale",
                    ),
                ),
                (
                    "sale_return",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="cash_drawer_transactions",
                        to="sales.salereturn",
                    ),
                ),
            ],
            options={
                "ordering": ["-timestamp"],
            },
        ),
        migrations.CreateModel(
            name="SaleReturnItem",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "quantity_returned",
                    models.PositiveIntegerField(
                        validators=[django.core.validators.MinValueValidator(1)]
                    ),
                ),
                ("refund_amount", models.DecimalField(decimal_places=2, max_digits=10)),
                ("restocked", models.BooleanField(default=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "accessory_item",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="inventory.accessory",
                    ),
                ),
                (
                    "inventory_item",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="inventory.inventoryitem",
                    ),
                ),
                (
                    "sale_item",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="return_records",
                        to="sales.saleitem",
                    ),
                ),
                (
                    "sale_return",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="items",
                        to="sales.salereturn",
                    ),
                ),
            ],
        ),
        migrations.AddIndex(
            model_name="cashdrawer",
            index=models.Index(
                fields=["business", "status"], name="sales_cashd_busines_5ca034_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawer",
            index=models.Index(
                fields=["location", "status"], name="sales_cashd_locatio_9fe664_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawer",
            index=models.Index(
                fields=["opened_at"], name="sales_cashd_opened__e16db7_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawer",
            index=models.Index(
                fields=["status", "opened_at"], name="sales_cashd_status_12a9de_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawerauditlog",
            index=models.Index(
                fields=["cash_drawer", "timestamp"],
                name="sales_cashd_cash_dr_1476fb_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawerauditlog",
            index=models.Index(fields=["action"], name="sales_cashd_action_f23ef7_idx"),
        ),
        migrations.AddIndex(
            model_name="customer",
            index=models.Index(
                fields=["business", "phone"], name="sales_custo_busines_ca6040_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="customer",
            index=models.Index(
                fields=["business", "name"], name="sales_custo_busines_1d89a1_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="customer",
            index=models.Index(
                fields=["business", "credit_enabled"],
                name="sales_custo_busines_967651_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="customer",
            index=models.Index(
                fields=["credit_status"], name="sales_custo_credit__d5c2b1_idx"
            ),
        ),
        migrations.AlterUniqueTogether(
            name="paymentmode",
            unique_together={("business", "name")},
        ),
        migrations.AddIndex(
            model_name="paymentplan",
            index=models.Index(
                fields=["customer", "status"], name="sales_payme_custome_84a09f_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="paymentplan",
            index=models.Index(
                fields=["next_due_date"], name="sales_payme_next_du_14af42_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="paymentplan",
            index=models.Index(
                fields=["status", "next_due_date"], name="sales_payme_status_cd970d_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="paymentplaninstallment",
            index=models.Index(
                fields=["payment_plan", "status"], name="sales_payme_payment_05807e_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="paymentplaninstallment",
            index=models.Index(
                fields=["due_date", "status"], name="sales_payme_due_dat_2e86eb_idx"
            ),
        ),
        migrations.AlterUniqueTogether(
            name="paymentplaninstallment",
            unique_together={("payment_plan", "installment_number")},
        ),
        migrations.AddIndex(
            model_name="sale",
            index=models.Index(
                fields=["business", "sale_date"], name="sales_sale_busines_3d57fe_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="sale",
            index=models.Index(
                fields=["salesperson", "sale_date"],
                name="sales_sale_salespe_500108_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="sale",
            index=models.Index(
                fields=["customer", "sale_date"], name="sales_sale_custome_e35bee_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="sale",
            index=models.Index(
                fields=["sale_number"], name="sales_sale_sale_nu_99d8fe_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="quote",
            index=models.Index(
                fields=["business", "status"], name="sales_quote_busines_0adf2d_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="quote",
            index=models.Index(
                fields=["customer", "status"], name="sales_quote_custome_47e5dd_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="quote",
            index=models.Index(
                fields=["quote_date"], name="sales_quote_quote_d_56572e_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="quote",
            index=models.Index(
                fields=["valid_until"], name="sales_quote_valid_u_ec377d_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="credittransaction",
            index=models.Index(
                fields=["customer", "transaction_date"],
                name="sales_credi_custome_24a1e1_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="credittransaction",
            index=models.Index(
                fields=["business", "transaction_date"],
                name="sales_credi_busines_398ede_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="commission",
            index=models.Index(
                fields=["salesperson", "status"], name="sales_commi_salespe_652e1d_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="commission",
            index=models.Index(
                fields=["business", "created_at"], name="sales_commi_busines_476d6c_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="saleitem",
            index=models.Index(
                fields=["sale", "status"], name="sales_salei_sale_id_1d40f0_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="saleitem",
            index=models.Index(
                fields=["inventory_item"], name="sales_salei_invento_b6e991_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="saleitem",
            index=models.Index(
                fields=["accessory_item"], name="sales_salei_accesso_c09393_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="saleitem",
            index=models.Index(
                fields=["item_type"], name="sales_salei_item_ty_5e5062_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="salepayment",
            index=models.Index(
                fields=["sale", "payment_date"], name="sales_salep_sale_id_f65465_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="salepayment",
            index=models.Index(
                fields=["payment_mode"], name="sales_salep_payment_4494f2_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="creditledger",
            index=models.Index(
                fields=["customer", "transaction_date"],
                name="sales_credi_custome_b49dca_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="creditledger",
            index=models.Index(
                fields=["customer", "status"], name="sales_credi_custome_a0bd6f_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="creditledger",
            index=models.Index(
                fields=["due_date"], name="sales_credi_due_dat_f249a5_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="creditledger",
            index=models.Index(
                fields=["status", "due_date"], name="sales_credi_status_a17c85_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="salereturn",
            index=models.Index(
                fields=["original_sale"], name="sales_saler_origina_978884_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="salereturn",
            index=models.Index(
                fields=["business", "return_date"],
                name="sales_saler_busines_18f0ea_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawertransaction",
            index=models.Index(
                fields=["cash_drawer", "type"], name="sales_cashd_cash_dr_0e3380_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawertransaction",
            index=models.Index(
                fields=["cash_drawer", "timestamp"],
                name="sales_cashd_cash_dr_5b6086_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="cashdrawertransaction",
            index=models.Index(
                fields=["reference"], name="sales_cashd_referen_c663ec_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="salereturnitem",
            index=models.Index(
                fields=["sale_return"], name="sales_saler_sale_re_641893_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="salereturnitem",
            index=models.Index(
                fields=["sale_item"], name="sales_saler_sale_it_f93852_idx"
            ),
        ),
    ]
