Add FinishedGoodsAccessory and AccessoryType ORM models for the accessory module. Add item_type column to FinishedGoodsBoxItem to distinguish between products and accessories in boxing records. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
2.4 KiB
Python
70 lines
2.4 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import BigInteger, DateTime, Index, Numeric, String, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.database import Base
|
|
|
|
SCHEMA = "CargoTrace"
|
|
|
|
|
|
class FinishedGoodsLocation(Base):
|
|
__tablename__ = "finished_goods_location"
|
|
__table_args__ = (
|
|
Index("uk_zongpai_no", "zongpai_no", unique=True),
|
|
Index("idx_fgl_location_code", "location_code"),
|
|
{"schema": SCHEMA},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
zongpai_no: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
location_code: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime,
|
|
nullable=False,
|
|
default=func.current_timestamp(),
|
|
server_default=func.current_timestamp(),
|
|
)
|
|
|
|
|
|
class FinishedGoodsBox(Base):
|
|
__tablename__ = "finished_goods_box"
|
|
__table_args__ = (
|
|
Index("uk_paichan_box", "paichan_no", "box_no", unique=True),
|
|
Index("idx_fgb_paichan_no", "paichan_no"),
|
|
{"schema": SCHEMA},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
paichan_no: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
box_no: Mapped[int] = mapped_column(nullable=False)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime,
|
|
nullable=False,
|
|
default=func.current_timestamp(),
|
|
server_default=func.current_timestamp(),
|
|
)
|
|
|
|
|
|
class FinishedGoodsBoxItem(Base):
|
|
__tablename__ = "finished_goods_box_item"
|
|
__table_args__ = (
|
|
Index("idx_fgbi_box_id", "box_id"),
|
|
Index("idx_fgbi_zongpai_no", "zongpai_no"),
|
|
{"schema": SCHEMA},
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
box_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
|
zongpai_no: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
quantity: Mapped[float | None] = mapped_column(Numeric(18, 3), nullable=True)
|
|
item_type: Mapped[str] = mapped_column(
|
|
String(16), nullable=False, default="product", server_default="product"
|
|
)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime,
|
|
nullable=False,
|
|
default=func.current_timestamp(),
|
|
server_default=func.current_timestamp(),
|
|
)
|