Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
69e2b47cf1 | |||
feb14f2400 |
22
main.py
22
main.py
@ -41,7 +41,7 @@ def custom_date_parser(x):
|
||||
except:
|
||||
return x
|
||||
|
||||
def format_time(dt,info):
|
||||
def format_time(dt,info=""):
|
||||
try:
|
||||
return dt.strftime("%Y.%m")
|
||||
except:
|
||||
@ -217,7 +217,8 @@ def level_salary(level:str, time):
|
||||
return tmp["salary"]
|
||||
except:
|
||||
logging.warning(f"职级[{level}]在[{time}]时不存在工资规则")
|
||||
logging.warning(f"时间[{time}]时不存在职级工资规则")
|
||||
return 0
|
||||
logging.warning(f"时间[{time}]时不存在职级工资规则")
|
||||
return 0
|
||||
|
||||
def role_limit(role:str):
|
||||
@ -275,8 +276,8 @@ def fill_prompt_info(ws, promote):# 填充晋升信息
|
||||
|
||||
def add_history(History_pd, row, promote):
|
||||
# 添加入职记录
|
||||
History_pd.loc[len(History_pd), ["变动后时间","变动后职务","变动原因","变动后级别档次"]] = [
|
||||
row["入职时间"],row["初始职务"],"套改/定级",row["入职时的初始级别"]]
|
||||
History_pd.loc[len(History_pd), ["变动后时间","变动后职务","变动原因","变动后级别档次","五年1级年份","两年1档年份"]] = [
|
||||
row["入职时间"],row["初始职务"],"套改/定级",row["入职时的初始级别"],format_time(row['晋级起始']),format_time(row['晋档起始'])]
|
||||
for index, prow in promote.iterrows(): # 添加晋升记录
|
||||
History_pd.loc[len(History_pd),["变动后时间","变动后职务","变动原因","晋升备注"]] = [
|
||||
prow["工资执行时间"]+relativedelta(hours=prow["任职时间"].month,minutes=prow["任职时间"].day),
|
||||
@ -288,16 +289,16 @@ def add_history(History_pd, row, promote):
|
||||
calctime += relativedelta(years=row["晋档间隔"])
|
||||
if calctime > NOWTIME:
|
||||
break
|
||||
History_pd.loc[len(History_pd),["变动后时间","变动原因"]] = [
|
||||
calctime,"两年晋档"]
|
||||
History_pd.loc[len(History_pd),["变动后时间","变动原因","两年1档年份"]] = [
|
||||
calctime,"两年晋档",format_time(calctime)]
|
||||
calctime=row["晋级起始"]
|
||||
# 添加晋级记录
|
||||
while True:
|
||||
calctime += relativedelta(years=row["晋级间隔"])
|
||||
if calctime > NOWTIME:
|
||||
break
|
||||
History_pd.loc[len(History_pd),["变动后时间","变动原因"]] = [
|
||||
calctime,"五年晋级"]
|
||||
History_pd.loc[len(History_pd),["变动后时间","变动原因","五年1级年份"]] = [
|
||||
calctime,"五年晋级",format_time(calctime)]
|
||||
except:
|
||||
raise Exception(f"晋级、档起始或间隔时间格式错误:{row['晋级起始']}-{row['晋档起始']}-{row['晋级间隔']}-{row['晋档间隔']}")
|
||||
# 工资调标
|
||||
@ -315,8 +316,6 @@ def add_history(History_pd, row, promote):
|
||||
History_pd["身份证号码"] = row["身份证号码"]
|
||||
History_pd["姓名"] = row["姓名"]
|
||||
History_pd["工龄"] = History_pd.apply(lambda x: calculate_seniority(row, x["变动后时间"].year), axis=1)
|
||||
History_pd["五年1级年份"] = History_pd.apply(lambda x: x["变动后时间"].year - row["晋级起始"].year, axis=1)
|
||||
History_pd["两年1档年份"] = History_pd.apply(lambda x: x["变动后时间"].year - row["晋档起始"].year, axis=1)
|
||||
|
||||
def calc_history(History_pd, row):
|
||||
# 复杂数据计算
|
||||
@ -330,6 +329,8 @@ def calc_history(History_pd, row):
|
||||
History_pd.at[index, "变动前级别工资"] = History_pd.at[index-1, "变动后级别工资"]
|
||||
History_pd.at[index, "变动前津贴工资"] = History_pd.at[index-1, "变动后津贴工资"]
|
||||
History_pd.at[index, "变动前工资合计"] = History_pd.at[index-1, "变动后工资合计"]
|
||||
History_pd.at[index, "五年1级年份"] = History_pd.at[index-1, "五年1级年份"] if pd.isna(History_pd.at[index, "五年1级年份"]) else History_pd.at[index, "五年1级年份"]
|
||||
History_pd.at[index, "两年1档年份"] = History_pd.at[index-1, "两年1档年份"] if pd.isna(History_pd.at[index, "两年1档年份"]) else History_pd.at[index, "两年1档年份"]
|
||||
# 继承名称
|
||||
if pd.isna(hrow["变动后职务"]):
|
||||
History_pd.at[index,"变动后职务"] = History_pd.at[index,"变动前职务"]
|
||||
@ -345,7 +346,6 @@ def calc_history(History_pd, row):
|
||||
History_pd.at[index, "变动后级别档次"] = f"{jb}-{dc+1}"
|
||||
elif hrow["变动原因"] == "五年晋级":
|
||||
if jb-1 < 1 or jb-1 < role_limit(History_pd.iloc[index]["变动后职务"]):
|
||||
|
||||
History_pd.at[index, "变动后级别档次"] = f"{jb}-{dc+1}"
|
||||
else:
|
||||
History_pd.at[index, "变动后级别档次"] = f"{jb-1}-{dc-1}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user