feat(plugin): 新增 XQ0036 门店员工起调薪处理(0.1.0,依赖 hr_sdk ^0.2);XQ0001 放宽 hr_sdk 兼容范围
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0036 数据层:对接 hr_sdk.wage(接口薄封装),只保留账套名映射等适配逻辑。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, Dict, List, Optional
|
||||
|
||||
from hr_sdk import wage as sdk_wage
|
||||
|
||||
from .. import config
|
||||
|
||||
LOGGER = Callable[[str], None]
|
||||
|
||||
|
||||
class WageApi:
|
||||
"""工资待办处理所需的 HR 接口适配层(无业务判断)。"""
|
||||
|
||||
def __init__(self, client, log: Optional[LOGGER] = None) -> None:
|
||||
self.client = client
|
||||
self.log: LOGGER = log or (lambda msg: None)
|
||||
|
||||
# ---------------- 待办 ----------------
|
||||
def tasks(self, start_date: str = "", end_date: str = "", **filters) -> List[dict]:
|
||||
return sdk_wage.rows(self.client, start_date, end_date, **filters)
|
||||
|
||||
# ---------------- 账套 ----------------
|
||||
def accounts(self) -> Dict[str, dict]:
|
||||
"""账套清单(按名称索引;接口异常时退回内置 ID)。"""
|
||||
try:
|
||||
rows = sdk_wage.accounts(self.client)
|
||||
except Exception as exc: # noqa: BLE001 - 清单失败不阻断映射
|
||||
self.log(f"[WARN] 账套清单接口失败,使用内置映射:{exc}")
|
||||
rows = []
|
||||
result: Dict[str, dict] = {}
|
||||
for row in rows:
|
||||
name = config.text(row.get("ACCOUNT_NAME") or row.get("accountName"))
|
||||
aid = config.text(row.get("ACCOUNT_ID") or row.get("accountId"))
|
||||
if name and aid:
|
||||
result[name] = {"id": aid, "name": name}
|
||||
for name, aid in config.ACCOUNT_ID_FALLBACK.items():
|
||||
result.setdefault(name, {"id": aid, "name": name})
|
||||
return result
|
||||
|
||||
# ---------------- 工资项 / 已起薪 ----------------
|
||||
def account_items(self, account_id: str, staff_id: str, stru_id: str) -> List[dict]:
|
||||
"""账套起薪/调薪项目(itemType 1/5/6/8)。"""
|
||||
return sdk_wage.account_items(self.client, account_id, staff_id, stru_id)
|
||||
|
||||
def started(self, staff_id: str) -> Optional[dict]:
|
||||
"""已起薪记录(第一条;未起薪返回 None)。"""
|
||||
return sdk_wage.started(self.client, staff_id)
|
||||
|
||||
def base_items(self, base_info_id: str) -> List[dict]:
|
||||
"""已起薪的工资项明细(调薪同账套回填原值)。"""
|
||||
return sdk_wage.base_items(self.client, base_info_id)
|
||||
|
||||
def standards(self, staff_id: str, account_id: str, stru_id: str) -> List[dict]:
|
||||
"""账套项目按人员/组织匹配到的工资标准。"""
|
||||
return sdk_wage.standards(self.client, staff_id, account_id, stru_id)
|
||||
|
||||
def staff_base(self, staff_id: str) -> dict:
|
||||
"""员工基础信息(入职日期/薪酬发放单位/纳税单位等)。"""
|
||||
try:
|
||||
return sdk_wage.staff_base(self.client, staff_id)
|
||||
except Exception as exc: # noqa: BLE001 - 缺失时走默认
|
||||
self.log(f"[WARN] 员工基础信息查询失败:{exc}")
|
||||
return {}
|
||||
|
||||
def wage_cards(self, staff_id: str) -> List[dict]:
|
||||
"""工资卡(起薪需要主卡:bankType=cardBank、cardId=cardId)。"""
|
||||
try:
|
||||
return sdk_wage.wage_cards(self.client, staff_id)
|
||||
except Exception as exc: # noqa: BLE001 - 无卡不阻断核对
|
||||
self.log(f"[WARN] 工资卡查询失败:{exc}")
|
||||
return []
|
||||
|
||||
# ---------------- 提交 ----------------
|
||||
def submit_start(self, payload: dict) -> dict:
|
||||
return sdk_wage.submit_start(self.client, payload)
|
||||
|
||||
def submit_change(self, payload: dict) -> dict:
|
||||
return sdk_wage.submit_change(self.client, payload)
|
||||
Reference in New Issue
Block a user