Files
Hermes CI Fix 1a6ea8afae chore: CI流程加固+Schema检查门禁
- deploy.sh: 提交纪律检查(本地未提交修改→中止) + 冒烟测试(健康/登录/KPI/BOT/Schema)
- .woodpecker: 加前端typecheck+后端pytest测试步骤, backend-deploy加提交纪律检查
- 新增schema_check.py: ORM与数据库表结构一致性检查
- 修复budget_plans表缺3列(source_kpi_id/source_type/calc_logic)
- 附带入库: budget测试+文档
2026-08-28 07:18:54 +08:00

27 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""预算计划模型 — 管理会计OS"""
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey, Text, func
from app.database import Base
class BudgetPlan(Base):
"""预算计划 — 按KPI按月分解的目标值"""
__tablename__ = "budget_plans"
id = Column(Integer, primary_key=True, index=True)
entity_id = Column(Integer, default=1, comment="企业ID (P2多租户隔离 2026-08-23)")
map_id = Column(Integer, nullable=True, comment="归属战略地图ID (预算按地图隔离 2026-08-27)")
kpi_id = Column(Integer, ForeignKey("kpi_definitions.id"), nullable=False, comment="关联KPI")
period = Column(String(20), nullable=False, comment="预算期间 2026-05")
budget_value = Column(Float, nullable=False, comment="预算值")
budget_year = Column(Integer, nullable=False, comment="预算年份")
budget_month = Column(Integer, nullable=False, comment="预算月份 1-12")
version = Column(String(20), default="v1.0", comment="版本号 v1.0/v2.0")
status = Column(String(20), default="active", comment="active/archived")
source_type = Column(String(50), nullable=True, comment="来源类型: manual/kpi_generated/roll_forward等")
source_kpi_id = Column(Integer, nullable=True, comment="来源KPI IDKPI推算生成时记录)")
calc_logic = Column(Text, nullable=True, comment="预算计算逻辑说明")
remark = Column(String(500), nullable=True, comment="备注")
created_by = Column(String(100), nullable=True)
created_at = Column(DateTime, server_default=func.now())
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())