# Generated by Django 5.2.10 on 2026-01-24 16:32

import _socket
import django.db.models.deletion
import django.utils.timezone
import django_audit_fields.fields.hostname_modification_field
import django_audit_fields.fields.userfield
import django_audit_fields.fields.uuid_auto_field
import django_revision.revision_field
from decimal import Decimal
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("edc_pharmacy", "0112_historicalstock_container_qty_stock_container_qty"),
    ]

    operations = [
        migrations.AlterField(
            model_name="historicalstock",
            name="container_qty",
            field=models.DecimalField(
                decimal_places=2,
                help_text="Number of units per container. ",
                max_digits=20,
                null=True,
                verbose_name="Units per container",
            ),
        ),
        migrations.AlterField(
            model_name="stock",
            name="container_qty",
            field=models.DecimalField(
                decimal_places=2,
                help_text="Number of units per container. ",
                max_digits=20,
                null=True,
                verbose_name="Units per container",
            ),
        ),
        migrations.CreateModel(
            name="StockTransactionType",
            fields=[
                (
                    "name",
                    models.CharField(
                        help_text="This is the stored value, required",
                        max_length=250,
                        unique=True,
                        verbose_name="Stored value",
                    ),
                ),
                (
                    "plural_name",
                    models.CharField(
                        default="", max_length=250, verbose_name="Plural name"
                    ),
                ),
                (
                    "display_name",
                    models.CharField(
                        help_text="(suggest 40 characters max.)",
                        max_length=250,
                        unique=True,
                        verbose_name="Name",
                    ),
                ),
                (
                    "display_index",
                    models.IntegerField(
                        default=0,
                        help_text="Index to control display order if not alphabetical, not required",
                        verbose_name="display index",
                    ),
                ),
                (
                    "field_name",
                    models.CharField(
                        blank=True,
                        default="",
                        editable=False,
                        help_text="Not required",
                        max_length=25,
                    ),
                ),
                ("extra_value", models.CharField(default="", max_length=250)),
                (
                    "version",
                    models.CharField(default="1.0", editable=False, max_length=35),
                ),
                ("id", models.AutoField(primary_key=True, serialize=False)),
            ],
            options={
                "verbose_name": "Stock transaction type",
                "verbose_name_plural": "Stock transaction types",
                "abstract": False,
                "default_permissions": (
                    "add",
                    "change",
                    "delete",
                    "view",
                    "export",
                    "import",
                ),
                "indexes": [
                    models.Index(
                        fields=["display_index", "display_name"],
                        name="edc_pharmac_display_46f88a_idx",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="StockTransaction",
            fields=[
                (
                    "revision",
                    django_revision.revision_field.RevisionField(
                        blank=True,
                        default="",
                        editable=False,
                        help_text="System field. From git repository (tag:branch:commit), project metadata, project toml, project VERSION, or settings.",
                        max_length=75,
                        verbose_name="Revision",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(blank=True, default=django.utils.timezone.now),
                ),
                (
                    "modified",
                    models.DateTimeField(blank=True, default=django.utils.timezone.now),
                ),
                (
                    "user_created",
                    django_audit_fields.fields.userfield.UserField(
                        blank=True,
                        default="",
                        help_text="Updated by admin.save_model",
                        max_length=50,
                        verbose_name="user created",
                    ),
                ),
                (
                    "user_modified",
                    django_audit_fields.fields.userfield.UserField(
                        blank=True,
                        default="",
                        help_text="Updated by admin.save_model",
                        max_length=50,
                        verbose_name="user modified",
                    ),
                ),
                (
                    "hostname_created",
                    models.CharField(
                        blank=True,
                        default=_socket.gethostname,
                        help_text="System field. (modified on create only)",
                        max_length=60,
                        verbose_name="Hostname created",
                    ),
                ),
                (
                    "hostname_modified",
                    django_audit_fields.fields.hostname_modification_field.HostnameModificationField(
                        blank=True,
                        default="",
                        help_text="System field. (modified on every save)",
                        max_length=50,
                        verbose_name="Hostname modified",
                    ),
                ),
                (
                    "device_created",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=10,
                        verbose_name="Device created",
                    ),
                ),
                (
                    "device_modified",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=10,
                        verbose_name="Device modified",
                    ),
                ),
                (
                    "locale_created",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Auto-updated by Modeladmin",
                        max_length=10,
                        verbose_name="Locale created",
                    ),
                ),
                (
                    "locale_modified",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Auto-updated by Modeladmin",
                        max_length=10,
                        verbose_name="Locale modified",
                    ),
                ),
                (
                    "id",
                    django_audit_fields.fields.uuid_auto_field.UUIDAutoField(
                        blank=True,
                        editable=False,
                        help_text="System auto field. UUID primary key.",
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "transaction_datetime",
                    models.DateTimeField(default=django.utils.timezone.now),
                ),
                (
                    "transaction_qty",
                    models.DecimalField(
                        decimal_places=2, default=Decimal("0.0"), max_digits=20
                    ),
                ),
                (
                    "balance",
                    models.DecimalField(
                        decimal_places=2, default=Decimal("0.0"), max_digits=20
                    ),
                ),
                (
                    "stock",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="edc_pharmacy.stock",
                    ),
                ),
                (
                    "transaction_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="edc_pharmacy.stocktransactiontype",
                    ),
                ),
            ],
            options={
                "verbose_name": "Stock transaction",
                "verbose_name_plural": "Stock transactions",
                "abstract": False,
                "default_permissions": (
                    "add",
                    "change",
                    "delete",
                    "view",
                    "export",
                    "import",
                ),
                "default_manager_name": "objects",
                "indexes": [
                    models.Index(
                        fields=["modified", "created"],
                        name="edc_pharmac_modifie_69d29d_idx",
                    ),
                    models.Index(
                        fields=["user_modified", "user_created"],
                        name="edc_pharmac_user_mo_01143b_idx",
                    ),
                ],
            },
        ),
    ]
