Django_Basic_Manufacturing/inventory/migrations/0001_initial.py

87 lines
5.3 KiB
Python

# Generated by Django 4.2.7 on 2025-08-18 02:27
from decimal import Decimal
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, unique=True)),
('description', models.TextField(blank=True)),
('is_active', models.BooleanField(default=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='inventory.category')),
],
options={
'verbose_name': 'Category',
'verbose_name_plural': 'Categories',
'ordering': ['name'],
},
),
migrations.CreateModel(
name='Product',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('code', models.CharField(help_text='Unique product code/SKU', max_length=50, unique=True)),
('description', models.TextField(blank=True)),
('current_stock', models.DecimalField(decimal_places=2, default=0, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('min_stock_level', models.DecimalField(decimal_places=2, default=0, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('max_stock_level', models.DecimalField(decimal_places=2, default=1000, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('cost_price', models.DecimalField(decimal_places=2, default=0, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('selling_price', models.DecimalField(decimal_places=2, default=0, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('unit', models.CharField(choices=[('pcs', 'Pieces'), ('kg', 'Kilograms'), ('m', 'Meters'), ('l', 'Liters'), ('box', 'Boxes'), ('set', 'Sets')], default='pcs', max_length=10)),
('weight', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True)),
('dimensions', models.CharField(blank=True, help_text='Format: LxWxH in cm', max_length=100)),
('is_active', models.BooleanField(default=True)),
('is_manufactured', models.BooleanField(default=False, help_text='Is this a manufactured product?')),
('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, to='inventory.category')),
],
options={
'verbose_name': 'Product',
'verbose_name_plural': 'Products',
'ordering': ['name'],
},
),
migrations.CreateModel(
name='StockMovement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('movement_type', models.CharField(choices=[('in', 'Stock In'), ('out', 'Stock Out'), ('adjustment', 'Stock Adjustment'), ('manufacturing', 'Manufacturing Output'), ('sale', 'Sale'), ('purchase', 'Purchase')], max_length=20)),
('quantity', models.DecimalField(decimal_places=2, max_digits=10)),
('unit_price', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
('total_value', models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True)),
('reference_type', models.CharField(blank=True, help_text='Type of reference document', max_length=50)),
('reference_id', models.IntegerField(blank=True, help_text='ID of reference document', null=True)),
('reference_note', models.CharField(blank=True, max_length=200)),
('date', models.DateField()),
('notes', models.TextField(blank=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stock_movements', to='inventory.product')),
],
options={
'verbose_name': 'Stock Movement',
'verbose_name_plural': 'Stock Movements',
'ordering': ['-date', '-created_at'],
},
),
]