Add owner work order approval page
Some checks failed
ci / test (push) Has been cancelled

This commit is contained in:
VPN SaaS Dev
2026-05-16 10:51:05 +09:00
parent ac5845d5a0
commit 545f4d088d
12 changed files with 1066 additions and 48 deletions

View File

@@ -0,0 +1,128 @@
"""work order catalog items
Revision ID: 202605160001
Revises: 202605150004
Create Date: 2026-05-16 12:00:00.000000
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = "202605160001"
down_revision: str | None = "202605150004"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
catalog = op.create_table(
"work_order_catalog_items",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("service_center_id", sa.Integer(), nullable=True),
sa.Column("item_type", sa.String(length=24), nullable=False),
sa.Column("title", sa.String(length=180), nullable=False),
sa.Column("category", sa.String(length=80), nullable=True),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("work_type", sa.String(length=40), nullable=True),
sa.Column("product_type", sa.String(length=40), nullable=True),
sa.Column("brand", sa.String(length=80), nullable=True),
sa.Column("sku", sa.String(length=120), nullable=True),
sa.Column("unit", sa.String(length=24), server_default="pcs", nullable=False),
sa.Column("default_quantity", sa.Numeric(10, 3), server_default="1", nullable=False),
sa.Column("default_unit_price", sa.Numeric(12, 2), server_default="0", nullable=False),
sa.Column("volume", sa.Numeric(8, 3), nullable=True),
sa.Column("viscosity", sa.String(length=40), nullable=True),
sa.Column("specification", sa.String(length=120), nullable=True),
sa.Column("metadata_json", sa.JSON(), nullable=True),
sa.Column("is_active", sa.Boolean(), server_default=sa.text("true"), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
sa.ForeignKeyConstraint(["service_center_id"], ["service_centers.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index("ix_work_order_catalog_items_category", "work_order_catalog_items", ["category"])
op.create_index("ix_work_order_catalog_items_created_at", "work_order_catalog_items", ["created_at"])
op.create_index("ix_work_order_catalog_items_is_active", "work_order_catalog_items", ["is_active"])
op.create_index("ix_work_order_catalog_items_item_type", "work_order_catalog_items", ["item_type"])
op.create_index("ix_work_order_catalog_items_product_type", "work_order_catalog_items", ["product_type"])
op.create_index("ix_work_order_catalog_items_service_center_id", "work_order_catalog_items", ["service_center_id"])
op.create_index("ix_work_order_catalog_items_sku", "work_order_catalog_items", ["sku"])
op.create_index("ix_work_order_catalog_items_title", "work_order_catalog_items", ["title"])
op.create_index("ix_work_order_catalog_items_work_type", "work_order_catalog_items", ["work_type"])
op.bulk_insert(
catalog,
[
{
"service_center_id": None,
"item_type": "work",
"title": "Замена моторного масла",
"category": "maintenance",
"work_type": "maintenance",
"unit": "job",
"default_quantity": 1,
"default_unit_price": 0,
"metadata_json": {"source": "system_seed"},
},
{
"service_center_id": None,
"item_type": "work",
"title": "Компьютерная диагностика",
"category": "diagnostics",
"work_type": "diagnostics",
"unit": "job",
"default_quantity": 1,
"default_unit_price": 0,
"metadata_json": {"source": "system_seed"},
},
{
"service_center_id": None,
"item_type": "work",
"title": "Замена тормозных колодок",
"category": "brakes",
"work_type": "repair",
"unit": "job",
"default_quantity": 1,
"default_unit_price": 0,
"metadata_json": {"source": "system_seed"},
},
{
"service_center_id": None,
"item_type": "product",
"title": "Масляный фильтр",
"category": "filter",
"product_type": "part",
"unit": "pcs",
"default_quantity": 1,
"default_unit_price": 0,
"metadata_json": {"source": "system_seed"},
},
{
"service_center_id": None,
"item_type": "product",
"title": "Тормозная жидкость",
"category": "brake_fluid",
"product_type": "fluid",
"unit": "l",
"default_quantity": 1,
"default_unit_price": 0,
"metadata_json": {"source": "system_seed"},
},
],
)
def downgrade() -> None:
op.drop_index("ix_work_order_catalog_items_work_type", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_title", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_sku", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_service_center_id", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_product_type", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_item_type", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_is_active", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_created_at", table_name="work_order_catalog_items")
op.drop_index("ix_work_order_catalog_items_category", table_name="work_order_catalog_items")
op.drop_table("work_order_catalog_items")