Files
s2f/backend/app/models/account_mapping.py
selfrelease 5278190750 feat: 凭证生成、成本分析、AI问答、前端页面、集成测试与E2E测试
- 后端: 凭证生成引擎、金蝶导出器、凭证模板服务
- 后端: 成本分析服务、AI问答服务
- 后端: 科目映射CRUD API、分析API、QA API
- 后端: 集成测试(认证/任务/凭证) 49个测试全部通过
- 前端: 凭证管理、成本分析、导出中心、知识库、系统设置页面
- 前端: AuthGuard认证守卫、Dashboard AI聊天功能
- 前端: Playwright E2E测试 16 passed, 1 skipped
- 基础设施: Docker Compose、Nginx反向代理、.env.example
- 文档: 用户手册、管理员手册、发布检查清单
2026-07-07 21:21:29 +08:00

48 lines
1.9 KiB
Python

"""
科目映射模型
存储标准字段到会计科目的映射关系
"""
from typing import Optional
from sqlalchemy import ForeignKey, Integer, String, Float, Boolean, JSON
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import BaseModel
class AccountMapping(BaseModel):
"""
科目映射模型
将标准字段(如基本工资、社保等)映射到会计科目
Attributes:
company_id: 企业ID
standard_field: 标准字段名
debit_account: 借方科目代码
debit_account_name: 借方科目名称
credit_account: 贷方科目代码
credit_account_name: 贷方科目名称
cost_center: 成本中心(可选)
is_active: 是否启用
"""
__tablename__ = "account_mappings"
company_id: Mapped[int] = mapped_column(Integer, ForeignKey("companies.id"), nullable=False, index=True)
standard_field: Mapped[str] = mapped_column(String(100), nullable=False, index=True, comment="标准字段名")
debit_account: Mapped[str] = mapped_column(String(50), nullable=False, comment="借方科目代码")
debit_account_name: Mapped[str] = mapped_column(String(200), nullable=False, comment="借方科目名称")
credit_account: Mapped[str] = mapped_column(String(50), nullable=False, comment="贷方科目代码")
credit_account_name: Mapped[str] = mapped_column(String(200), nullable=False, comment="贷方科目名称")
cost_center: Mapped[Optional[str]] = mapped_column(String(100), nullable=True, comment="成本中心")
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True, comment="是否启用")
# 关系
company = relationship("Company", backref="account_mappings")
def __repr__(self) -> str:
return f"<AccountMapping(field='{self.standard_field}', debit='{self.debit_account}', credit='{self.credit_account}')>"