From 547db6e7a2f90ce111b1a422d1b919cd892fdaaa Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Thu, 3 Jul 2025 17:40:13 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/yuthon_hr_employee.py | 51 +++++++++++++++++--
.../views/yuthon_hr_employee_views.xml | 5 ++
yuthon_salary/models/inherit_hr_payslip.py | 2 +
.../models/yuthon_payroll_project.py | 10 ++--
yuthon_salary/wizard/salary_compute_wizard.py | 3 +-
5 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py
index 675b31ab2..a9d75cc45 100644
--- a/yuthon_hr_employee/models/yuthon_hr_employee.py
+++ b/yuthon_hr_employee/models/yuthon_hr_employee.py
@@ -167,6 +167,10 @@ class YuthonHrEmployee(models.Model):
# 工资计算分组
salary_group_id = fields.Many2one('yuthon.salary.group', string="工资单分组", store=True)
salary_date = fields.Date(string="薪资计算时间", store=True)
+ salary_month = fields.Selection([('1', '一月'), ('2', '二月'), ('3', '三月'), ('4', '四月'),
+ ('5', '五月'), ('6', '六月'), ('7', '七月'), ('8', '八月'),
+ ('9', '九月'), ('10', '十月'), ('11', '十一月'),
+ ('12', '十二月')], string='薪资计算月份')
salary_year_jin_ids = fields.Many2many(
'hr.employee', # 自关联到hr.employee
relation='hr_employee_salary_year_jin_rel', # 显式指定关联表名
@@ -188,6 +192,12 @@ class YuthonHrEmployee(models.Model):
last_month_base_salary_deduction = fields.Float(string="上月基本薪资扣款")
last_month_performance_deduction = fields.Float(string="上月绩效扣款")
last_month_commuting_deduction = fields.Float(string='上月通信扣款')
+ # 薪资计算 基数
+ salary_medical_insurance = fields.Float(string='薪资医疗费基数', compute='_compute_insurance_salary')
+ salary_insurance = fields.Float(string='薪资养老费基数', compute='_compute_insurance_salary')
+ salary_work_injury_insurance = fields.Float(string='薪资保险金基数', compute='_compute_insurance_salary')
+ salary_housing_fund = fields.Float(string='薪资公积金基数', compute='_compute_insurance_salary')
+ # 显示基数
medical_insurance_base = fields.Float(string='基本医疗费基数', compute='_compute_insurance_bases')
pension_insurance_base = fields.Float(string='基本养老费基数', compute='_compute_insurance_bases')
work_injury_insurance_base = fields.Float(string='失业保险金基数', compute='_compute_insurance_bases')
@@ -200,6 +210,7 @@ class YuthonHrEmployee(models.Model):
subsidy_amount = fields.Float(string="岗位补贴金额", compute='_compute_subsidy_amount', store=True)
security_amount = fields.Float(string="安全委员会金额", compute='_compute_subsidy_amount', store=True)
+ quality_inspector_amount = fields.Float(string="质检员金额", compute='_compute_subsidy_amount', store=True)
@api.depends('quota_issued', 'user_year')
def _compute_remainder_year(self):
@@ -213,6 +224,7 @@ class YuthonHrEmployee(models.Model):
def _compute_subsidy_amount(self):
for record in self:
amount = 0
+ quality_amount = 0
# 获取主角色名称
primary_role_name = record.user_role_id.name if record.user_role_id else ''
# 获取所有辅助角色名称列表
@@ -244,7 +256,7 @@ class YuthonHrEmployee(models.Model):
for cert in record.skills_certificates_ids
)
if quality and department_name == '仓储组':
- amount += 100
+ quality_amount += 100
if department_name == '领导班子':
record.security_amount = 0
@@ -254,7 +266,7 @@ class YuthonHrEmployee(models.Model):
record.security_amount = 0
record.subsidy_amount = amount
-
+ record.quality_inspector_amount = quality_amount
@api.depends('converted', 'salary_year_jin_ids')
def _compute_total_coefficients(self):
for record in self:
@@ -291,7 +303,7 @@ class YuthonHrEmployee(models.Model):
def _compute_overtime_this_month(self):
for employee in self:
employee.overtime_this_month = employee.normal_overtime_hours + employee.weekend_overtime_hours + employee.holiday_overtime_hours
-
+ # 根据当前月份来选择具体的值
@api.depends('social_base_on', 'social_base_off')
def _compute_insurance_bases(self):
current_month = datetime.now().month
@@ -322,6 +334,39 @@ class YuthonHrEmployee(models.Model):
else:
setattr(record, field_name, base)
+ # 根据薪资计算选择的月份 来获取确定的值
+ @api.depends('social_base_on', 'social_base_off', 'salary_month')
+ def _compute_insurance_salary(self):
+ insurance_names = {
+ '薪资医疗保险费': 'salary_medical_insurance',
+ '薪资养老保险费': 'salary_insurance',
+ '薪资保险费': 'salary_work_injury_insurance',
+ '薪资公积金': 'salary_housing_fund'
+ }
+ name_mapping = {
+ '基本医疗保险费': '薪资医疗保险费',
+ '基本养老保险费': '薪资养老保险费',
+ '失业保险费': '薪资保险费',
+ '住房公积金': '薪资公积金'
+ }
+ insurance_records = self.env['yuthon.payroll.insurances'].search([('name', 'in',['基本医疗保险费', '基本养老保险费', '失业保险费', '住房公积金'])])
+ for record in self:
+ for field_name in insurance_names.values():
+ setattr(record, field_name, 0)
+ base = record.social_base_on if 1 <= int(record.salary_month) <= 6 else record.social_base_off
+ for insurance in insurance_records:
+ insurance_name_key = name_mapping.get(insurance.name)
+ field_name = insurance_names.get(insurance_name_key)
+ if field_name == 'housing_fund_base' and record.name in ['郭爱娣', '黄炎方']:
+ record.housing_fund_base = 4000
+ continue
+ if base > insurance.employee_base_ceiling:
+ setattr(record, field_name, insurance.employee_base_ceiling)
+ elif base < insurance.employee_base_floor:
+ setattr(record, field_name, insurance.employee_base_floor)
+ else:
+ setattr(record, field_name, base)
+
@api.onchange('job_id')
def _onchange_job_id(self):
if self.job_id:
diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
index 1713d31e0..3e576d39b 100644
--- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
+++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
@@ -162,6 +162,11 @@
+
+
+
+
+
diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py
index 071fe4cd2..a96ea047c 100644
--- a/yuthon_salary/models/inherit_hr_payslip.py
+++ b/yuthon_salary/models/inherit_hr_payslip.py
@@ -182,6 +182,8 @@ class InheritHrPayslip(models.Model):
rec.full_attendance_award = line.total
if line.name == '加班费':
rec.overtime_pay = line.total
+ if line.name == '质检员津贴':
+ rec.quality_allowance = line.total
if line.name == '误餐费':
rec.meal_misunderstanding_fee = line.total
if line.name == '事假':
diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py
index 96ef357ee..d279e6d90 100644
--- a/yuthon_salary/models/yuthon_payroll_project.py
+++ b/yuthon_salary/models/yuthon_payroll_project.py
@@ -96,7 +96,7 @@ class YuthonPayrollCommon(models.Model):
if ins.name == '环境作业津贴':
formula_salary = "result = 0"
if ins.name == '质检员津贴':
- formula_salary = "result = 0"
+ formula_salary = "result = employee.quality_inspector_amount"
if ins.name == '工会会费' and ins.company_id.name in ['集团本部', '天河物管']:
formula_salary = "result = round((payslip.base_salary * 0.005), 2)"
if ins.name == '工会会费' and ins.company_id.name == '天河粮储':
@@ -215,19 +215,19 @@ class YuthonPayrollInsurances (models.Model):
code = 'None'
if ins.name == '基本医疗保险费':
code = 'JBYLIAO'
- formula_salary = "result = employee.medical_insurance_base * " + str(number)
+ formula_salary = "result = employee.salary_medical_insurance * " + str(number)
if ins.name == '基本养老保险费':
code = 'JBYLAO'
- formula_salary = "result = employee.pension_insurance_base * " + str(number)
+ formula_salary = "result = employee.salary_insurance * " + str(number)
if ins.name == '失业保险费':
code = 'SYBX'
- formula_salary = "result = employee.work_injury_insurance_base * " + str(number)
+ formula_salary = "result = employee.salary_work_injury_insurance * " + str(number)
if ins.name == '工伤保险费':
code = 'GSBX'
formula_salary = "result = employee.social_base_on * " + str(number)
if ins.name == '住房公积金':
code = 'ZFGJJ'
- formula_salary = "result = (round((employee.housing_fund_base * " + str(number) + "), 0)) if employee.is_accum_salary else 0"
+ formula_salary = "result = (round((employee.salary_housing_fund * " + str(number) + "), 0)) if employee.is_accum_salary else 0"
if ins.name == '企业(职业)年金':
if ins.company_id.name == '天河物管':
code = 'WGQYNJ'
diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py
index 44fa97756..f62db3d6a 100644
--- a/yuthon_salary/wizard/salary_compute_wizard.py
+++ b/yuthon_salary/wizard/salary_compute_wizard.py
@@ -41,7 +41,7 @@ class SalaryComputeWizard(models.Model):
('company_id', '=', self.company_id.id),
('is_salary', '=', True),
('entry_date', '<=', start_date),
- ('contract_id.state', 'not in', ['draft', 'cancel']),
+ ('contract_id.state', 'not in', ['draft', 'cancel', 'close']),
('contract_id', '!=', False),
])
self.employee_ids = [(6, 0, employees.ids)]
@@ -91,6 +91,7 @@ class SalaryComputeWizard(models.Model):
('date_to', '>=', start_date)
])
employee.salary_date = start_date
+ employee.salary_month = self.select_time
employee.salary_year_jin_ids = [(6, 0, self.employee_ids.ids)]
if existing_payslip:
raise UserError(f"员工 {employee.name} 在 {start_date} 到 {end_date} 日期范围内已有工资单记录,无法创建新的工资单。")