from __future__ import annotations

ORGANIZATION_DEFINITIONS = [
    {
        "unit_code": "ORG-ROOT",
        "name": "星海科技",
        "unit_type": "company",
        "parent_code": None,
        "cost_center": "CC-0000",
        "location": "上海",
        "manager_name": "李文静",
    },
    {
        "unit_code": "TECH-DEPT",
        "name": "技术部",
        "unit_type": "department",
        "parent_code": "ORG-ROOT",
        "cost_center": "CC-6100",
        "location": "北京",
        "manager_name": "吴磊",
    },
    {
        "unit_code": "MARKET-DEPT",
        "name": "市场部",
        "unit_type": "department",
        "parent_code": "ORG-ROOT",
        "cost_center": "CC-4100",
        "location": "上海",
        "manager_name": "刘思雨",
    },
    {
        "unit_code": "FINANCE-DEPT",
        "name": "财务部",
        "unit_type": "department",
        "parent_code": "ORG-ROOT",
        "cost_center": "CC-2100",
        "location": "上海",
        "manager_name": "张晓晴",
    },
    {
        "unit_code": "HR-DEPT",
        "name": "人力资源部",
        "unit_type": "department",
        "parent_code": "ORG-ROOT",
        "cost_center": "CC-3200",
        "location": "杭州",
        "manager_name": "陈硕",
    },
    {
        "unit_code": "PRODUCTION-DEPT",
        "name": "生产部",
        "unit_type": "department",
        "parent_code": "ORG-ROOT",
        "cost_center": "CC-7200",
        "location": "南京",
        "manager_name": "梁雨辰",
    },
    {
        "unit_code": "PRESIDENT-OFFICE",
        "name": "总裁办",
        "unit_type": "department",
        "parent_code": "ORG-ROOT",
        "cost_center": "CC-1000",
        "location": "上海",
        "manager_name": "李文静",
    },
]

CANONICAL_DEPARTMENT_CODES = (
    "TECH-DEPT",
    "MARKET-DEPT",
    "FINANCE-DEPT",
    "HR-DEPT",
    "PRODUCTION-DEPT",
    "PRESIDENT-OFFICE",
)

LEGACY_ORGANIZATION_UNIT_CODE_MAP = {
    "RND-CENTER": "TECH-DEPT",
    "SALES-SOUTH": "MARKET-DEPT",
    "SALES-EAST": "MARKET-DEPT",
    "MKT-BRAND": "MARKET-DEPT",
    "FIN-SSC": "FINANCE-DEPT",
    "AUDIT-RISK": "FINANCE-DEPT",
    "HR-OD": "HR-DEPT",
    "OPS-ADMIN": "PRODUCTION-DEPT",
    "EXEC-OFFICE": "PRESIDENT-OFFICE",
}


def normalize_organization_unit_code(unit_code: str | None) -> str | None:
    if not unit_code:
        return unit_code
    return LEGACY_ORGANIZATION_UNIT_CODE_MAP.get(unit_code, unit_code)


EMPLOYEE_PROFILE_REPAIRS = [
    {
        "employee_no": "E90919",
        "name": "曹笑竹",
        "email": "caoxiaozhu@xf.com",
        "location": "武汉",
        "position": "财务智能化产品经理",
        "grade": "P5",
        "organization_unit_code": "TECH-DEPT",
        "manager_employee_no": "E11745",
        "finance_owner_name": "研发财务BP",
        "cost_center": "CC-6112",
        "employment_status": "在职",
        "sync_state": "已同步",
        "role_codes": ["user"],
    },
]
