Files
Refactored-App/backend/apps/operations/migrations/0001_initial.py
2026-04-01 03:20:54 +02:00

275 lines
17 KiB
Python

# Generated by Django 5.2.12 on 2026-04-01 00:09
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('core', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('title', models.CharField(max_length=255)),
('description', models.TextField(blank=True)),
('event_type', models.CharField(default='other', max_length=32)),
('start_datetime', models.DateTimeField()),
('end_datetime', models.DateTimeField()),
('all_day', models.BooleanField(default=False)),
('location', models.CharField(blank=True, max_length=255)),
('color', models.CharField(blank=True, max_length=32)),
('recurrence_type', models.CharField(default='none', max_length=32)),
('recurrence_end_date', models.DateField(blank=True, null=True)),
('is_active', models.BooleanField(default=True)),
('business', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='events', to='core.business')),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='InventoryBalance',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity_on_hand', models.DecimalField(decimal_places=3, default=0, max_digits=12)),
('uom', models.CharField(default='pcs', max_length=32)),
('last_updated_at', models.DateTimeField(blank=True, null=True)),
('product', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='inventory_balance', to='core.product')),
],
),
migrations.CreateModel(
name='InventoryMovement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('movement_ts', models.DateTimeField(blank=True, null=True)),
('movement_date', models.DateField()),
('movement_type', models.CharField(max_length=32)),
('quantity_delta', models.DecimalField(decimal_places=3, max_digits=12)),
('uom', models.CharField(default='pcs', max_length=32)),
('source_type', models.CharField(max_length=32)),
('source_ref', models.CharField(blank=True, max_length=255)),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inventory_movements', to='core.product')),
('sellable_product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sellable_inventory_movements', to='core.product')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Invoice',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('vendor_not_configured', models.BooleanField(default=False)),
('vendor_config_note', models.TextField(blank=True)),
('invoice_number', models.CharField(blank=True, max_length=120)),
('invoice_date', models.DateField(blank=True, null=True)),
('order_date', models.DateField(blank=True, null=True)),
('entered_at', models.DateTimeField(blank=True, null=True)),
('payment_status', models.CharField(default='unpaid', max_length=32)),
('paid_date', models.DateField(blank=True, null=True)),
('due_date', models.DateField(blank=True, null=True)),
('subtotal', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
('discount_pct', models.DecimalField(decimal_places=2, default=0, max_digits=8)),
('discount_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
('total_after_discount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
('vat_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
('gross_total', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
('currency', models.CharField(default='CZK', max_length=8)),
('goods_received_status', models.CharField(default='not_received', max_length=32)),
('goods_date', models.DateField(blank=True, null=True)),
('notes', models.TextField(blank=True)),
('is_editable', models.BooleanField(default=True)),
('inventory_updated', models.BooleanField(default=False)),
('rate_czk_eur', models.DecimalField(decimal_places=4, default=0, max_digits=12)),
('rate_czk_usd', models.DecimalField(decimal_places=4, default=0, max_digits=12)),
('vat_exempt', models.BooleanField(default=False)),
('business', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.business')),
('vendor', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.vendor')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='InvoiceLineItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('quantity', models.DecimalField(decimal_places=3, max_digits=12)),
('unit_price', models.DecimalField(decimal_places=2, max_digits=12)),
('total_price', models.DecimalField(decimal_places=2, max_digits=12)),
('vat_rate', models.DecimalField(decimal_places=2, default=0, max_digits=8)),
('vat_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
('line_order', models.PositiveIntegerField(default=0)),
('invoice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='line_items', to='operations.invoice')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.product')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='ShiftRole',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('name', models.CharField(max_length=255)),
('color', models.CharField(blank=True, max_length=32)),
('sort_order', models.PositiveIntegerField(default=0)),
('is_active', models.BooleanField(default=True)),
('business', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shift_roles', to='core.business')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='ShiftTemplate',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('name', models.CharField(max_length=255)),
('start_datetime', models.DateTimeField()),
('end_datetime', models.DateTimeField()),
('min_staff', models.PositiveIntegerField(default=1)),
('max_staff', models.PositiveIntegerField(default=3)),
('color', models.CharField(blank=True, max_length=32)),
('recurrence_type', models.CharField(default='none', max_length=32)),
('recurrence_end_date', models.DateField(blank=True, null=True)),
('is_active', models.BooleanField(default=True)),
('business', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shift_templates', to='core.business')),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
('shift_role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='operations.shiftrole')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='StockCount',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('counted_by', models.CharField(blank=True, max_length=255)),
('count_date', models.DateField()),
('notes', models.TextField(blank=True)),
('status', models.CharField(default='in_progress', max_length=32)),
('completed_at', models.DateTimeField(blank=True, null=True)),
('business', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.business')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='StockCountLine',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('full_units', models.DecimalField(decimal_places=3, default=0, max_digits=12)),
('partial_units', models.DecimalField(decimal_places=3, default=0, max_digits=12)),
('total_quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12)),
('previous_quantity', models.DecimalField(decimal_places=3, default=0, max_digits=12)),
('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='core.product')),
('stock_count', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lines', to='operations.stockcount')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='InventoryBulkMapping',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('decrement_amount', models.DecimalField(decimal_places=3, default=1, max_digits=12)),
('decrement_uom', models.CharField(blank=True, max_length=32)),
('chip_name', models.CharField(blank=True, max_length=120)),
('bulk_product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bulk_mappings', to='core.product')),
('sellable_product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sellable_mappings', to='core.product')),
],
options={
'unique_together': {('bulk_product', 'sellable_product')},
},
),
migrations.CreateModel(
name='InvoiceCategory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.category')),
('invoice', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='category_links', to='operations.invoice')),
],
options={
'unique_together': {('invoice', 'category')},
},
),
migrations.CreateModel(
name='ShiftAssignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('occurrence_date', models.DateField()),
('start_override', models.DateTimeField(blank=True, null=True)),
('end_override', models.DateTimeField(blank=True, null=True)),
('status', models.CharField(default='assigned', max_length=32)),
('notes', models.TextField(blank=True)),
('notification_sent_at', models.DateTimeField(blank=True, null=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shift_assignments', to=settings.AUTH_USER_MODEL)),
('shift_template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assignments', to='operations.shifttemplate')),
],
options={
'unique_together': {('shift_template', 'user', 'occurrence_date')},
},
),
migrations.CreateModel(
name='WorkerAvailability',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('legacy_id', models.IntegerField(blank=True, db_index=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('date', models.DateField()),
('status', models.CharField(default='available', max_length=32)),
('note', models.TextField(blank=True)),
('business', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='availabilities', to='core.business')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='availabilities', to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('user', 'date')},
},
),
]