refactor(薪资计算): 重构历史薪资记录数据结构
优化历史薪资记录DataFrame的列结构,增加更多详细信息字段 统一数据填充方式,使用列名直接赋值提高可读性
This commit is contained in:
parent
f87b4186bb
commit
2b7d8ebb4e
20
main.py
20
main.py
@ -344,29 +344,37 @@ def main():
|
|||||||
fill_prompt_info(ws, promote)# 填充晋升信息
|
fill_prompt_info(ws, promote)# 填充晋升信息
|
||||||
|
|
||||||
# 根据规则匹配职级薪资
|
# 根据规则匹配职级薪资
|
||||||
History_pd = pd.DataFrame(columns=["时间", "职务", "职务工资", "级别档次", "级别工资", "工资合计", "变动原因", "晋升备注"])
|
History_pd = pd.DataFrame(columns=[
|
||||||
|
"身份证号码", "姓名", # 统一填入
|
||||||
|
"变动后时间", "变动后职务", "变动原因", "晋升备注", # 直接填入
|
||||||
|
"工龄", "五年1级年份", "两年1档年份", # 简单计算更新
|
||||||
|
"变动后级别档次", "变动后职务工资", "变动后级别工资", "变动后津贴工资", # 复杂计算更新
|
||||||
|
"变动前时间", "变动前职务", "变动前级别档次", "变动前职务工资", "变动前级别工资", "变动前津贴工资"]) # 排序后(最后)更新
|
||||||
# 添加入职记录
|
# 添加入职记录
|
||||||
History_pd.loc[len(History_pd)] = [row["入职时间"], row["初始职务"], "", row["入职时的初始级别"], "", "", "套改/定级", ""]
|
History_pd.loc[len(History_pd), ["变动后时间","变动后职务","变动原因","变动后级别档次"]] = [
|
||||||
|
row["入职时间"],row["初始职务"],"套改/定级",row["入职时的初始级别"]]
|
||||||
for index, prow in promote.iterrows(): # 添加晋升记录
|
for index, prow in promote.iterrows(): # 添加晋升记录
|
||||||
History_pd.loc[len(History_pd)] = [prow["工资执行时间"]+relativedelta(hours=prow["任职时间"].month,minutes=prow["任职时间"].day), prow["新职务"], "", "", "", "", "晋升", f"任{prow['新职务']} {prow['变动批注'] if pd.notna(prow['变动批注']) else ''}"]
|
History_pd.loc[len(History_pd),["变动后时间","变动后职务","变动原因","晋升备注"]] = [
|
||||||
|
prow["工资执行时间"]+relativedelta(hours=prow["任职时间"].month,minutes=prow["任职时间"].day),
|
||||||
|
prow["新职务"],"晋升",f"任{prow['新职务']} {prow['变动批注'] if pd.notna(prow['变动批注']) else ''}"]
|
||||||
try:
|
try:
|
||||||
calctime=row["晋档起始"] + relativedelta(minute=1)
|
calctime=row["晋档起始"] + relativedelta(minute=1)
|
||||||
while True: # 添加晋档记录
|
while True: # 添加晋档记录
|
||||||
calctime += relativedelta(years=row["晋档间隔"])
|
calctime += relativedelta(years=row["晋档间隔"])
|
||||||
if calctime > NOWTIME:
|
if calctime > NOWTIME:
|
||||||
break
|
break
|
||||||
History_pd.loc[len(History_pd)] = [calctime, "", "", "", "", "", "两年晋档", ""]
|
History_pd.loc[len(History_pd),["变动后时间","变动原因"]] = [calctime,"两年晋档"]
|
||||||
calctime=row["晋级起始"]
|
calctime=row["晋级起始"]
|
||||||
while True: # 添加晋级记录
|
while True: # 添加晋级记录
|
||||||
calctime += relativedelta(years=row["晋级间隔"])
|
calctime += relativedelta(years=row["晋级间隔"])
|
||||||
if calctime > NOWTIME:
|
if calctime > NOWTIME:
|
||||||
break
|
break
|
||||||
History_pd.loc[len(History_pd)] = [calctime, "", "", "", "", "", "五年晋级", ""]
|
History_pd.loc[len(History_pd),["变动后时间","变动原因"]] = [calctime,"五年晋级"]
|
||||||
except:
|
except:
|
||||||
raise Exception(f"晋级、档起始或间隔时间格式错误:{row['晋级起始']}-{row['晋档起始']}-{row['晋级间隔']}-{row['晋档间隔']}")
|
raise Exception(f"晋级、档起始或间隔时间格式错误:{row['晋级起始']}-{row['晋档起始']}-{row['晋级间隔']}-{row['晋档间隔']}")
|
||||||
for rule in Rule_Level: # 工资调标
|
for rule in Rule_Level: # 工资调标
|
||||||
if row["入职时间"] < rule["start"]:
|
if row["入职时间"] < rule["start"]:
|
||||||
History_pd.loc[len(History_pd)] = [rule["start"], "", "", "", "", "", "工资调标", ""]
|
History_pd.loc[len(History_pd),["变动后时间","变动原因"]] = [rule["start"], "工资调标"]
|
||||||
History_pd = History_pd.sort_values(by="时间").reset_index(drop=True)
|
History_pd = History_pd.sort_values(by="时间").reset_index(drop=True)
|
||||||
|
|
||||||
if History_pd.at[0,"时间"] != row["入职时间"]:
|
if History_pd.at[0,"时间"] != row["入职时间"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user