From 6ae4f6bcfc90f718633b66d3c1ec3be80931cf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Sat, 15 Mar 2025 15:20:30 +0800 Subject: [PATCH 1/2] 1 --- .../models/yuthon_payroll_project.py | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index 04924839e..547823af8 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -8,10 +8,9 @@ class YuthonPayrollCommon(models.Model): _description = '薪资常用项' name = fields.Char(string='工资项名称') - yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储')], - string='公司') + yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储')],string='公司') department_id = fields.Many2one('hr.department', string="部门") - conditional_formulas = fields.Char(string='条件公式') # todo 可能是个many2one + conditional_formulas = fields.Char(string='条件公式') start_date = fields.Date(string="生效日期", default=fields.Date.today()) end_date = fields.Date(string="失效日期") @@ -19,22 +18,41 @@ class YuthonPayrollCommon(models.Model): """ 更新常用项职级 :return: + # Available variables: + #---------------------- + # payslip: hr.payslip object + # employee: hr.employee object + # contract: hr.contract object + # rules: dict containing the rules code (previously computed) + # categories: dict containing the computed salary rule categories (sum of amount of all rules belonging to that category). + # worked_days: dict containing the computed worked days + # inputs: dict containing the computed inputs. + + # Note: returned value have to be set in the variable 'result' + + result = contract.wage * 0.10 """ - insurances_ids = self.env["yuthon.payroll.insurances"].browse(self._context.get('active_ids', self._context.get('active_id'))) + insurances_ids = self.env["yuthon.payroll.common"].browse(self._context.get('active_ids', self._context.get('active_id'))) for ins in insurances_ids: - salary_lv_ids = self.env["yuthon.payroll.common"].search([]) + salary_lv_ids = self.env["hr.payroll.structure"].search([]) for sal in salary_lv_ids: rule_list = [] if ins.name not in sal.rule_ids.mapped('name'): + # 工资项公式 + formula_salary = '' + if ins.name == '工龄': + formula_salary = "result = int((employee.cumulative_work_month / 12) * 10)" + if ins.name == '工会会费': + formula_salary = "result = contract.wage * 0.05" + if ins.name == '加班费': + formula_salary = "result = employee.all_overtime_hours - 40 * contract.wage /21.75 / 8" rule_list.append([0, 0, { 'name': ins.name, 'category_id': self.env['hr.salary.rule.category'].search([('name', '=', '常用项')], limit=1).id, 'code': "".join([p[0][0] for p in pinyin(ins.name, style=Style.FIRST_LETTER)]).upper(), 'amount_select': 'code', - # 'amount_percentage_base': sal.base_salary, - 'quantity': 1, - # 'amount_percentage': ins.proportion_employee, - 'struct_id': sal.id + 'amount_python_compute': formula_salary, + 'struct_id': sal.id, }]) sal.write({'rule_ids': rule_list}) @@ -50,12 +68,6 @@ class YuthonPayrollTemporary(models.Model): start_date = fields.Date(string="生效日期", default=fields.Date.today()) end_date = fields.Date(string="失效日期") - -class YuthonPayrollInsurances2(models.Model): - _name = 'yuthon.disease.approval' -class YuthonPayrollInsurances3(models.Model): - _name = 'yuthon.hospital.approval' - class YuthonPayrollInsurances (models.Model): _name = 'yuthon.payroll.insurances' _description = '五险一金' From fc725e1dbba53647faef33647d60f440b018e6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Sat, 15 Mar 2025 15:23:53 +0800 Subject: [PATCH 2/2] 1 --- yuthon_salary/models/yuthon_payroll_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index 547823af8..cfbe6fb03 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -37,9 +37,9 @@ class YuthonPayrollCommon(models.Model): salary_lv_ids = self.env["hr.payroll.structure"].search([]) for sal in salary_lv_ids: rule_list = [] + formula_salary = '' if ins.name not in sal.rule_ids.mapped('name'): # 工资项公式 - formula_salary = '' if ins.name == '工龄': formula_salary = "result = int((employee.cumulative_work_month / 12) * 10)" if ins.name == '工会会费':