diff --git a/oo_list_manager/views/ir_ui_view.xml b/oo_list_manager/views/ir_ui_view.xml
index 3858357dc..3ff6633d6 100644
--- a/oo_list_manager/views/ir_ui_view.xml
+++ b/oo_list_manager/views/ir_ui_view.xml
@@ -9,6 +9,7 @@
+
diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py
index dc675ba0f..6f1439560 100644
--- a/yuthon_salary/models/inherit_hr_payslip.py
+++ b/yuthon_salary/models/inherit_hr_payslip.py
@@ -150,7 +150,7 @@ class InheritHrPayslip(models.Model):
medical_insurance_base = fields.Float(string='医疗保险缴费基数(单位缴纳)')
medical_insurance_payable = fields.Float(string='医疗保险应缴金额(单位缴纳)')
- performance_deduction = fields.Float(string='扣发绩效奖金', compute='_compute_deduction', store=True)
+ performance_deduction = fields.Float(string='扣发绩效奖金')
commuting_deduction = fields.Float(string='扣发通信补贴', compute='_compute_deduction', store=True)
base_salary_deduction = fields.Float(string='扣发基本工资', compute='_compute_deduction', store=True)
specialized_deduction = fields.Float(string='累计专项扣除')
diff --git a/yuthon_salary/views/inherit_hr_payslip_views.xml b/yuthon_salary/views/inherit_hr_payslip_views.xml
index 6573d5176..d8532eb02 100644
--- a/yuthon_salary/views/inherit_hr_payslip_views.xml
+++ b/yuthon_salary/views/inherit_hr_payslip_views.xml
@@ -372,58 +372,67 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -439,28 +448,17 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -468,14 +466,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -491,41 +508,49 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py
index cc893c612..698364a3a 100644
--- a/yuthon_salary/wizard/salary_compute_wizard.py
+++ b/yuthon_salary/wizard/salary_compute_wizard.py
@@ -67,11 +67,11 @@ class SalaryComputeWizard(models.Model):
def confirm(self):
for employee in self.employee_ids:
- detail_id = self.env['hr.attendance.month.detail'].search([('employee_id', '=', employee.id),
- ('current_year', '=', self.select_year),
- ('current_month', '=', self.select_time)])
- if detail_id.state == 'unconfirmed':
- raise UserError(f'{employee.name}的{self.select_time}考勤还未确认,请先确认考勤再进行工资计算!')
+ # detail_id = self.env['hr.attendance.month.detail'].search([('employee_id', '=', employee.id),
+ # ('current_year', '=', self.select_year),
+ # ('current_month', '=', self.select_time)])
+ # if detail_id.state == 'unconfirmed':
+ # raise UserError(f'{employee.name}的{self.select_time}考勤还未确认,请先确认考勤再进行工资计算!')
is_bold = self.check_employee_dates(employee)
contract_id = self.env['hr.contract'].search([('employee_id', '=', employee.id)], limit=1)
year = int(self.select_year)
@@ -136,7 +136,11 @@ class SalaryComputeWizard(models.Model):
for internship_id in internship_ids:
employee = internship_id.employee_id
contract = employee.contract_id
-
+ # 更改扣发绩效奖金
+ performance_deduction = self.salary_performance_deduction(employee, self.select_year, self.select_time, internship_id.performance_bonuses)
+ internship_id.write({
+ 'performance_deduction': performance_deduction,
+ })
# 获取离职日期
turnover_date = employee.contract_id.date_end
start_date = fields.Date.from_string(start_date)
@@ -192,66 +196,75 @@ class SalaryComputeWizard(models.Model):
internship_days = self._process_shift_days(internship_start, internship_end)
work_days = 21.75 - internship_days
- if internship_id.line_ids:
- if is_probation and not internship_id.employee_id.is_annual_salary:
- target_names = {
- '基本工资': 'base_salary',
- '职级工资': 'rank_salary',
- '岗位工资': 'position_salary',
- '预发绩效奖金': 'performance_bonuses',
- '通讯补贴': 'commuting_allowance',
- '工龄工资': 'seniority_salary',
- '工会会费': 'union_dues',
- '住房公积金': 'housing_provident_fund',
- '企业(职业)年金': 'b_year', # 企业年金
- }
- for line in internship_id.line_ids:
- if line.name in target_names:
- field_name = target_names[line.name]
- if field_name == 'performance_bonuses':
- if work_days != days:
- result = round(line.total * work_days / days)
- else:
- result = 0
- elif field_name in ['commuting_allowance', 'seniority_salary']:
- if work_days != days:
- result = line.total * internship_days / days + line.total * work_days / days
- else:
- result = line.total * internship_days / days
- elif field_name in ['rank_salary', 'base_salary']:
- if work_days != days:
- result = round(math.ceil(line.total * 0.8) * internship_days / days + line.total * work_days / days)
- else:
- result = line.total * 0.8 * internship_days / days
- elif field_name == 'union_dues': # 单独处理工会会费
- base_salary = getattr(internship_id, 'base_salary', 0)
- result = base_salary * 0.005
- elif field_name == 'housing_provident_fund': # 单独处理住房公积金
- # 获取合同入职日期的年份和月份
- contract_year = str(contract_start_date.year)
- contract_month = str(contract_start_date.month)
- # 判断是否为入职当月
- if contract_year == self.select_year and contract_month == self.select_time:
- result = 0 # 入职当月住房公积金为0
- elif field_name == 'b_year':
- # 获取合同转正日期的年份和月份
- if contract_end_date: # 确保转正日期存在
- contract_end_year = str(contract_end_date.year)
- contract_end_month = str(contract_end_date.month)
- # 判断是否为转正当月
- if contract_end_year == self.select_year and contract_end_month == self.select_time:
- last_year_salary = internship_id.employee_id.last_year_salary or 0
- result = last_year_salary * 0.002
+ if internship_id.line_ids:
+ if is_probation and not internship_id.employee_id.is_annual_salary:
+ target_names = {
+ '基本工资': 'base_salary',
+ '职级工资': 'rank_salary',
+ '岗位工资': 'position_salary',
+ '预发绩效奖金': 'performance_bonuses',
+ '通讯补贴': 'commuting_allowance',
+ '工龄工资': 'seniority_salary',
+ '工会会费': 'union_dues',
+ '住房公积金': 'housing_provident_fund',
+ '企业(职业)年金': 'b_year', # 企业年金
+ }
+ for line in internship_id.line_ids:
+ if line.name in target_names:
+ field_name = target_names[line.name]
+ # 初始化result为默认值,避免未赋值的情况
+ result = 0
+
+ if field_name == 'performance_bonuses':
+ if work_days != days:
+ result = round(line.total * work_days / days)
else:
result = 0
- else:
- if work_days != days:
- result = line.total * 0.8 * internship_days / days + line.total * work_days / days
+ elif field_name in ['commuting_allowance', 'seniority_salary']:
+ if work_days != days:
+ result = line.total * internship_days / days + line.total * work_days / days
+ else:
+ result = line.total * internship_days / days
+ elif field_name in ['rank_salary', 'base_salary']:
+ if work_days != days:
+ result = round(math.ceil(
+ line.total * 0.8) * internship_days / days + line.total * work_days / days)
+ else:
+ result = line.total * 0.8 * internship_days / days
+ elif field_name == 'union_dues': # 单独处理工会会费
+ base_salary = getattr(internship_id, 'base_salary', 0)
+ result = base_salary * 0.005
+ elif field_name == 'housing_provident_fund': # 单独处理住房公积金
+ # 获取合同入职日期的年份和月份
+ contract_year = str(contract_start_date.year)
+ contract_month = str(contract_start_date.month)
+ # 判断是否为入职当月
+ if contract_year == self.select_year and contract_month == self.select_time:
+ result = 0 # 入职当月住房公积金为0
+ # 新增:非入职当月时的默认值(根据业务需求调整)
+ else:
+ result = line.total # 或其他合理默认值
+ elif field_name == 'b_year':
+ # 获取合同转正日期的年份和月份
+ if contract_end_date: # 确保转正日期存在
+ contract_end_year = str(contract_end_date.year)
+ contract_end_month = str(contract_end_date.month)
+ # 判断是否为转正当月
+ if contract_end_year == self.select_year and contract_end_month == self.select_time:
+ last_year_salary = internship_id.employee_id.last_year_salary or 0
+ result = last_year_salary * 0.002
+ else:
+ result = 0 # 非转正当月默认值
+ else:
+ result = 0 # 无转正日期时的默认值
else:
- result = line.total * 0.8 * internship_days / days
+ if work_days != days:
+ result = line.total * 0.8 * internship_days / days + line.total * work_days / days
+ else:
+ result = line.total * 0.8 * internship_days / days
- setattr(internship_id, field_name, result)
- line.write({'total': result})
+ setattr(internship_id, field_name, result)
+ line.write({'total': result})
if is_turnover:
target_names = {
@@ -359,4 +372,21 @@ class SalaryComputeWizard(models.Model):
)
# 满足任一条件即返回 True
- return entry_matches or confirmation_matches or retire_matches
\ No newline at end of file
+ return entry_matches or confirmation_matches or retire_matches
+
+ def salary_performance_deduction(self, employee, selected_year, selected_month, performance_bonuses):
+ attendance_month_obj = self.env["hr.attendance.month.detail"].search([
+ ('employee_id', '=', employee.id),
+ ('current_year', '=', selected_year),
+ ('current_month', '=', selected_month),
+ ('state', '=', 'confirmed')
+ ], limit=1)
+ if attendance_month_obj:
+ year = int(selected_year)
+ month = int(selected_month)
+ last_day = calendar.monthrange(year, month)[1]
+ total_days = last_day
+ result = (performance_bonuses / total_days) * attendance_month_obj.maternity_leave if total_days != 0 else 0.0
+ return round(result, 2)
+ else:
+ return 0.00
\ No newline at end of file