from pydantic import Field

from ...common.sync_node import SyncNode
from schemas.project.project_base import ProjectResponseBase


class ProjectSyncSchema(ProjectResponseBase):
    """
    项目同步内部 schema。

    以 project 主表字段为主体，并补充少量从 /project/all_info 的多项目类型
    extension 中拍平得到的投资/结算相关字段。

    这些字段不是 ProjectResponseBase 原生字段，而是为了让 project 节点在保持
    扁平存储形态的同时，能够参与 project update diff，以及后续的
    settlement_investment 等更新接口。
    """

    implementation_estimate: float | None = Field(None, description="执行概算")
    static_total_investment: float | None = Field(None, description="静态总投资")
    completed_investment: float | None = Field(None, description="已完成投资")
    total_contract_quantity: float | None = Field(None, description="合同总量")
    completed_settlement_quantity: float | None = Field(None, description="已结算量")


class ProjectSyncNode(SyncNode[ProjectSyncSchema]):
    """项目同步节点"""
    node_type = "project"
    schema = ProjectSyncSchema
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
