# Generated by Django 5.2.19 on 2026-11-29 09:32

import uuid
from decimal import Decimal
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='GoodsReceiptLine',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('received_qty', models.DecimalField(decimal_places=3, max_digits=14)),
                ('accepted_qty', models.DecimalField(decimal_places=3, max_digits=14)),
                ('rejected_qty', models.DecimalField(decimal_places=3, default=Decimal('0.000'), max_digits=14)),
                ('unit_rate', models.DecimalField(decimal_places=2, max_digits=14)),
                ('amount', models.DecimalField(decimal_places=2, max_digits=18)),
                ('batch_no', models.CharField(blank=True, max_length=48)),
                ('serial_no', models.CharField(blank=True, max_length=64)),
                ('expiry_date', models.DateField(blank=True, null=True)),
            ],
            options={
                'db_table': 'grn_lines',
            },
        ),
        migrations.CreateModel(
            name='GoodsReceiptNote',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('grn_number', models.CharField(max_length=40)),
                ('grn_date', models.DateField(db_index=True)),
                ('bs_date', models.CharField(blank=True, max_length=16)),
                ('challan_no', models.CharField(blank=True, max_length=64)),
                ('total_amount', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('INSPECTED', 'Quality Inspected'), ('APPROVED', 'Approved & Stocked'), ('CANCELLED', 'Cancelled')], db_index=True, default='DRAFT', max_length=16)),
                ('remarks', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'grn_records',
                'ordering': ['-grn_date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='ItemCategory',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('code', models.CharField(max_length=24)),
                ('name', models.CharField(max_length=120)),
                ('is_active', models.BooleanField(default=True)),
            ],
            options={
                'db_table': 'item_categories',
                'ordering': ['code'],
            },
        ),
        migrations.CreateModel(
            name='ItemMaster',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('item_code', models.CharField(max_length=40)),
                ('name', models.CharField(max_length=200)),
                ('description', models.CharField(blank=True, max_length=255)),
                ('brand', models.CharField(blank=True, max_length=80)),
                ('conversion_factor', models.DecimalField(decimal_places=4, default=Decimal('1.0000'), max_digits=14)),
                ('min_stock', models.DecimalField(decimal_places=3, default=Decimal('0.000'), max_digits=14)),
                ('max_stock', models.DecimalField(decimal_places=3, default=Decimal('0.000'), max_digits=14)),
                ('reorder_level', models.DecimalField(decimal_places=3, default=Decimal('0.000'), max_digits=14)),
                ('standard_rate', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14)),
                ('last_purchase_rate', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14)),
                ('valuation_method', models.CharField(choices=[('FIFO', 'First-In, First-Out (FIFO)'), ('WEIGHTED_AVG', 'Weighted Average Cost'), ('SPECIFIC_ID', 'Specific Identification (Batch/Serial)')], default='WEIGHTED_AVG', max_length=16)),
                ('tax_rate', models.DecimalField(decimal_places=2, default=Decimal('13.00'), max_digits=5)),
                ('barcode_qr', models.CharField(blank=True, max_length=80)),
                ('track_batch', models.BooleanField(default=False)),
                ('track_serial', models.BooleanField(default=False)),
                ('is_active', models.BooleanField(default=True)),
            ],
            options={
                'db_table': 'items',
                'ordering': ['item_code'],
            },
        ),
        migrations.CreateModel(
            name='MaterialIssue',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('issue_no', models.CharField(max_length=40)),
                ('issue_date', models.DateField()),
                ('bs_date', models.CharField(blank=True, max_length=16)),
                ('receiver_name', models.CharField(blank=True, max_length=120)),
                ('total_cost', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
                ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('APPROVED', 'Approved & Consumed'), ('CANCELLED', 'Cancelled')], default='DRAFT', max_length=16)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'material_issues',
                'ordering': ['-issue_date', '-created_at'],
            },
        ),
        migrations.CreateModel(
            name='MaterialIssueLine',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('quantity', models.DecimalField(decimal_places=3, max_digits=14)),
                ('wastage_qty', models.DecimalField(decimal_places=3, default=Decimal('0.000'), max_digits=14)),
                ('unit_cost', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14)),
                ('total_cost', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=18)),
            ],
            options={
                'db_table': 'material_issue_lines',
            },
        ),
        migrations.CreateModel(
            name='MaterialRequisition',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('requisition_no', models.CharField(max_length=40)),
                ('requisition_date', models.DateField()),
                ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('APPROVED', 'Approved for Issue'), ('ISSUED', 'Issued'), ('CANCELLED', 'Cancelled')], default='DRAFT', max_length=16)),
                ('remarks', models.CharField(blank=True, max_length=255)),
            ],
            options={
                'db_table': 'material_requisitions',
            },
        ),
        migrations.CreateModel(
            name='MaterialReturn',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('return_no', models.CharField(max_length=40)),
                ('return_date', models.DateField()),
                ('quantity', models.DecimalField(decimal_places=3, max_digits=14)),
                ('unit_cost', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=14)),
                ('reason', models.CharField(blank=True, max_length=255)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'material_returns',
            },
        ),
        migrations.CreateModel(
            name='StockBatch',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('batch_no', models.CharField(blank=True, default='GENERAL', max_length=48)),
                ('serial_no', models.CharField(blank=True, max_length=64)),
                ('expiry_date', models.DateField(blank=True, null=True)),
                ('received_date', models.DateField()),
                ('received_qty', models.DecimalField(decimal_places=3, max_digits=16)),
                ('remaining_qty', models.DecimalField(decimal_places=3, max_digits=16)),
                ('unit_cost', models.DecimalField(decimal_places=2, max_digits=14)),
            ],
            options={
                'db_table': 'stock_batches',
                'ordering': ['received_date', 'id'],
            },
        ),
        migrations.CreateModel(
            name='StockCount',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('count_no', models.CharField(max_length=40)),
                ('count_date', models.DateField()),
                ('book_qty', models.DecimalField(decimal_places=3, max_digits=16)),
                ('physical_qty', models.DecimalField(decimal_places=3, max_digits=16)),
                ('variance_qty', models.DecimalField(decimal_places=3, max_digits=16)),
                ('remarks', models.CharField(blank=True, max_length=255)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'stock_counts',
            },
        ),
        migrations.CreateModel(
            name='StockMovement',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('movement_type', models.CharField(choices=[('GRN_RECEIPT', 'GRN Purchase Receipt'), ('ISSUE', 'Material Issue to Project/Site'), ('RETURN', 'Material Return to Store'), ('TRANSFER_OUT', 'Inter-Store Transfer Out'), ('TRANSFER_IN', 'Inter-Store Transfer In'), ('ADJUSTMENT', 'Authorized Stock Adjustment'), ('WRITE_OFF', 'Damaged / Wastage Write-off'), ('COUNT_VARIANCE', 'Physical Stock Reconciliation')], db_index=True, max_length=20)),
                ('movement_date', models.DateField(db_index=True)),
                ('reference_no', models.CharField(max_length=48)),
                ('quantity_delta', models.DecimalField(decimal_places=3, max_digits=16)),
                ('unit_cost', models.DecimalField(decimal_places=2, max_digits=14)),
                ('value_delta', models.DecimalField(decimal_places=2, max_digits=18)),
                ('balance_qty_after', models.DecimalField(decimal_places=3, max_digits=16)),
                ('balance_value_after', models.DecimalField(decimal_places=2, max_digits=18)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'stock_movements',
                'ordering': ['movement_date', 'created_at'],
            },
        ),
        migrations.CreateModel(
            name='StockTransfer',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('transfer_no', models.CharField(max_length=40)),
                ('transfer_date', models.DateField()),
                ('quantity', models.DecimalField(decimal_places=3, max_digits=14)),
                ('status', models.CharField(default='COMPLETED', max_length=16)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'stock_transfers',
            },
        ),
        migrations.CreateModel(
            name='UnitConversion',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('factor', models.DecimalField(decimal_places=6, max_digits=14)),
            ],
            options={
                'db_table': 'unit_conversions',
            },
        ),
        migrations.CreateModel(
            name='UnitOfMeasure',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('code', models.CharField(max_length=16)),
                ('name', models.CharField(max_length=64)),
            ],
            options={
                'db_table': 'units',
                'ordering': ['code'],
            },
        ),
        migrations.CreateModel(
            name='Warehouse',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('code', models.CharField(max_length=32)),
                ('name', models.CharField(max_length=160)),
                ('store_kind', models.CharField(choices=[('CENTRAL', 'Central Warehouse'), ('HEAD_OFFICE', 'Head Office Store'), ('BRANCH', 'Branch Warehouse'), ('PROJECT', 'Project Warehouse'), ('SITE_STORE', 'Construction Site Store'), ('EQUIPMENT_YARD', 'Equipment & Machinery Yard'), ('TOOL_CUSTODY', 'Employee Tool Custody')], default='SITE_STORE', max_length=20)),
                ('allow_negative_stock', models.BooleanField(default=False)),
                ('is_active', models.BooleanField(default=True)),
            ],
            options={
                'db_table': 'warehouses',
                'ordering': ['code'],
            },
        ),
    ]
