unis_hrms/app/core/constants.py

32 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""跨模块共享的业务常量:避免「合同续签提醒窗口」在不同接口里取不同天数。"""
from __future__ import annotations
#: 合同续签提醒窗口(天)。到期看板、合同列表标记、自助首页共用同一口径。
RENEW_WINDOW_DAYS = 90
#: 性别:库里统一存英文码(male / female),Excel 导入、历史数据与表单沿用中文标签,
#: 所有写入路径先经 gender_code() 归一,图表分组和档案展示才不会出现两套口径。
GENDER_CODES = {
"男": "male", "女": "female", "其他": "other",
"male": "male", "female": "female", "other": "other",
}
GENDER_LABELS = {"male": "男", "female": "女", "other": "其他"}
def gender_code(value):
"""任意来源的性别写法 → 库内英文码;未知值原样保留,不做静默丢弃。"""
if value in (None, ""):
return None
text = str(value).strip()
return GENDER_CODES.get(text, text)
def gender_label(value):
"""库内英文码 → 中文标签,供导出 / 报表使用。"""
if value in (None, ""):
return ""
return GENDER_LABELS.get(str(value).strip(), str(value))