feat: v0.3 报价算料引擎与仓库库存模块
后端: - 报价算料: 从drawing_data几何提取型材清单(外框/中梃/扇框投影长度) 与玻璃面积(鞋带公式), 套价格本计价, 支持样板/订单/自定义图纸三入口 - 仓库库存: 材料CRUD/出入库/流水/负库存拦截/预警线 - SQLite默认路径锚定项目根目录(修复cwd依赖) 前端: - 仓库库存页(筛选/出入库对话框/预警高亮) - 算料报价弹窗(样板库与订单详情入口, 支持打印) - 路由与导航更新(8页面) 回归: 9个API端点全部200, 报价/优化/SPA路由验证通过
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
"""ORM 模型统一导出。"""
|
||||
from huamenchuang.models.contract import Contract, Customer
|
||||
from huamenchuang.models.contract import (
|
||||
Contract,
|
||||
Customer,
|
||||
ReceiptAccount,
|
||||
StockMove,
|
||||
WarehouseItem,
|
||||
)
|
||||
from huamenchuang.models.order import DEFAULT_PROCESSES, Order, OrderLog, OrderProcess
|
||||
from huamenchuang.models.user import User
|
||||
from huamenchuang.models.windoor_template import WindoorCatelog, WindoorTemplate
|
||||
@@ -11,7 +17,10 @@ __all__ = [
|
||||
"Order",
|
||||
"OrderLog",
|
||||
"OrderProcess",
|
||||
"ReceiptAccount",
|
||||
"StockMove",
|
||||
"User",
|
||||
"WarehouseItem",
|
||||
"WindoorCatelog",
|
||||
"WindoorTemplate",
|
||||
]
|
||||
|
||||
@@ -25,6 +25,63 @@ class Customer(Base):
|
||||
)
|
||||
|
||||
|
||||
class ReceiptAccount(Base):
|
||||
"""收款账户。"""
|
||||
|
||||
__tablename__ = "receipt_accounts"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
company_id: Mapped[int] = mapped_column(default=1, index=True)
|
||||
type: Mapped[int] = mapped_column(default=1) # 1银行 2现金 3其他
|
||||
name: Mapped[str] = mapped_column(String(64))
|
||||
number: Mapped[str] = mapped_column(String(64), default="")
|
||||
bank: Mapped[str] = mapped_column(String(64), default="")
|
||||
note: Mapped[str] = mapped_column(Text, default="")
|
||||
is_default: Mapped[int] = mapped_column(default=0)
|
||||
balance: Mapped[float] = mapped_column(Numeric(12, 2), default=0)
|
||||
created_at: Mapped[datetime.datetime] = mapped_column(DateTime, default=datetime.datetime.utcnow)
|
||||
|
||||
|
||||
class WarehouseItem(Base):
|
||||
"""材料库存(型材/玻璃/五金/配件)。"""
|
||||
|
||||
__tablename__ = "warehouse_items"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
company_id: Mapped[int] = mapped_column(default=1, index=True)
|
||||
bom_code: Mapped[str] = mapped_column(String(32), default="")
|
||||
name: Mapped[str] = mapped_column(String(128))
|
||||
# profile型材/glass玻璃/hardware五金/addon配件
|
||||
material: Mapped[str] = mapped_column(String(16), default="profile", index=True)
|
||||
color: Mapped[str] = mapped_column(String(32), default="")
|
||||
spec: Mapped[str] = mapped_column(String(64), default="") # 规格型号
|
||||
unit: Mapped[str] = mapped_column(String(8), default="根")
|
||||
cost: Mapped[float] = mapped_column(Numeric(12, 2), default=0)
|
||||
price: Mapped[float] = mapped_column(Numeric(12, 2), default=0)
|
||||
count: Mapped[float] = mapped_column(Numeric(12, 2), default=0)
|
||||
warning: Mapped[float] = mapped_column(Numeric(12, 2), default=0) # 库存预警线
|
||||
length: Mapped[int] = mapped_column(default=0) # 单根长度mm(型材)
|
||||
note: Mapped[str] = mapped_column(Text, default="")
|
||||
created_at: Mapped[datetime.datetime] = mapped_column(DateTime, default=datetime.datetime.utcnow)
|
||||
updated_at: Mapped[datetime.datetime] = mapped_column(
|
||||
DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow
|
||||
)
|
||||
|
||||
|
||||
class StockMove(Base):
|
||||
"""出入库流水。direction: 1入库 -1出库"""
|
||||
|
||||
__tablename__ = "stock_moves"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
item_id: Mapped[int] = mapped_column(ForeignKey("warehouse_items.id"), index=True)
|
||||
direction: Mapped[int] = mapped_column(default=1)
|
||||
count: Mapped[float] = mapped_column(Numeric(12, 2), default=0)
|
||||
note: Mapped[str] = mapped_column(String(255), default="")
|
||||
user_id: Mapped[int] = mapped_column(default=0)
|
||||
created_at: Mapped[datetime.datetime] = mapped_column(DateTime, default=datetime.datetime.utcnow)
|
||||
|
||||
|
||||
class Contract(Base):
|
||||
"""合同/意向单:目标站契约 status="意向单" 起步,oids[] 记录关联订单。"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user