# Generated by Django 6.0.4 on 2026-06-08 06:07

import apps.asset_management.models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('asset_management', '0002_initial'),
        ('procurements', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='StockItem',
            fields=[
                ('id', models.UUIDField(default=apps.asset_management.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('sku', models.CharField(blank=True, max_length=100, unique=True)),
                ('unit', models.CharField(default='unit', max_length=30)),
                ('reorder_point', models.PositiveIntegerField(default=0)),
                ('unit_cost', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_items', to='asset_management.assetcategory')),
                ('vendor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_items', to='asset_management.vendor')),
            ],
            options={
                'db_table': 'stock_items',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='License',
            fields=[
                ('id', models.UUIDField(default=apps.asset_management.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('license_key', models.CharField(blank=True, max_length=255)),
                ('seats', models.PositiveIntegerField(default=1)),
                ('cost_per_period', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('period', models.CharField(choices=[('monthly', 'Monthly'), ('quarterly', 'Quarterly'), ('annual', 'Annual'), ('perpetual', 'Perpetual')], default='annual', max_length=20)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('renewal_date', models.DateField(blank=True, db_index=True, null=True)),
                ('auto_renew', models.BooleanField(default=False)),
                ('status', models.CharField(choices=[('active', 'Active'), ('expiring', 'Expiring'), ('expired', 'Expired'), ('cancelled', 'Cancelled')], default='active', max_length=20)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('goods_receipt', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='licenses', to='procurements.goodsreceipt')),
                ('purchase_order', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='licenses', to='procurements.purchaseorder')),
                ('vendor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='licenses', to='asset_management.vendor')),
            ],
            options={
                'db_table': 'licenses',
                'ordering': ['renewal_date', 'name'],
                'indexes': [models.Index(fields=['status', 'renewal_date'], name='licenses_status_794b94_idx')],
            },
        ),
        migrations.CreateModel(
            name='Rental',
            fields=[
                ('id', models.UUIDField(default=apps.asset_management.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=255)),
                ('quantity', models.PositiveIntegerField(default=1)),
                ('rental_cost', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('deposit', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('return_date', models.DateField(blank=True, db_index=True, null=True)),
                ('returned_at', models.DateField(blank=True, null=True)),
                ('returned_condition', models.CharField(blank=True, choices=[('good', 'Good'), ('damaged', 'Damaged'), ('lost', 'Lost')], max_length=20)),
                ('status', models.CharField(choices=[('active', 'Active'), ('overdue', 'Overdue'), ('returned', 'Returned')], default='active', max_length=20)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('goods_receipt', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rentals', to='procurements.goodsreceipt')),
                ('location', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rentals', to='asset_management.assetlocation')),
                ('purchase_order', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rentals', to='procurements.purchaseorder')),
                ('vendor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='rentals', to='asset_management.vendor')),
            ],
            options={
                'db_table': 'rentals',
                'ordering': ['return_date', 'name'],
                'indexes': [models.Index(fields=['status', 'return_date'], name='rentals_status_54bb1c_idx')],
            },
        ),
        migrations.CreateModel(
            name='StockLevel',
            fields=[
                ('id', models.UUIDField(default=apps.asset_management.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('quantity', models.IntegerField(default=0)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='levels', to='asset_management.stockitem')),
                ('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_levels', to='asset_management.assetlocation')),
            ],
            options={
                'db_table': 'stock_levels',
                'ordering': ['item__name'],
                'constraints': [models.UniqueConstraint(fields=('item', 'location'), name='uniq_stock_item_location')],
            },
        ),
        migrations.CreateModel(
            name='StockMovement',
            fields=[
                ('id', models.UUIDField(default=apps.asset_management.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('movement_type', models.CharField(choices=[('in', 'Stock In'), ('out', 'Stock Out'), ('adjust', 'Adjustment'), ('transfer', 'Transfer')], max_length=20)),
                ('quantity', models.IntegerField(help_text='Positive for in/transfer-in, negative for out.')),
                ('reason', models.CharField(blank=True, max_length=255)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('goods_receipt', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_movements', to='procurements.goodsreceipt')),
                ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='movements', to='asset_management.stockitem')),
                ('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_movements', to='asset_management.assetlocation')),
                ('performed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='stock_movements', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'stock_movements',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['item', 'location', '-created_at'], name='stock_movem_item_id_a517fd_idx')],
            },
        ),
    ]
