deep-risk/backend/app/models/expense.py
2025-12-14 20:08:27 +08:00

106 lines
3.4 KiB
Python
Raw 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 date
from typing import Optional, TYPE_CHECKING
from sqlalchemy import (
Boolean,
Column,
Date,
Integer,
String,
Text,
Float,
)
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import BaseModel
if TYPE_CHECKING:
from .streamer import StreamerInfo, McnAgency
class Expense(BaseModel):
"""
成本费用凭证表
"""
__tablename__ = "expense"
expense_id: Mapped[str] = mapped_column(
String(50), unique=True, nullable=False, comment="费用ID"
)
voucher_no: Mapped[str] = mapped_column(
String(100), nullable=False, comment="凭证号"
)
expense_type: Mapped[str] = mapped_column(
String(50),
nullable=False,
comment="费用类型streamer_commission-主播佣金platform_fee-平台费用advertising_fee-广告费other-其他",
)
expense_category: Mapped[str] = mapped_column(
String(50),
nullable=False,
comment="费用类别sales_expense-销售费用management_expense-管理费用financial_expense-财务费用",
)
payer_name: Mapped[str] = mapped_column(
String(100), nullable=False, comment="付款方名称"
)
payer_account_no: Mapped[str] = mapped_column(
String(50), nullable=False, comment="付款方账号"
)
payee_name: Mapped[str] = mapped_column(
String(100), nullable=False, comment="收款方名称"
)
payee_account_no: Mapped[str] = mapped_column(
String(50), nullable=False, comment="收款方账号"
)
payee_bank_name: Mapped[Optional[str]] = mapped_column(
String(100), nullable=True, comment="收款方开户行"
)
expense_date: Mapped[date] = mapped_column(
Date, nullable=False, comment="费用发生日期"
)
expense_amount: Mapped[float] = mapped_column(
nullable=False, comment="费用金额"
)
tax_amount: Mapped[float] = mapped_column(
default=0, comment="税额"
)
tax_rate: Mapped[float] = mapped_column(
default=0, comment="税率"
)
payment_method: Mapped[str] = mapped_column(
String(50),
nullable=False,
comment="支付方式bank_transfer-银行转账alipay-支付宝wechat-微信cash-现金",
)
payment_status: Mapped[str] = mapped_column(
String(20),
nullable=False,
comment="支付状态pending-待支付processing-处理中paid-已支付failed-支付失败",
)
accounting_status: Mapped[str] = mapped_column(
String(20),
nullable=False,
comment="入账状态unposted-未入账posted-已入账reversed-已冲销",
)
fiscal_year: Mapped[int] = mapped_column(
nullable=False, comment="会计年度"
)
fiscal_period: Mapped[int] = mapped_column(
nullable=False, comment="会计期间"
)
is_large_amount: Mapped[bool] = mapped_column(
default=False, comment="是否大额费用(>5万"
)
is_cross_border: Mapped[bool] = mapped_column(
default=False, comment="是否跨境支付"
)
expense_description: Mapped[Optional[str]] = mapped_column(
Text, nullable=True, comment="费用说明"
)
related_contract_id: Mapped[Optional[str]] = mapped_column(
String(50), nullable=True, comment="关联协议ID"
)