# This file is auto-generated by generate_models.py
# This file may be manually edited after generation
# The file has been formatted using isort and black

from typing import Any, ClassVar, Dict, List

from clickhouse_sqlalchemy import engines
from sqlalchemy import Column, PrimaryKeyConstraint, text

from tushare_models.core import Base, Date, DateTime, Float, Integer, String


class Cashflow(Base):
    """现金流量表"""

    __tablename__: str = "cashflow"
    __api_id__: ClassVar[int] = 44
    __api_name__: ClassVar[str] = "cashflow"
    __api_title__: ClassVar[str] = "现金流量表"
    __api_info_title__: ClassVar[str] = "现金流量表"
    __api_path__: ClassVar[List[str]] = ["数据接口", "股票数据", "财务数据", "现金流量表"]
    __api_path_ids__: ClassVar[List[int]] = [2, 14, 16, 44]
    __api_points_required__: ClassVar[int] = 2000
    __api_special_permission__: ClassVar[bool] = False
    __has_vip__: ClassVar[bool] = True
    __dependencies__: ClassVar[List[str]] = ["stock_basic"]
    __primary_key__: ClassVar[List[str]] = [
        "ts_code",
        "ann_date",
        "f_ann_date",
        "end_date",
        "report_type",
        "update_flag",
    ]
    __start_date__: ClassVar[str | None] = None
    __end_date__: ClassVar[str | None] = None
    __api_params__: ClassVar[Dict[str, Any]] = {
        "ts_code": {"type": "str", "required": True, "description": "股票代码"},
        "ann_date": {"type": "str", "required": False, "description": "公告日期（格式：YYYYMMDD，下同）"},
        "f_ann_date": {"type": "str", "required": False, "description": "实际公告日期"},
        "start_date": {"type": "str", "required": False, "description": "报告期开始日期"},
        "end_date": {"type": "str", "required": False, "description": "报告期结束日期"},
        "period": {"type": "str", "required": False, "description": "报告期"},
        "report_type": {"type": "str", "required": False, "description": "报告类型"},
        "comp_type": {"type": "str", "required": False, "description": "公司类型"},
        "is_calc": {"type": "int", "required": False, "description": "是否计算报表"},
        "limit": {"type": "int", "required": False, "description": "单次返回数据长度"},
        "offset": {"type": "int", "required": False, "description": "请求数据的开始位移量"},
    }

    __mapper_args__ = {"primary_key": __primary_key__}
    __table_args__ = (
        PrimaryKeyConstraint(*__primary_key__),
        # ClickHouse引擎
        engines.ReplacingMergeTree(order_by=__primary_key__),
        {
            "comment": "现金流量表",
            # MySQL引擎
            "mysql_engine": "InnoDB",
            # StarRocks引擎
            "starrocks_primary_key": ",".join(__primary_key__),
            "starrocks_order_by": ",".join(__primary_key__),
            # Apache Doris引擎
            "doris_unique_key": __primary_key__,
            # Databend引擎
            "databend_cluster_by": __primary_key__,
        },
    )

    ts_code = Column("ts_code", String(16), nullable=False, default="", server_default=text("''"), comment="TS股票代码")
    ann_date = Column(
        "ann_date", Date, nullable=False, default="1970-01-01", server_default=text("'1970-01-01'"), comment="公告日期"
    )
    f_ann_date = Column(
        "f_ann_date",
        Date,
        nullable=False,
        default="1970-01-01",
        server_default=text("'1970-01-01'"),
        comment="实际公告日期",
    )
    end_date = Column(
        "end_date", Date, nullable=False, default="1970-01-01", server_default=text("'1970-01-01'"), comment="报告期"
    )
    comp_type = Column(
        "comp_type",
        String(),
        nullable=False,
        default="",
        server_default=text("''"),
        comment="公司类型(1一般工商业2银行3保险4证券)",
    )
    report_type = Column(
        "report_type", String(), nullable=False, default="", server_default=text("''"), comment="报表类型"
    )
    end_type = Column("end_type", String(), nullable=False, default="", server_default=text("''"), comment="报告期类型")
    net_profit = Column(
        "net_profit", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="净利润"
    )
    finan_exp = Column(
        "finan_exp", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="财务费用"
    )
    c_fr_sale_sg = Column(
        "c_fr_sale_sg",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="销售商品、提供劳务收到的现金",
    )
    recp_tax_rends = Column(
        "recp_tax_rends", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="收到的税费返还"
    )
    n_depos_incr_fi = Column(
        "n_depos_incr_fi",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="客户存款和同业存放款项净增加额",
    )
    n_incr_loans_cb = Column(
        "n_incr_loans_cb",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="向中央银行借款净增加额",
    )
    n_inc_borr_oth_fi = Column(
        "n_inc_borr_oth_fi",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="向其他金融机构拆入资金净增加额",
    )
    prem_fr_orig_contr = Column(
        "prem_fr_orig_contr",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="收到原保险合同保费取得的现金",
    )
    n_incr_insured_dep = Column(
        "n_incr_insured_dep",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="保户储金净增加额",
    )
    n_reinsur_prem = Column(
        "n_reinsur_prem",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="收到再保业务现金净额",
    )
    n_incr_disp_tfa = Column(
        "n_incr_disp_tfa",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="处置交易性金融资产净增加额",
    )
    ifc_cash_incr = Column(
        "ifc_cash_incr",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="收取利息和手续费净增加额",
    )
    n_incr_disp_faas = Column(
        "n_incr_disp_faas",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="处置可供出售金融资产净增加额",
    )
    n_incr_loans_oth_bank = Column(
        "n_incr_loans_oth_bank",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="拆入资金净增加额",
    )
    n_cap_incr_repur = Column(
        "n_cap_incr_repur",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="回购业务资金净增加额",
    )
    c_fr_oth_operate_a = Column(
        "c_fr_oth_operate_a",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="收到其他与经营活动有关的现金",
    )
    c_inf_fr_operate_a = Column(
        "c_inf_fr_operate_a",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="经营活动现金流入小计",
    )
    c_paid_goods_s = Column(
        "c_paid_goods_s",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="购买商品、接受劳务支付的现金",
    )
    c_paid_to_for_empl = Column(
        "c_paid_to_for_empl",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="支付给职工以及为职工支付的现金",
    )
    c_paid_for_taxes = Column(
        "c_paid_for_taxes", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="支付的各项税费"
    )
    n_incr_clt_loan_adv = Column(
        "n_incr_clt_loan_adv",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="客户贷款及垫款净增加额",
    )
    n_incr_dep_cbob = Column(
        "n_incr_dep_cbob",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="存放央行和同业款项净增加额",
    )
    c_pay_claims_orig_inco = Column(
        "c_pay_claims_orig_inco",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="支付原保险合同赔付款项的现金",
    )
    pay_handling_chrg = Column(
        "pay_handling_chrg",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="支付手续费的现金",
    )
    pay_comm_insur_plcy = Column(
        "pay_comm_insur_plcy",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="支付保单红利的现金",
    )
    oth_cash_pay_oper_act = Column(
        "oth_cash_pay_oper_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="支付其他与经营活动有关的现金",
    )
    st_cash_out_act = Column(
        "st_cash_out_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="经营活动现金流出小计",
    )
    n_cashflow_act = Column(
        "n_cashflow_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="经营活动产生的现金流量净额",
    )
    oth_recp_ral_inv_act = Column(
        "oth_recp_ral_inv_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="收到其他与投资活动有关的现金",
    )
    c_disp_withdrwl_invest = Column(
        "c_disp_withdrwl_invest",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="收回投资收到的现金",
    )
    c_recp_return_invest = Column(
        "c_recp_return_invest",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="取得投资收益收到的现金",
    )
    n_recp_disp_fiolta = Column(
        "n_recp_disp_fiolta",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="处置固定资产、无形资产和其他长期资产收回的现金净额",
    )
    n_recp_disp_sobu = Column(
        "n_recp_disp_sobu",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="处置子公司及其他营业单位收到的现金净额",
    )
    stot_inflows_inv_act = Column(
        "stot_inflows_inv_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="投资活动现金流入小计",
    )
    c_pay_acq_const_fiolta = Column(
        "c_pay_acq_const_fiolta",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="购建固定资产、无形资产和其他长期资产支付的现金",
    )
    c_paid_invest = Column(
        "c_paid_invest", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="投资支付的现金"
    )
    n_disp_subs_oth_biz = Column(
        "n_disp_subs_oth_biz",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="取得子公司及其他营业单位支付的现金净额",
    )
    oth_pay_ral_inv_act = Column(
        "oth_pay_ral_inv_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="支付其他与投资活动有关的现金",
    )
    n_incr_pledge_loan = Column(
        "n_incr_pledge_loan",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="质押贷款净增加额",
    )
    stot_out_inv_act = Column(
        "stot_out_inv_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="投资活动现金流出小计",
    )
    n_cashflow_inv_act = Column(
        "n_cashflow_inv_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="投资活动产生的现金流量净额",
    )
    c_recp_borrow = Column(
        "c_recp_borrow", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="取得借款收到的现金"
    )
    proc_issue_bonds = Column(
        "proc_issue_bonds",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="发行债券收到的现金",
    )
    oth_cash_recp_ral_fnc_act = Column(
        "oth_cash_recp_ral_fnc_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="收到其他与筹资活动有关的现金",
    )
    stot_cash_in_fnc_act = Column(
        "stot_cash_in_fnc_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="筹资活动现金流入小计",
    )
    free_cashflow = Column(
        "free_cashflow", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="企业自由现金流量"
    )
    c_prepay_amt_borr = Column(
        "c_prepay_amt_borr",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="偿还债务支付的现金",
    )
    c_pay_dist_dpcp_int_exp = Column(
        "c_pay_dist_dpcp_int_exp",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="分配股利、利润或偿付利息支付的现金",
    )
    incl_dvd_profit_paid_sc_ms = Column(
        "incl_dvd_profit_paid_sc_ms",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="其中:子公司支付给少数股东的股利、利润",
    )
    oth_cashpay_ral_fnc_act = Column(
        "oth_cashpay_ral_fnc_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="支付其他与筹资活动有关的现金",
    )
    stot_cashout_fnc_act = Column(
        "stot_cashout_fnc_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="筹资活动现金流出小计",
    )
    n_cash_flows_fnc_act = Column(
        "n_cash_flows_fnc_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="筹资活动产生的现金流量净额",
    )
    eff_fx_flu_cash = Column(
        "eff_fx_flu_cash",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="汇率变动对现金的影响",
    )
    n_incr_cash_cash_equ = Column(
        "n_incr_cash_cash_equ",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="现金及现金等价物净增加额",
    )
    c_cash_equ_beg_period = Column(
        "c_cash_equ_beg_period",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="期初现金及现金等价物余额",
    )
    c_cash_equ_end_period = Column(
        "c_cash_equ_end_period",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="期末现金及现金等价物余额",
    )
    c_recp_cap_contrib = Column(
        "c_recp_cap_contrib",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="吸收投资收到的现金",
    )
    incl_cash_rec_saims = Column(
        "incl_cash_rec_saims",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="其中:子公司吸收少数股东投资收到的现金",
    )
    uncon_invest_loss = Column(
        "uncon_invest_loss", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="未确认投资损失"
    )
    prov_depr_assets = Column(
        "prov_depr_assets", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="加:资产减值准备"
    )
    depr_fa_coga_dpba = Column(
        "depr_fa_coga_dpba",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="固定资产折旧、油气资产折耗、生产性生物资产折旧",
    )
    amort_intang_assets = Column(
        "amort_intang_assets", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="无形资产摊销"
    )
    lt_amort_deferred_exp = Column(
        "lt_amort_deferred_exp",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="长期待摊费用摊销",
    )
    decr_deferred_exp = Column(
        "decr_deferred_exp", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="待摊费用减少"
    )
    incr_acc_exp = Column(
        "incr_acc_exp", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="预提费用增加"
    )
    loss_disp_fiolta = Column(
        "loss_disp_fiolta",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="处置固定、无形资产和其他长期资产的损失",
    )
    loss_scr_fa = Column(
        "loss_scr_fa", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="固定资产报废损失"
    )
    loss_fv_chg = Column(
        "loss_fv_chg", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="公允价值变动损失"
    )
    invest_loss = Column(
        "invest_loss", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="投资损失"
    )
    decr_def_inc_tax_assets = Column(
        "decr_def_inc_tax_assets",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="递延所得税资产减少",
    )
    incr_def_inc_tax_liab = Column(
        "incr_def_inc_tax_liab",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="递延所得税负债增加",
    )
    decr_inventories = Column(
        "decr_inventories", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="存货的减少"
    )
    decr_oper_payable = Column(
        "decr_oper_payable",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="经营性应收项目的减少",
    )
    incr_oper_payable = Column(
        "incr_oper_payable",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="经营性应付项目的增加",
    )
    others = Column("others", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="其他")
    im_net_cashflow_oper_act = Column(
        "im_net_cashflow_oper_act",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="经营活动产生的现金流量净额(间接法)",
    )
    conv_debt_into_cap = Column(
        "conv_debt_into_cap", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="债务转为资本"
    )
    conv_copbonds_due_within_1y = Column(
        "conv_copbonds_due_within_1y",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="一年内到期的可转换公司债券",
    )
    fa_fnc_leases = Column(
        "fa_fnc_leases", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="融资租入固定资产"
    )
    im_n_incr_cash_equ = Column(
        "im_n_incr_cash_equ",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="现金及现金等价物净增加额(间接法)",
    )
    net_dism_capital_add = Column(
        "net_dism_capital_add",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="拆出资金净增加额",
    )
    net_cash_rece_sec = Column(
        "net_cash_rece_sec",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="代理买卖证券收到的现金净额(元)",
    )
    credit_impa_loss = Column(
        "credit_impa_loss", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="信用减值损失"
    )
    use_right_asset_dep = Column(
        "use_right_asset_dep",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="使用权资产折旧",
    )
    oth_loss_asset = Column(
        "oth_loss_asset", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="其他资产减值损失"
    )
    end_bal_cash = Column(
        "end_bal_cash", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="现金的期末余额"
    )
    beg_bal_cash = Column(
        "beg_bal_cash", Float, nullable=False, default=0.0, server_default=text("'0.0'"), comment="减:现金的期初余额"
    )
    end_bal_cash_equ = Column(
        "end_bal_cash_equ",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="加:现金等价物的期末余额",
    )
    beg_bal_cash_equ = Column(
        "beg_bal_cash_equ",
        Float,
        nullable=False,
        default=0.0,
        server_default=text("'0.0'"),
        comment="减:现金等价物的期初余额",
    )
    update_flag = Column(
        "update_flag", String(), nullable=False, default="", server_default=text("''"), comment="更新标志"
    )
