# Generated by Django 5.1.5 on 2026-10-05 12:55

import api.models.data.attachment
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 = [
        ("contenttypes", "0002_remove_content_type_name"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Account",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("account_number", models.CharField(max_length=50)),
                ("name", models.CharField(blank=True, max_length=150, null=True)),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-id"],
            },
        ),
        migrations.CreateModel(
            name="ActivityLog",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "action",
                    models.CharField(
                        choices=[
                            ("create", "Create"),
                            ("update", "Update"),
                            ("delete", "Delete"),
                            ("login", "Login"),
                            ("logout", "Logout"),
                            ("view", "View"),
                            ("export", "Export"),
                            ("payment", "Payment"),
                        ],
                        max_length=20,
                    ),
                ),
                ("model_name", models.CharField(max_length=100)),
                ("object_id", models.PositiveIntegerField(blank=True, null=True)),
                ("description", models.TextField()),
                ("ip_address", models.GenericIPAddressField(blank=True, null=True)),
                ("user_agent", models.TextField(blank=True, null=True)),
                ("changes", models.JSONField(blank=True, null=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="activity_logs",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="AttachedDocument",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("title", models.CharField(max_length=255)),
                (
                    "file",
                    models.FileField(
                        upload_to=api.models.data.attachment.attachment_upload_to,
                        validators=[
                            django.core.validators.FileExtensionValidator(
                                allowed_extensions=[
                                    "pdf",
                                    "jpg",
                                    "jpeg",
                                    "png",
                                    "webp",
                                    "gif",
                                ]
                            )
                        ],
                    ),
                ),
                ("original_name", models.CharField(blank=True, max_length=255)),
                ("file_size", models.PositiveIntegerField(default=0)),
                ("object_id", models.PositiveIntegerField()),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["id"],
            },
        ),
        migrations.CreateModel(
            name="CurrencyExchange",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "exchange_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "from_currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                ("from_amount", models.DecimalField(decimal_places=2, max_digits=15)),
                (
                    "from_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        max_length=20,
                    ),
                ),
                (
                    "to_currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                ("to_amount", models.DecimalField(decimal_places=2, max_digits=15)),
                (
                    "to_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        max_length=20,
                    ),
                ),
                (
                    "rate",
                    models.DecimalField(
                        decimal_places=6,
                        default=Decimal("0"),
                        help_text="Cross rate: 1 unit of from_currency = this many units of to_currency.",
                        max_digits=18,
                    ),
                ),
                (
                    "from_exchange_rate",
                    models.DecimalField(
                        blank=True,
                        decimal_places=6,
                        help_text="Deal rate: 1 unit of from_currency = this many AFN. AFN = 1.",
                        max_digits=18,
                        null=True,
                    ),
                ),
                (
                    "to_exchange_rate",
                    models.DecimalField(
                        blank=True,
                        decimal_places=6,
                        help_text="Deal rate: 1 unit of to_currency = this many AFN. AFN = 1.",
                        max_digits=18,
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "Draft"),
                            ("posted", "Posted"),
                            ("reversed", "Reversed"),
                        ],
                        default="posted",
                        max_length=20,
                    ),
                ),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                ("posted_at", models.DateTimeField(blank=True, null=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="recorded_currency_exchanges",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-exchange_date", "-id"],
            },
        ),
        migrations.CreateModel(
            name="Customer",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("code", models.CharField(blank=True, max_length=50, unique=True)),
                ("name", models.CharField(max_length=255)),
                ("phone", models.CharField(blank=True, max_length=20, null=True)),
                ("email", models.EmailField(blank=True, max_length=255, null=True)),
                ("address", models.CharField(blank=True, max_length=255, null=True)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Employee",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("full_name", models.CharField(default="", max_length=255)),
                ("email", models.EmailField(blank=True, max_length=254, null=True)),
                ("address", models.CharField(blank=True, max_length=255, null=True)),
                ("phone", models.CharField(default="", max_length=50)),
                (
                    "tazkira_number",
                    models.CharField(blank=True, default="", max_length=100),
                ),
                (
                    "tazkira_copy",
                    models.FileField(
                        blank=True, null=True, upload_to="employee/tazkira_copies/"
                    ),
                ),
                (
                    "salary",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "currency",
                    models.IntegerField(
                        blank=True,
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")],
                        null=True,
                    ),
                ),
                ("contract_start_date", models.DateField(blank=True, null=True)),
                ("contract_end_date", models.DateField(blank=True, null=True)),
                ("is_active", models.BooleanField(default=True)),
                ("notes", models.CharField(blank=True, max_length=200, null=True)),
                ("date_joined", models.DateTimeField(auto_now_add=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        blank=True,
                        help_text="Login account for this employee.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="employee_profile",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Attendance",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("date", models.DateField()),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("present", "Present"),
                            ("absent", "Absent"),
                            ("leave", "Leave"),
                            ("holiday", "Holiday"),
                            ("late", "Late"),
                        ],
                        default="present",
                        max_length=20,
                    ),
                ),
                ("check_in_time", models.TimeField(blank=True, null=True)),
                ("check_out_time", models.TimeField(blank=True, null=True)),
                ("device_id", models.CharField(blank=True, max_length=50, null=True)),
                (
                    "employee_device_id",
                    models.CharField(blank=True, max_length=50, null=True),
                ),
                (
                    "verification_type",
                    models.CharField(
                        choices=[
                            ("fingerprint", "Fingerprint"),
                            ("face", "Face Recognition"),
                            ("card", "Card"),
                            ("password", "Password"),
                            ("manual", "Manual Entry"),
                        ],
                        default="fingerprint",
                        max_length=20,
                    ),
                ),
                (
                    "work_hours",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=5),
                ),
                (
                    "overtime_hours",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=5),
                ),
                (
                    "break_time",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=5),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "employee",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="attendances",
                        to="api.employee",
                    ),
                ),
            ],
            options={
                "ordering": ["-date", "-check_in_time"],
            },
        ),
        migrations.CreateModel(
            name="EmployeeLeave",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("start_date", models.DateField()),
                ("end_date", models.DateField()),
                ("reason", models.TextField(blank=True, null=True)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("pending", "Pending"),
                            ("approved", "Approved"),
                            ("rejected", "Rejected"),
                        ],
                        default="pending",
                        max_length=20,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "employee",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="leave_requests",
                        to="api.employee",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="EntryType",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=100, unique=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="AccountEntry",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("entry_date", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "debit_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "credit_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                ("object_id", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="entries",
                        to="api.account",
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "entry_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="entries",
                        to="api.entrytype",
                    ),
                ),
            ],
            options={
                "ordering": ["-entry_date", "-id"],
            },
        ),
        migrations.CreateModel(
            name="ExchangeRate",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "from_currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "to_currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")], default=1
                    ),
                ),
                (
                    "rate",
                    models.DecimalField(
                        decimal_places=6,
                        help_text="1 unit of from_currency equals this many units of to_currency (base).",
                        max_digits=18,
                    ),
                ),
                ("date", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "effective_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("notes", models.CharField(blank=True, default="", max_length=255)),
                ("source", models.CharField(blank=True, default="", max_length=100)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-date"],
            },
        ),
        migrations.CreateModel(
            name="Expense",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("amount", models.DecimalField(decimal_places=2, max_digits=12)),
                (
                    "amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                (
                    "expense_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "payment_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        help_text="Cash book credited when the expense is posted",
                        max_length=20,
                    ),
                ),
                (
                    "receipt",
                    models.FileField(
                        blank=True, null=True, upload_to="expenses/receipts/"
                    ),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="expenses",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Equipment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=150)),
                (
                    "category",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("furniture", "Furniture"),
                            ("computers", "Computers"),
                            ("peripherals", "Peripherals"),
                            ("networking", "Networking"),
                            ("electronics", "Electronics"),
                            ("communication", "Communication"),
                            ("appliances", "Appliances"),
                            ("security", "Security"),
                            ("storage", "Storage"),
                            ("lighting", "Lighting"),
                            ("other", "Other"),
                        ],
                        help_text="Office equipment category",
                        max_length=100,
                        null=True,
                    ),
                ),
                (
                    "serial_number",
                    models.CharField(
                        blank=True,
                        help_text="Auto-generated label serial (e.g. E26-0001) for printing on the asset",
                        max_length=100,
                        null=True,
                        unique=True,
                    ),
                ),
                ("asset_tag", models.CharField(blank=True, max_length=100, null=True)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "quantity",
                    models.DecimalField(decimal_places=2, default=1, max_digits=12),
                ),
                (
                    "unit",
                    models.CharField(
                        blank=True, default="pcs", max_length=50, null=True
                    ),
                ),
                (
                    "unit_cost",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "acquired_date",
                    models.DateField(default=django.utils.timezone.localdate),
                ),
                (
                    "acquisition_type",
                    models.CharField(
                        choices=[
                            ("new_purchase", "New purchase"),
                            ("opening", "Existing / opening asset"),
                            ("owner_contribution", "Owner contribution"),
                            ("expense", "Record as expense"),
                        ],
                        default="new_purchase",
                        help_text="How this asset entered the books",
                        max_length=30,
                    ),
                ),
                (
                    "accumulated_depreciation",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Historical accumulated depreciation (opening / owner assets only)",
                        max_digits=12,
                    ),
                ),
                (
                    "useful_life_months",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="Useful life in months for future depreciation runs",
                        null=True,
                    ),
                ),
                (
                    "residual_value",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Expected salvage value at end of useful life",
                        max_digits=12,
                    ),
                ),
                (
                    "depreciation_start_date",
                    models.DateField(
                        blank=True,
                        help_text="Date depreciation should begin",
                        null=True,
                    ),
                ),
                ("condition", models.CharField(blank=True, max_length=100, null=True)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("in_use", "In use"),
                            ("in_storage", "In storage"),
                            ("under_repair", "Under repair"),
                            ("disposed", "Disposed"),
                        ],
                        default="in_use",
                        max_length=30,
                    ),
                ),
                (
                    "location",
                    models.CharField(
                        blank=True,
                        help_text="Room, floor, or desk location",
                        max_length=150,
                        null=True,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "is_opening_balance",
                    models.BooleanField(
                        default=False,
                        help_text="Legacy flag — synced from acquisition_type",
                    ),
                ),
                (
                    "record_as_expense",
                    models.BooleanField(
                        default=False,
                        help_text="Legacy flag — synced from acquisition_type",
                    ),
                ),
                (
                    "payment_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        help_text="Cash book used when buying new equipment",
                        max_length=20,
                    ),
                ),
                (
                    "assigned_to",
                    models.ForeignKey(
                        blank=True,
                        help_text="Employee currently using this equipment",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="assigned_equipment",
                        to="api.employee",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "expense",
                    models.OneToOneField(
                        blank=True,
                        help_text="Linked expense row when acquisition_type is expense",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="equipment_source",
                        to="api.expense",
                    ),
                ),
            ],
            options={
                "verbose_name": "Equipment",
                "verbose_name_plural": "Equipment",
                "ordering": ["name", "id"],
            },
        ),
        migrations.CreateModel(
            name="ExpenseCategory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=100)),
                (
                    "description",
                    models.CharField(blank=True, max_length=200, null=True),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="expense",
            name="category",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="expenses",
                to="api.expensecategory",
            ),
        ),
        migrations.CreateModel(
            name="FiscalYear",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=50)),
                ("start_date", models.DateField()),
                ("end_date", models.DateField()),
                (
                    "status",
                    models.CharField(
                        choices=[("open", "Open"), ("closed", "Closed")],
                        default="open",
                        max_length=20,
                    ),
                ),
                ("is_current", models.BooleanField(default=False)),
                ("closed_at", models.DateTimeField(blank=True, null=True)),
                (
                    "net_income",
                    models.DecimalField(
                        decimal_places=2, default=Decimal("0"), max_digits=15
                    ),
                ),
                ("notes", models.TextField(blank=True)),
                (
                    "closed_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="closed_fiscal_years",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Fiscal Year",
                "verbose_name_plural": "Fiscal Years",
                "ordering": ["-start_date"],
            },
        ),
        migrations.CreateModel(
            name="FxRevaluation",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "as_of_date",
                    models.DateField(
                        help_text="Balances through end of this date are revalued at closing rates."
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "Draft"),
                            ("posted", "Posted"),
                            ("reversed", "Reversed"),
                        ],
                        default="posted",
                        max_length=20,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "total_gain",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "total_loss",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "closing_rates",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Map of currency_id → closing rate used (1 unit = X AFN).",
                    ),
                ),
                ("posted_at", models.DateTimeField(blank=True, null=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="recorded_fx_revaluations",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-as_of_date", "-id"],
            },
        ),
        migrations.CreateModel(
            name="GLAccount",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("code", models.CharField(max_length=20)),
                ("name", models.CharField(max_length=150)),
                (
                    "category",
                    models.CharField(
                        choices=[
                            ("asset", "Asset"),
                            ("liability", "Liability"),
                            ("equity", "Equity"),
                            ("revenue", "Revenue"),
                            ("expense", "Expense"),
                        ],
                        max_length=20,
                    ),
                ),
                ("description", models.TextField(blank=True, null=True)),
                ("is_system", models.BooleanField(default=False)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "currency",
                    models.IntegerField(
                        blank=True,
                        help_text="Currency this account tracks (null = base AFN)",
                        null=True,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["code"],
            },
        ),
        migrations.CreateModel(
            name="AccountingSettings",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "usd_to_afn_rate",
                    models.DecimalField(
                        decimal_places=6,
                        default=Decimal("87.20"),
                        help_text="1 USD equals this many AFN",
                        max_digits=18,
                    ),
                ),
                (
                    "fiscal_year_start_month",
                    models.PositiveSmallIntegerField(
                        default=3,
                        help_text="Month when fiscal year begins (1-12). Default 3 = March.",
                    ),
                ),
                (
                    "fiscal_year_start_day",
                    models.PositiveSmallIntegerField(
                        default=21,
                        help_text="Day when fiscal year begins. Default 21 (Hamal 1 approx.).",
                    ),
                ),
                ("is_configured", models.BooleanField(default=False)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "current_fiscal_year",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="api.fiscalyear",
                    ),
                ),
                (
                    "accounts_payable_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "accounts_receivable_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "accrued_expenses_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "accumulated_depreciation_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "bad_debt_expense_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "bank_account",
                    models.ForeignKey(
                        blank=True,
                        help_text="Primary bank account (separate from petty cash)",
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "bank_charges_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "cash_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "cogs_account",
                    models.ForeignKey(
                        blank=True,
                        help_text="Cost of Goods Sold account for inventory valuation",
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "depreciation_expense_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "employee_advance_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "equity_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "expense_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "fixed_asset_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "inventory_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "loan_payable_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "loan_receivable_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "opening_balance_equity_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "other_income_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "payroll_expense_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "petty_cash_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "prepaid_expense_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "purchase_discount_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "retained_earnings_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "sales_discount_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "sales_returns_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "sales_revenue_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "sales_tax_payable_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
                (
                    "stock_adjustment_account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="api.glaccount",
                    ),
                ),
            ],
            options={
                "verbose_name": "Accounting Settings",
                "verbose_name_plural": "Accounting Settings",
            },
        ),
        migrations.CreateModel(
            name="JournalEntry",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("entry_date", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("description", models.TextField(blank=True, null=True)),
                ("is_auto", models.BooleanField(default=True)),
                ("is_closing_entry", models.BooleanField(default=False)),
                ("object_id", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "fiscal_year",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="journal_entries",
                        to="api.fiscalyear",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Journal entries",
                "ordering": ["-entry_date", "-id"],
            },
        ),
        migrations.AddField(
            model_name="fiscalyear",
            name="closing_journal",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="+",
                to="api.journalentry",
            ),
        ),
        migrations.CreateModel(
            name="JournalLine",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")],
                        help_text="Native/transaction currency of this line",
                    ),
                ),
                (
                    "debit",
                    models.DecimalField(
                        decimal_places=2, default=Decimal("0"), max_digits=15
                    ),
                ),
                (
                    "credit",
                    models.DecimalField(
                        decimal_places=2, default=Decimal("0"), max_digits=15
                    ),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(
                        blank=True,
                        decimal_places=6,
                        help_text="Historical rate: 1 unit of line currency = this many AFN. AFN = 1.",
                        max_digits=18,
                        null=True,
                    ),
                ),
                (
                    "base_debit",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        help_text="AFN equivalent of debit at exchange_rate (reporting, not Cash AFN).",
                        max_digits=15,
                        null=True,
                    ),
                ),
                (
                    "base_credit",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        help_text="AFN equivalent of credit at exchange_rate (reporting, not Cash AFN).",
                        max_digits=15,
                        null=True,
                    ),
                ),
                (
                    "needs_rate_review",
                    models.BooleanField(
                        default=False,
                        help_text="True when historical rate/base could not be backfilled without inventing a rate.",
                    ),
                ),
                (
                    "description",
                    models.CharField(blank=True, max_length=255, null=True),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "gl_account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="journal_lines",
                        to="api.glaccount",
                    ),
                ),
                (
                    "journal_entry",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="lines",
                        to="api.journalentry",
                    ),
                ),
            ],
            options={
                "ordering": ["id"],
            },
        ),
        migrations.CreateModel(
            name="Loan",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "loaner_type",
                    models.CharField(
                        choices=[("customer", "Customer"), ("vendor", "Vendor")],
                        default="customer",
                        max_length=10,
                    ),
                ),
                ("amount", models.DecimalField(decimal_places=2, max_digits=15)),
                (
                    "amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "amount_paid",
                    models.DecimalField(
                        decimal_places=2, default=Decimal("0"), max_digits=15
                    ),
                ),
                (
                    "amount_paid_base",
                    models.DecimalField(
                        decimal_places=2, default=Decimal("0"), max_digits=15
                    ),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                (
                    "loan_type",
                    models.CharField(
                        choices=[
                            ("loan_in", "Loan Received"),
                            ("loan_out", "Loan Given"),
                        ],
                        max_length=10,
                    ),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "payment_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        help_text="Cash/bank/sarafi account that increases (loan in) or decreases (loan out). Ignored for opening balance.",
                        max_length=20,
                    ),
                ),
                ("loan_date", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "bill_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                (
                    "bill_file",
                    models.FileField(blank=True, null=True, upload_to="loan_bills/"),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "is_opening_balance",
                    models.BooleanField(
                        default=False,
                        help_text="Historical loan from before the system — no cash movement at creation.",
                    ),
                ),
                ("is_paid", models.BooleanField(default=False)),
                (
                    "customer",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="loans",
                        to="api.customer",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-loan_date"],
            },
        ),
        migrations.CreateModel(
            name="LoanPayment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("amount", models.DecimalField(decimal_places=2, max_digits=15)),
                (
                    "amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                (
                    "payment_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        help_text="Cash/bank/sarafi account used for this settlement.",
                        max_length=20,
                    ),
                ),
                (
                    "payment_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "loan",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="payments",
                        to="api.loan",
                    ),
                ),
            ],
            options={
                "ordering": ["-payment_date", "-id"],
            },
        ),
        migrations.CreateModel(
            name="Notification",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("title", models.CharField(max_length=200)),
                ("message", models.TextField()),
                (
                    "notification_type",
                    models.CharField(
                        choices=[
                            ("stock_expiry", "Stock Expiry"),
                            ("low_stock", "Low Stock"),
                            ("transfer", "Stock Transfer"),
                            ("general", "General"),
                        ],
                        default="general",
                        max_length=30,
                    ),
                ),
                ("is_read", models.BooleanField(default=False)),
                ("object_id", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        help_text="Null = visible to admins/superusers",
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notifications",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="Payment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("object_id", models.PositiveIntegerField()),
                (
                    "payment_type",
                    models.CharField(
                        choices=[
                            ("sale", "Sale Payment"),
                            ("purchase", "Purchase Payment"),
                        ],
                        max_length=20,
                    ),
                ),
                (
                    "payment_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                            ("intermediary_credit", "Intermediary Credit"),
                        ],
                        default="cash",
                        help_text="How money moved: cash, bank, or sarafi — selects the GL asset account",
                        max_length=20,
                    ),
                ),
                (
                    "payment_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("amount", models.DecimalField(decimal_places=2, max_digits=15)),
                (
                    "amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "intermediary_loan",
                    models.ForeignKey(
                        blank=True,
                        help_text="Linked payable loan created for intermediary credit payment.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="source_payments",
                        to="api.loan",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "Payments",
                "ordering": ["-payment_date", "-id"],
            },
        ),
        migrations.AddField(
            model_name="loan",
            name="source_payment",
            field=models.ForeignKey(
                blank=True,
                help_text="When set, this loan was created by an intermediary credit payment.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="generated_loans",
                to="api.payment",
            ),
        ),
        migrations.CreateModel(
            name="Payroll",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "payroll_type",
                    models.CharField(
                        choices=[("salary", "Salary"), ("advance", "Advance")],
                        default="salary",
                        max_length=20,
                    ),
                ),
                ("month", models.CharField(max_length=20)),
                ("year", models.PositiveIntegerField()),
                (
                    "amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "basic_salary",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "basic_salary_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "bonus",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "bonus_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "overtime",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "overtime_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                ("working_days", models.PositiveIntegerField(default=30)),
                ("deduction_days", models.PositiveIntegerField(default=0)),
                (
                    "deductions",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "deductions_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "net_salary",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "net_salary_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "payment_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                ("manual_net", models.BooleanField(default=False)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "employee",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="payrolls",
                        to="api.employee",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Permission",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=100, unique=True)),
                ("codename", models.CharField(max_length=100, unique=True)),
                ("description", models.TextField(blank=True, null=True)),
                ("module", models.CharField(max_length=50)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["module", "name"],
            },
        ),
        migrations.CreateModel(
            name="Product",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
                ("barcode", models.CharField(blank=True, max_length=100, null=True)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "image",
                    models.ImageField(blank=True, null=True, upload_to="products/"),
                ),
                (
                    "bottle_capacity_liters",
                    models.DecimalField(
                        blank=True,
                        decimal_places=4,
                        help_text="Liquid capacity of one bottle for packaged liquid products.",
                        max_digits=10,
                        null=True,
                    ),
                ),
                (
                    "carton_capacity_liters",
                    models.DecimalField(
                        blank=True,
                        decimal_places=4,
                        help_text="Liquid capacity of one carton for packaged liquid products.",
                        max_digits=12,
                        null=True,
                    ),
                ),
                (
                    "bottles_per_carton",
                    models.PositiveIntegerField(
                        default=8,
                        help_text="Number of bottles per carton for this product variant.",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="PackingRun",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "packing_number",
                    models.CharField(blank=True, max_length=40, unique=True),
                ),
                (
                    "quantity_liters",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                (
                    "bottle_volume_liters",
                    models.DecimalField(decimal_places=4, max_digits=8),
                ),
                ("bottle_count", models.PositiveIntegerField()),
                (
                    "liquid_cost_afn",
                    models.DecimalField(decimal_places=4, max_digits=15),
                ),
                (
                    "packaging_cost_afn",
                    models.DecimalField(decimal_places=4, max_digits=15),
                ),
                (
                    "total_cost_afn",
                    models.DecimalField(decimal_places=4, max_digits=15),
                ),
                (
                    "cost_per_bottle_afn",
                    models.DecimalField(decimal_places=6, max_digits=15),
                ),
                ("notes", models.TextField(blank=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "product",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="packing_runs",
                        to="api.product",
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at", "-id"],
            },
        ),
        migrations.CreateModel(
            name="InventoryBatch",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "batch_number",
                    models.CharField(
                        help_text="Unique batch identifier (auto-generated)",
                        max_length=50,
                        unique=True,
                    ),
                ),
                (
                    "condition",
                    models.CharField(
                        choices=[
                            ("good", "Good"),
                            ("damaged", "Damaged"),
                            ("waste", "Waste"),
                        ],
                        default="good",
                        help_text="Inventory condition for the batch",
                        max_length=20,
                    ),
                ),
                (
                    "cartons_received",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Cartons received in this batch",
                        max_digits=12,
                    ),
                ),
                (
                    "pieces_received",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Total pieces received (cartons_received × 8)",
                        max_digits=12,
                    ),
                ),
                (
                    "remaining_pieces",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Remaining pieces in this batch",
                        max_digits=12,
                    ),
                ),
                (
                    "unit_cost",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Cost per piece in AFN at time of receipt",
                        max_digits=12,
                    ),
                ),
                (
                    "currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")],
                        default=1,
                        help_text="Always AFN (1) for inventory batch costs",
                    ),
                ),
                (
                    "expire_date",
                    models.DateField(
                        blank=True,
                        db_index=True,
                        help_text="Expiration date for FEFO allocation",
                        null=True,
                    ),
                ),
                (
                    "manufacturing_date",
                    models.DateField(
                        blank=True, help_text="Optional manufacturing date", null=True
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("active", "Active"),
                            ("expired", "Expired"),
                            ("empty", "Empty"),
                            ("damaged", "Damaged"),
                            ("returned", "Returned"),
                        ],
                        db_index=True,
                        default="active",
                        help_text="Batch status",
                        max_length=20,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "product",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="inventory_batches",
                        to="api.product",
                    ),
                ),
            ],
            options={
                "ordering": ["expire_date", "created_at"],
            },
        ),
        migrations.CreateModel(
            name="RawMaterial",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
                (
                    "material_type",
                    models.CharField(
                        choices=[
                            ("bottle", "Bottle"),
                            ("cap", "Cap"),
                            ("label", "Label"),
                            ("plastic", "Plastic"),
                            ("carton", "Carton"),
                            ("chemistry", "Chemistry"),
                            ("other", "Other"),
                        ],
                        db_index=True,
                        default="chemistry",
                        max_length=20,
                    ),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "unit",
                    models.CharField(
                        choices=[("kg", "Kilogram"), ("piece", "Piece")],
                        default="kg",
                        help_text="Inventory unit used for purchases and stock.",
                        max_length=50,
                    ),
                ),
                (
                    "capacity_liters",
                    models.DecimalField(
                        blank=True,
                        decimal_places=4,
                        help_text="Bottle volume in liters. For plastic/carton this is the matching bottle size (same liters as the bottle they wrap/hold).",
                        max_digits=12,
                        null=True,
                    ),
                ),
                (
                    "bottles_per_carton",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="For carton materials: how many bottles fit in one carton.",
                        null=True,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="RawMaterialProcess",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "process_number",
                    models.CharField(blank=True, max_length=50, unique=True),
                ),
                ("product_name", models.CharField(max_length=255)),
                (
                    "process_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("in_process", "In Process"),
                            ("completed", "Completed"),
                            ("moved_to_storage", "Moved to Storage"),
                        ],
                        default="in_process",
                        max_length=24,
                    ),
                ),
                (
                    "output_quantity_liters",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                (
                    "water_quantity_liters",
                    models.DecimalField(decimal_places=4, default=0, max_digits=12),
                ),
                (
                    "extra_expense",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "expense_currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")], default=1
                    ),
                ),
                (
                    "material_cost_afn",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "extra_expense_afn",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "total_cost_afn",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "cost_per_liter_afn",
                    models.DecimalField(decimal_places=6, default=0, max_digits=18),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at", "-id"],
            },
        ),
        migrations.CreateModel(
            name="RawMaterialProcessItem",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("quantity", models.DecimalField(decimal_places=4, max_digits=12)),
                ("piece_count", models.PositiveIntegerField(default=0)),
                (
                    "material_cost_afn",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                ("purchase_sources", models.JSONField(default=list)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "process",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="items",
                        to="api.rawmaterialprocess",
                    ),
                ),
                (
                    "raw_material",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="process_items",
                        to="api.rawmaterial",
                    ),
                ),
            ],
            options={
                "ordering": ["id"],
            },
        ),
        migrations.CreateModel(
            name="RawMaterialPurchase",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "invoice_number",
                    models.CharField(blank=True, max_length=50, unique=True),
                ),
                (
                    "bill_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                (
                    "purchase_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "Draft"),
                            ("pending", "Pending"),
                            ("received", "Received"),
                            ("cancelled", "Cancelled"),
                        ],
                        default="draft",
                        max_length=20,
                    ),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "total_amount",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "total_amount_base",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Purchase total converted to AFN at the purchase-date exchange rate.",
                        max_digits=15,
                    ),
                ),
                (
                    "paid_amount",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "paid_amount_base",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Paid total converted to AFN from linked payment amount_base values.",
                        max_digits=15,
                    ),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(
                        decimal_places=6,
                        default=1,
                        help_text="Snapshot of Settings→Exchange Rates at purchase_date (1 purchase-currency = this many AFN). Not a separate rate table.",
                        max_digits=18,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-purchase_date", "-id"],
            },
        ),
        migrations.CreateModel(
            name="RawMaterialPurchaseItem",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "quantity",
                    models.DecimalField(
                        decimal_places=4,
                        help_text="Quantity in the raw material unit",
                        max_digits=12,
                    ),
                ),
                (
                    "piece_count",
                    models.PositiveIntegerField(
                        default=0,
                        help_text="Additional piece or package count for kilogram-based materials",
                    ),
                ),
                (
                    "price_per_unit",
                    models.DecimalField(
                        decimal_places=4, help_text="Price per unit", max_digits=12
                    ),
                ),
                (
                    "total_price",
                    models.DecimalField(
                        decimal_places=4,
                        help_text="Total price (quantity × price per unit)",
                        max_digits=15,
                    ),
                ),
                (
                    "price_per_unit_base",
                    models.DecimalField(
                        decimal_places=6,
                        default=0,
                        help_text="Unit price converted to AFN at the purchase-date exchange rate.",
                        max_digits=18,
                    ),
                ),
                (
                    "total_price_base",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Line total converted to AFN at the purchase-date exchange rate.",
                        max_digits=15,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "purchase",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="items",
                        to="api.rawmaterialpurchase",
                    ),
                ),
                (
                    "raw_material",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="purchase_items",
                        to="api.rawmaterial",
                    ),
                ),
            ],
            options={
                "ordering": ["id"],
            },
        ),
        migrations.CreateModel(
            name="RawMaterialStock",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "quantity",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Current stock quantity in the raw material unit",
                        max_digits=12,
                    ),
                ),
                (
                    "piece_count",
                    models.PositiveIntegerField(
                        default=0,
                        help_text="Additional piece or package count for kilogram-based materials",
                    ),
                ),
                (
                    "last_purchase_price",
                    models.DecimalField(
                        decimal_places=6,
                        default=0,
                        help_text="Last purchase price per unit in AFN only. Converted from the purchase currency using the purchase-date exchange rate.",
                        max_digits=18,
                    ),
                ),
                ("last_purchase_date", models.DateField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "raw_material",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="stocks",
                        to="api.rawmaterial",
                    ),
                ),
            ],
            options={
                "ordering": ["raw_material__name"],
            },
        ),
        migrations.CreateModel(
            name="Sales",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "invoice_number",
                    models.CharField(blank=True, max_length=50, unique=True),
                ),
                ("sale_date", models.DateTimeField(default=django.utils.timezone.now)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "Draft"),
                            ("confirmed", "Confirmed"),
                            ("shipped", "Shipped"),
                            ("delivered", "Delivered"),
                            ("invoiced", "Invoiced"),
                            ("cancelled", "Cancelled"),
                        ],
                        default="draft",
                        max_length=20,
                    ),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "discount_percentage",
                    models.DecimalField(decimal_places=2, default=0, max_digits=5),
                ),
                ("total_amount", models.DecimalField(decimal_places=4, max_digits=15)),
                (
                    "total_amount_base",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "paid_amount",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "paid_amount_base",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(
                        decimal_places=6,
                        default=1,
                        help_text="Snapshot of Settings→Exchange Rates at sale_date (1 sale-currency = this many AFN). Not a separate rate table.",
                        max_digits=18,
                    ),
                ),
                (
                    "plate_number",
                    models.CharField(
                        blank=True,
                        help_text="Vehicle plate number (پلیټ نمبر)",
                        max_length=50,
                        null=True,
                    ),
                ),
                ("notes", models.CharField(blank=True, max_length=255, null=True)),
                (
                    "customer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sales",
                        to="api.customer",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Return",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "return_number",
                    models.CharField(blank=True, max_length=50, unique=True),
                ),
                (
                    "return_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                ("reason", models.CharField(blank=True, max_length=200, null=True)),
                (
                    "currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")], default=1
                    ),
                ),
                (
                    "total_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "total_amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "refund_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "refund_amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                ("notes", models.CharField(blank=True, max_length=255, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "sales",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="returns",
                        to="api.sales",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="SalesItems",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "sale_source",
                    models.CharField(
                        choices=[("stock", "Packed stock"), ("tank", "Tank fill")],
                        db_index=True,
                        default="stock",
                        help_text="stock = packed inventory; tank = bulk fill from storage tank",
                        max_length=16,
                    ),
                ),
                (
                    "unit",
                    models.CharField(
                        choices=[
                            ("carton", "Carton"),
                            ("bottle", "Bottle"),
                            ("plastic", "Plastic"),
                            ("dana", "Dana"),
                            ("liter", "Liter"),
                        ],
                        default="carton",
                        help_text="carton/dana for stock sales; liter for tank fills",
                        max_length=10,
                    ),
                ),
                (
                    "quantity",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Quantity in the selected unit (cartons, pieces, or liters)",
                        max_digits=12,
                    ),
                ),
                (
                    "liter_amount",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="For stock lines: piece equivalent. For tank lines: liters sold.",
                        max_digits=12,
                    ),
                ),
                (
                    "sell_price",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Price per selected unit (carton, piece, or liter)",
                        max_digits=12,
                    ),
                ),
                (
                    "unit_cost",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Inventory cost per piece (stock) or per liter (tank) in AFN",
                        max_digits=12,
                    ),
                ),
                (
                    "commission_amount",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Commission per selected unit (carton, bottle, plastic, or liter) always in AFN.",
                        max_digits=12,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "sales",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="sales_items",
                        to="api.sales",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="SaleBatchAllocation",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "quantity",
                    models.DecimalField(
                        decimal_places=4,
                        help_text="Quantity of pieces allocated from this batch",
                        max_digits=12,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "inventory_batch",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sale_allocations",
                        to="api.inventorybatch",
                    ),
                ),
                (
                    "sale",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="batch_allocations",
                        to="api.sales",
                    ),
                ),
                (
                    "sale_item",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="batch_allocations",
                        to="api.salesitems",
                    ),
                ),
            ],
            options={
                "ordering": ["inventory_batch__expire_date"],
            },
        ),
        migrations.CreateModel(
            name="ReturnItems",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "liter_amount",
                    models.DecimalField(decimal_places=3, default=0, max_digits=12),
                ),
                (
                    "return_price",
                    models.DecimalField(decimal_places=2, default=0, max_digits=12),
                ),
                (
                    "return_amount",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "return_order",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="return_items",
                        to="api.return",
                    ),
                ),
                (
                    "sales_item",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="api.salesitems"
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Salesman",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("code", models.CharField(blank=True, max_length=50, unique=True)),
                ("name", models.CharField(max_length=255)),
                ("phone", models.CharField(blank=True, max_length=20, null=True)),
                ("email", models.EmailField(blank=True, max_length=255, null=True)),
                ("address", models.CharField(blank=True, max_length=255, null=True)),
                ("is_active", models.BooleanField(default=True)),
                ("notes", models.CharField(blank=True, max_length=255, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        migrations.AddField(
            model_name="sales",
            name="salesman",
            field=models.ForeignKey(
                blank=True,
                help_text="Optional salesman who earns commission on this sale.",
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="sales",
                to="api.salesman",
            ),
        ),
        migrations.CreateModel(
            name="SalesmanCommissionPayment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "payment_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "payment_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        help_text="Cash book credited when the commission is paid",
                        max_length=20,
                    ),
                ),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2,
                        help_text="Payment amount in AFN",
                        max_digits=15,
                    ),
                ),
                (
                    "amount_base",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="AFN amount (same as amount; commission is always AFN).",
                        max_digits=15,
                    ),
                ),
                (
                    "currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")],
                        default=1,
                        help_text="Always AFN for commission payments.",
                    ),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "salesman",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="commission_payments",
                        to="api.salesman",
                    ),
                ),
            ],
            options={
                "verbose_name": "Salesman commission payment",
                "verbose_name_plural": "Salesman commission payments",
                "ordering": ["-payment_date", "-id"],
            },
        ),
        migrations.CreateModel(
            name="Stock",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "condition",
                    models.CharField(
                        choices=[
                            ("good", "Good"),
                            ("damaged", "Damaged"),
                            ("waste", "Waste"),
                        ],
                        db_index=True,
                        default="good",
                        help_text="Good, damaged, or waste — same product can have separate lots per condition",
                        max_length=20,
                    ),
                ),
                (
                    "piece_amount",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Canonical quantity in pieces. 1 carton = 8 pieces.",
                        max_digits=12,
                    ),
                ),
                (
                    "buy_price",
                    models.DecimalField(
                        decimal_places=2,
                        default=0,
                        help_text="Unit buy price in AFN (packed stock cost from packing/production)",
                        max_digits=12,
                    ),
                ),
                (
                    "currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")],
                        default=1,
                        help_text="Always AFN (1) for finished-goods stock costs",
                    ),
                ),
                (
                    "expire_date",
                    models.DateField(
                        blank=True,
                        help_text="Optional expiry date for notification alerts",
                        null=True,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "product",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="api.product"
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="salesitems",
            name="stock",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="sales_items",
                to="api.stock",
            ),
        ),
        migrations.CreateModel(
            name="PackingRunComponent",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "component_type",
                    models.CharField(
                        choices=[
                            ("bottle", "Bottle"),
                            ("cap", "Cap"),
                            ("label", "Label"),
                            ("plastic", "Plastic"),
                            ("carton", "Carton"),
                        ],
                        max_length=12,
                    ),
                ),
                (
                    "quantity_pieces",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                ("unit_cost_afn", models.DecimalField(decimal_places=6, max_digits=15)),
                (
                    "total_cost_afn",
                    models.DecimalField(decimal_places=4, max_digits=15),
                ),
                ("inventory_allocations", models.JSONField(default=list)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "packing_run",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="components",
                        to="api.packingrun",
                    ),
                ),
                (
                    "raw_material_stock",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="packing_run_components",
                        to="api.rawmaterialstock",
                    ),
                ),
                (
                    "stock",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="packing_consumptions",
                        to="api.stock",
                    ),
                ),
            ],
            options={
                "ordering": ["id"],
            },
        ),
        migrations.AddField(
            model_name="packingrun",
            name="finished_stock",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="packing_runs",
                to="api.stock",
            ),
        ),
        migrations.CreateModel(
            name="StockAdjustment",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "adjustment_type",
                    models.CharField(
                        choices=[
                            ("expired", "Expired"),
                            ("damaged", "Damaged"),
                            ("lost", "Lost"),
                            ("manual_correction", "Manual Correction"),
                            ("returned", "Returned"),
                            ("transfer", "Transfer"),
                        ],
                        max_length=30,
                    ),
                ),
                (
                    "quantity_before",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                (
                    "quantity_after",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                (
                    "quantity_change",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                ("reason", models.TextField(blank=True, null=True)),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=50, null=True),
                ),
                (
                    "adjustment_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "adjusted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="stock_adjustments",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "inventory_batch",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="adjustments",
                        to="api.inventorybatch",
                    ),
                ),
            ],
            options={
                "ordering": ["-adjustment_date"],
            },
        ),
        migrations.CreateModel(
            name="StockTransfer",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("transfer_number", models.CharField(max_length=50, unique=True)),
                (
                    "condition",
                    models.CharField(
                        choices=[
                            ("good", "Good"),
                            ("damaged", "Damaged"),
                            ("waste", "Waste"),
                        ],
                        default="good",
                        max_length=20,
                    ),
                ),
                (
                    "reason",
                    models.CharField(
                        choices=[
                            ("expired", "Expired"),
                            ("damaged", "Damaged"),
                            ("other", "Other"),
                        ],
                        default="other",
                        max_length=20,
                    ),
                ),
                ("piece_amount", models.DecimalField(decimal_places=4, max_digits=12)),
                (
                    "unit_cost",
                    models.DecimalField(decimal_places=4, default=0, max_digits=12),
                ),
                (
                    "currency",
                    models.IntegerField(
                        choices=[(1, "AFN"), (2, "USD"), (3, "KDR")], default=1
                    ),
                ),
                (
                    "total_value",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "transfer_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[("completed", "Completed")],
                        default="completed",
                        max_length=20,
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "product",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="stock_transfers_from",
                        to="api.product",
                    ),
                ),
                (
                    "source_batch",
                    models.ForeignKey(
                        blank=True,
                        help_text="Primary source batch when a single batch was selected",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="transfers_out",
                        to="api.inventorybatch",
                    ),
                ),
                (
                    "source_stock",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="transfers_out",
                        to="api.stock",
                    ),
                ),
                (
                    "target_product",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="stock_transfers_to",
                        to="api.product",
                    ),
                ),
                (
                    "target_stock",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="transfers_in",
                        to="api.stock",
                    ),
                ),
                (
                    "transferred_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="stock_transfers",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-transfer_date", "-id"],
            },
        ),
        migrations.CreateModel(
            name="StorageTank",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255, unique=True)),
                (
                    "capacity_liters",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["name", "id"],
            },
        ),
        migrations.AddField(
            model_name="salesitems",
            name="storage_tank",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="sales_items",
                to="api.storagetank",
            ),
        ),
        migrations.CreateModel(
            name="ProductionStorageTransfer",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "quantity_liters",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "production",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="storage_transfers",
                        to="api.rawmaterialprocess",
                    ),
                ),
                (
                    "storage_tank",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="production_transfers",
                        to="api.storagetank",
                    ),
                ),
            ],
            options={
                "ordering": ["id"],
            },
        ),
        migrations.AddField(
            model_name="packingrun",
            name="storage_tank",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="packing_runs",
                to="api.storagetank",
            ),
        ),
        migrations.CreateModel(
            name="UserPermission",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("granted", models.BooleanField(default=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "permission",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="api.permission"
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="user_permissions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Vendor",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("code", models.CharField(blank=True, max_length=50, unique=True)),
                ("name", models.CharField(max_length=255)),
                ("phone", models.CharField(blank=True, max_length=20, null=True)),
                ("email", models.EmailField(blank=True, max_length=255, null=True)),
                ("address", models.CharField(blank=True, max_length=255, null=True)),
                ("is_active", models.BooleanField(default=True)),
                (
                    "is_intermediary",
                    models.BooleanField(
                        default=False,
                        help_text="Sarafi/bank party used to pay goods vendors on our behalf (not a goods supplier).",
                    ),
                ),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="rawmaterialpurchase",
            name="vendor",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="raw_material_purchases",
                to="api.vendor",
            ),
        ),
        migrations.AddField(
            model_name="payment",
            name="intermediary_vendor",
            field=models.ForeignKey(
                blank=True,
                help_text="Intermediary (sarafi/bank) that paid on our behalf.",
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="intermediary_payments",
                to="api.vendor",
            ),
        ),
        migrations.CreateModel(
            name="PackingBreakage",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "breakage_number",
                    models.CharField(blank=True, max_length=40, unique=True),
                ),
                ("broken_bottle_count", models.PositiveIntegerField()),
                (
                    "liquid_liters_returned",
                    models.DecimalField(decimal_places=4, max_digits=12),
                ),
                (
                    "liquid_cost_afn",
                    models.DecimalField(decimal_places=4, default=0, max_digits=15),
                ),
                (
                    "bottle_return_value_afn",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="AP credit for bottles returned to vendor",
                        max_digits=15,
                    ),
                ),
                (
                    "scrap_cost_afn",
                    models.DecimalField(
                        decimal_places=4,
                        default=0,
                        help_text="Label + cap (+ plastic/carton share) written off as waste",
                        max_digits=15,
                    ),
                ),
                (
                    "finished_stock_reduced",
                    models.DecimalField(decimal_places=4, default=0, max_digits=12),
                ),
                (
                    "scrap_details",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Per-component scrap qty/cost breakdown",
                    ),
                ),
                ("notes", models.TextField(blank=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "packing_run",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="breakages",
                        to="api.packingrun",
                    ),
                ),
                (
                    "bottle_purchase_item",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="packing_breakage_returns",
                        to="api.rawmaterialpurchaseitem",
                    ),
                ),
                (
                    "storage_tank",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="packing_breakages",
                        to="api.storagetank",
                    ),
                ),
                (
                    "bottle_vendor",
                    models.ForeignKey(
                        blank=True,
                        help_text="Vendor who supplied the bottle raw material",
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="packing_breakage_returns",
                        to="api.vendor",
                    ),
                ),
            ],
            options={
                "ordering": ["-created_at", "-id"],
            },
        ),
        migrations.AddField(
            model_name="loan",
            name="vendor",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="loans",
                to="api.vendor",
            ),
        ),
        migrations.AddField(
            model_name="inventorybatch",
            name="supplier",
            field=models.ForeignKey(
                blank=True,
                help_text="Supplier for this batch (optional)",
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="inventory_batches",
                to="api.vendor",
            ),
        ),
        migrations.CreateModel(
            name="Withdrawal",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "deleted_at",
                    models.DateTimeField(blank=True, db_index=True, null=True),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "payment_method",
                    models.CharField(
                        choices=[
                            ("cash", "Cash"),
                            ("bank", "Bank"),
                            ("sarafi", "Sarafi"),
                        ],
                        default="cash",
                        help_text="Derived from gl_account.code for reports / cash-out sections",
                        max_length=20,
                    ),
                ),
                ("amount", models.DecimalField(decimal_places=2, max_digits=15)),
                (
                    "amount_base",
                    models.DecimalField(decimal_places=2, default=0, max_digits=15),
                ),
                (
                    "exchange_rate",
                    models.DecimalField(decimal_places=6, default=1, max_digits=18),
                ),
                (
                    "currency",
                    models.IntegerField(choices=[(1, "AFN"), (2, "USD"), (3, "KDR")]),
                ),
                (
                    "withdrawal_date",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "reference_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "deleted_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "gl_account",
                    models.ForeignKey(
                        help_text="Exact Cash / Bank / Sarafi GL account money is taken from",
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="withdrawals",
                        to="api.glaccount",
                    ),
                ),
                (
                    "recorded_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="recorded_withdrawals",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-withdrawal_date", "-id"],
            },
        ),
        migrations.AddConstraint(
            model_name="account",
            constraint=models.UniqueConstraint(
                fields=("account_number",), name="uniq_account_number"
            ),
        ),
        migrations.AddIndex(
            model_name="activitylog",
            index=models.Index(
                fields=["-created_at"], name="api_activit_created_011954_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="activitylog",
            index=models.Index(
                fields=["user", "-created_at"], name="api_activit_user_id_29f0f8_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="activitylog",
            index=models.Index(
                fields=["action", "-created_at"], name="api_activit_action_35dd86_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="attacheddocument",
            index=models.Index(
                fields=["content_type", "object_id"],
                name="api_attache_content_9a1f81_idx",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="attendance",
            unique_together={("employee", "date")},
        ),
        migrations.AddIndex(
            model_name="exchangerate",
            index=models.Index(
                fields=["from_currency", "to_currency", "date"],
                name="api_exchang_from_cu_160948_idx",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="exchangerate",
            unique_together={("from_currency", "to_currency", "date")},
        ),
        migrations.AddIndex(
            model_name="equipment",
            index=models.Index(fields=["status"], name="api_equipme_status_26dd77_idx"),
        ),
        migrations.AddIndex(
            model_name="equipment",
            index=models.Index(
                fields=["is_active"], name="api_equipme_is_acti_00f092_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="equipment",
            index=models.Index(
                fields=["acquisition_type"], name="api_equipme_acquisi_4bae28_idx"
            ),
        ),
        migrations.AddConstraint(
            model_name="fxrevaluation",
            constraint=models.UniqueConstraint(
                fields=("as_of_date",), name="uniq_fx_revaluation_as_of"
            ),
        ),
        migrations.AddConstraint(
            model_name="glaccount",
            constraint=models.UniqueConstraint(
                fields=("currency", "code"), name="uniq_gl_account_currency_code"
            ),
        ),
        migrations.AddIndex(
            model_name="journalentry",
            index=models.Index(fields=["entry_date"], name="api_je_date_idx"),
        ),
        migrations.AddIndex(
            model_name="journalentry",
            index=models.Index(
                fields=["content_type", "object_id"], name="api_je_content_idx"
            ),
        ),
        migrations.AddConstraint(
            model_name="fiscalyear",
            constraint=models.UniqueConstraint(
                fields=("start_date", "end_date"), name="unique_fiscal_year_range"
            ),
        ),
        migrations.AddIndex(
            model_name="journalline",
            index=models.Index(fields=["currency"], name="api_jl_currency_idx"),
        ),
        migrations.AddIndex(
            model_name="journalline",
            index=models.Index(
                fields=["gl_account", "currency"], name="api_jl_gl_currency_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="journalline",
            index=models.Index(
                fields=["needs_rate_review"], name="api_jl_rate_review_idx"
            ),
        ),
        migrations.AddConstraint(
            model_name="journalline",
            constraint=models.CheckConstraint(
                condition=models.Q(("debit__gte", 0), ("credit__gte", 0)),
                name="journalline_debit_credit_nonnegative",
            ),
        ),
        migrations.AddConstraint(
            model_name="journalline",
            constraint=models.CheckConstraint(
                condition=models.Q(("debit__gt", 0), ("credit__gt", 0), _negated=True),
                name="journalline_not_both_debit_and_credit",
            ),
        ),
        migrations.AddConstraint(
            model_name="payroll",
            constraint=models.UniqueConstraint(
                fields=("employee", "month", "year", "payroll_type"),
                name="uniq_payroll_employee_period_type",
            ),
        ),
        migrations.AddConstraint(
            model_name="product",
            constraint=models.UniqueConstraint(
                condition=models.Q(
                    ("barcode__isnull", False), models.Q(("barcode", ""), _negated=True)
                ),
                fields=("barcode",),
                name="uniq_product_barcode",
            ),
        ),
        migrations.AddConstraint(
            model_name="rawmaterial",
            constraint=models.UniqueConstraint(
                fields=("name",), name="uniq_raw_material_name"
            ),
        ),
        migrations.AlterUniqueTogether(
            name="rawmaterialstock",
            unique_together={("raw_material",)},
        ),
        migrations.AlterUniqueTogether(
            name="salebatchallocation",
            unique_together={("sale_item", "inventory_batch")},
        ),
        migrations.AlterUniqueTogether(
            name="stock",
            unique_together={("product", "condition")},
        ),
        migrations.AddConstraint(
            model_name="packingruncomponent",
            constraint=models.UniqueConstraint(
                fields=("packing_run", "component_type"),
                name="uniq_packing_run_component_type",
            ),
        ),
        migrations.AddIndex(
            model_name="stockadjustment",
            index=models.Index(
                fields=["inventory_batch", "adjustment_type"],
                name="api_stockad_invento_0e9015_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="stockadjustment",
            index=models.Index(
                fields=["adjustment_date"], name="api_stockad_adjustm_767da8_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="stockadjustment",
            index=models.Index(
                fields=["adjustment_type"], name="api_stockad_adjustm_107024_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="stocktransfer",
            index=models.Index(
                fields=["transfer_date"], name="api_stocktr_transfe_a6e19c_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="stocktransfer",
            index=models.Index(fields=["reason"], name="api_stocktr_reason_23b7ab_idx"),
        ),
        migrations.AddConstraint(
            model_name="salesitems",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(
                        ("sale_source", "stock"),
                        ("stock__isnull", False),
                        ("storage_tank__isnull", True),
                    ),
                    models.Q(
                        ("sale_source", "tank"),
                        ("stock__isnull", True),
                        ("storage_tank__isnull", False),
                    ),
                    _connector="OR",
                ),
                name="salesitems_source_stock_xor_tank",
            ),
        ),
        migrations.AddConstraint(
            model_name="productionstoragetransfer",
            constraint=models.UniqueConstraint(
                fields=("production", "storage_tank"),
                name="uniq_production_storage_tank_transfer",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="userpermission",
            unique_together={("user", "permission")},
        ),
        migrations.AddIndex(
            model_name="inventorybatch",
            index=models.Index(
                fields=["product", "status"], name="api_invento_product_e0fa05_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="inventorybatch",
            index=models.Index(
                fields=["expire_date", "status"], name="api_invento_expire__55d85d_idx"
            ),
        ),
    ]
