Merge branch 'dev' of https://gitee.com/jinan-pengyusen-data/gzth into dev_wang
This commit is contained in:
@@ -857,7 +857,62 @@ class HolidaysRequestBatch(models.Model):
|
||||
('employee_id', '=', record.users_id.employee_ids.id),
|
||||
('vacation_date', '=', vacation_date.replace(day=1))
|
||||
], limit=1)
|
||||
if not reports_id:
|
||||
record.holiday_allowance = ""
|
||||
continue
|
||||
holiday_configs = [
|
||||
("年假", "previous_year", "year_distribution"),
|
||||
("补休", "previous_year1", "this_year1"),
|
||||
("育儿假", None, "remaining_parental_leave")
|
||||
]
|
||||
|
||||
for name, prev_field, curr_field in holiday_configs:
|
||||
parts = []
|
||||
# ========== 核心修改:年假专属扣减逻辑 ==========
|
||||
if name == "年假" and prev_field and curr_field:
|
||||
used_this_year = getattr(reports_id, 'used_this_year', 0.0) # 本年已用
|
||||
prev_value = getattr(reports_id, prev_field, 0.0) # 上年结余(previous_year)
|
||||
curr_value = getattr(reports_id, curr_field, 0.0) # 本年额度(year_distribution)
|
||||
valid_date = getattr(reports_id, 'valid_date', None) # previous_year的有效期
|
||||
|
||||
is_prev_valid = True
|
||||
if valid_date:
|
||||
is_prev_valid = date.today() <= valid_date
|
||||
|
||||
remain_used = used_this_year
|
||||
final_prev = prev_value
|
||||
final_curr = curr_value
|
||||
|
||||
if is_prev_valid and final_prev > 0 and remain_used > 0:
|
||||
# 扣减previous_year:取剩余已用和previous_year的较小值
|
||||
deduct_prev = min(remain_used, final_prev)
|
||||
final_prev -= deduct_prev
|
||||
remain_used -= deduct_prev
|
||||
|
||||
# 4. 剩余已用扣减year_distribution
|
||||
if remain_used > 0 and final_curr > 0:
|
||||
deduct_curr = min(remain_used, final_curr)
|
||||
final_curr -= deduct_curr
|
||||
remain_used -= deduct_curr
|
||||
|
||||
# 5. 根据扣减后的值判断是否显示
|
||||
if final_prev > 0:
|
||||
parts.append(f"上年结余{final_prev:.3f}天")
|
||||
if final_curr > 0:
|
||||
parts.append(f"本年剩余{final_curr:.3f}天")
|
||||
else:
|
||||
if prev_field:
|
||||
prev_value = getattr(reports_id, prev_field, 0.0)
|
||||
if prev_value > 0:
|
||||
parts.append(f"上年结余{prev_value:.3f}天")
|
||||
curr_value = getattr(reports_id, curr_field, 0.0)
|
||||
if curr_value > 0:
|
||||
parts.append(f"本年剩余{curr_value:.3f}天")
|
||||
|
||||
if parts:
|
||||
result_parts.append(f"{name}:{','.join(parts)}")
|
||||
|
||||
record.holiday_allowance = "\n".join(result_parts)
|
||||
|
||||
def action_print_leave_batch(self):
|
||||
"""按钮触发打印请假单"""
|
||||
|
||||
@@ -51,6 +51,17 @@ class YuthonMedicalManage(models.Model):
|
||||
elif employee.marital == 'married':
|
||||
final_quota += rule.allowance_married_women
|
||||
|
||||
entry_date = fields.Date.from_string(employee.entry_date)
|
||||
current_year = current_date.year
|
||||
entry_year = entry_date.year
|
||||
|
||||
# 判断是否为当年入职
|
||||
if entry_year == current_year:
|
||||
entry_month = entry_date.month
|
||||
ratio = (12 - entry_month + 1) / 12
|
||||
final_quota = final_quota * ratio
|
||||
final_quota = max(final_quota, 0.0)
|
||||
|
||||
if rule.cap > 0:
|
||||
final_quota = min(base_quota, rule.cap)
|
||||
|
||||
@@ -111,6 +122,7 @@ class YuthonMedicalManage(models.Model):
|
||||
'prev_last_year_balance': prev_last_year_rec.current_year_remaining,
|
||||
})
|
||||
|
||||
|
||||
def button_details(self):
|
||||
form_id = self.env.ref('yuthon_hr_employee.view_yuthon_medical_manage_form').id
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user