Files
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

68 lines
2.5 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.
"""
凭证模型
存储生成的会计凭证
"""
from datetime import datetime
from typing import Optional
from sqlalchemy import ForeignKey, Integer, String, Float, DateTime, JSON, Text
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import BaseModel
class VoucherStatus:
"""凭证状态"""
DRAFT = "DRAFT"
CONFIRMED = "CONFIRMED"
EXPORTED = "EXPORTED"
class Voucher(BaseModel):
"""
会计凭证模型
Attributes:
company_id: 企业ID
task_id: 对账任务ID
voucher_number: 凭证编号
voucher_date: 凭证日期
period: 会计期间
summary: 摘要
entries: 凭证分录(JSON
total_debit: 借方合计
total_credit: 贷方合计
status: 状态
confirmed_by: 确认人
confirmed_at: 确认时间
"""
__tablename__ = "vouchers"
company_id: Mapped[int] = mapped_column(Integer, ForeignKey("companies.id"), nullable=False, index=True)
task_id: Mapped[int] = mapped_column(Integer, ForeignKey("reconciliation_tasks.id"), nullable=False, index=True)
voucher_number: Mapped[str] = mapped_column(String(50), nullable=False, index=True, comment="凭证编号")
voucher_date: Mapped[str] = mapped_column(String(20), nullable=False, comment="凭证日期 YYYY-MM-DD")
period: Mapped[str] = mapped_column(String(20), nullable=False, index=True, comment="会计期间 YYYY-MM")
summary: Mapped[str] = mapped_column(String(500), nullable=False, comment="摘要")
entries: Mapped[dict] = mapped_column(JSON, nullable=False, comment="凭证分录列表")
total_debit: Mapped[float] = mapped_column(Float, nullable=False, default=0.0, comment="借方合计")
total_credit: Mapped[float] = mapped_column(Float, nullable=False, default=0.0, comment="贷方合计")
status: Mapped[str] = mapped_column(String(20), nullable=False, default=VoucherStatus.DRAFT, index=True, comment="状态")
confirmed_by: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("users.id"), nullable=True)
confirmed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
# 关系
company = relationship("Company", backref="vouchers")
task = relationship("ReconciliationTask", backref="vouchers")
confirmer = relationship("User", foreign_keys=[confirmed_by])
def __repr__(self) -> str:
return f"<Voucher(number='{self.voucher_number}', period='{self.period}', status='{self.status}')>"