Django_Basic_Manufacturing/purchase/migrations/0001_initial.py

108 lines
6.4 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 = [
('inventory', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='PurchaseOrder',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('order_number', models.CharField(help_text='Unique purchase order number', max_length=50, unique=True)),
('date', models.DateField()),
('expected_delivery_date', models.DateField(blank=True, null=True)),
('status', models.CharField(choices=[('draft', 'Draft'), ('sent', 'Sent to Supplier'), ('confirmed', 'Confirmed by Supplier'), ('received', 'Received'), ('cancelled', 'Cancelled')], default='draft', max_length=20)),
('subtotal', models.DecimalField(decimal_places=2, default=0, max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('tax_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('shipping_cost', models.DecimalField(decimal_places=2, default=0, max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('total_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('notes', models.TextField(blank=True)),
('terms_conditions', models.TextField(blank=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Purchase Order',
'verbose_name_plural': 'Purchase Orders',
'ordering': ['-date', '-created_at'],
},
),
migrations.CreateModel(
name='Supplier',
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 supplier code', max_length=50, unique=True)),
('contact_person', models.CharField(blank=True, max_length=100)),
('email', models.EmailField(blank=True, max_length=254)),
('phone', models.CharField(blank=True, max_length=20)),
('address', models.TextField(blank=True)),
('tax_id', models.CharField(blank=True, max_length=50)),
('payment_terms', models.CharField(blank=True, help_text='e.g., Net 30, Net 60', max_length=100)),
('credit_limit', models.DecimalField(decimal_places=2, default=0, max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('is_active', models.BooleanField(default=True)),
('rating', models.IntegerField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)], default=3, help_text='Supplier rating from 1-5')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'verbose_name': 'Supplier',
'verbose_name_plural': 'Suppliers',
'ordering': ['name'],
},
),
migrations.CreateModel(
name='PurchaseReceipt',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('receipt_number', models.CharField(max_length=50, unique=True)),
('receipt_date', models.DateField()),
('notes', models.TextField(blank=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('purchase_order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='receipts', to='purchase.purchaseorder')),
('received_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'Purchase Receipt',
'verbose_name_plural': 'Purchase Receipts',
'ordering': ['-receipt_date'],
},
),
migrations.CreateModel(
name='PurchaseOrderItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.DecimalField(decimal_places=2, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0.01'))])),
('unit_price', models.DecimalField(decimal_places=2, max_digits=10, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('total_price', models.DecimalField(decimal_places=2, max_digits=12, validators=[django.core.validators.MinValueValidator(Decimal('0'))])),
('description', models.CharField(blank=True, max_length=200)),
('notes', models.TextField(blank=True)),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='purchase_order_items', to='inventory.product')),
('purchase_order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='purchase.purchaseorder')),
],
options={
'verbose_name': 'Purchase Order Item',
'verbose_name_plural': 'Purchase Order Items',
},
),
migrations.AddField(
model_name='purchaseorder',
name='supplier',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='purchase_orders', to='purchase.supplier'),
),
]