上传的图像用于项目: 'CST技术支持'
  1. CST技术支持
  2. SLAL2-1413

客制化薪资函数【获取新员工社保基数】

XMLWord打印

    • Icon: 技术问题 技术问题
    • 解决结果: 完成
    • Icon: High High
    • 202012
    • Y-易路产品-
    • yltest
    • 薪酬管理
    • 隐藏

      payroll_period = str(payslip_run_record.payroll_period.name)
      all_bases = env['social.security.base'].search([('start_month','<=',payroll_period),'|',('end_month','=',False),('end_month','>=',payroll_period)])

      all_sb_bases={}
      for item in all_bases:
      if all_sb_bases.get(item.employee_id.id):
      all_sb_bases[item.employee_id.id].update({item.insurance_id.code:

      { 'individual_base':item.individual_base, 'company_base':item.company_base}

      })
      else:
      all_sb_bases[item.employee_id.id] = {item.insurance_id.code:

      { 'individual_base':item.individual_base, 'company_base':item.company_base}

      }
      result = all_sb_bases

      def F_Get_Sb_Personal_Base(*args):
      if len(args) == 1:
      sb_code = args[0]
      sb_type = 1
      has_sb_base = False
      elif len(args) == 2:
      sb_code = args[0]
      sb_type = args[1]
      has_sb_base = False
      elif len(args) == 3:
      sb_code = args[0]
      sb_type = args[1]
      sb_base = args[2]
      has_sb_base = True
      else:
      return 0
      employee_id = individual_dict['ref_employee_id']
      year_month_now = str(global_dict['ref_payroll_period_name'])
      social_security_start_month = individual_dict.get('ref_social_insurance_report_month') or individual_dict['ref_social_security_start_month']
      social_security_end_month = individual_dict['ref_social_security_end_month']

      1. 如果不存在社保起缴月或者社保起缴月大于薪资月,那么返回0
        if social_security_start_month:
        social_security_start_month = social_security_start_month[0:7].replace('-', '')
        if social_security_start_month > year_month_now:
        return 0
        else:
        return 0
      2. 如果存在社保停缴月,并且社保停缴月小于薪资月,那么返回0
        if social_security_end_month:
        social_security_end_month = social_security_end_month[0:7].replace('-', '')
        if social_security_end_month < year_month_now:
        return 0
        social_security_rule_code = individual_dict['ref_hr_employee_social_security_id_code']
      3. 如果不存在的对应的规则,那么返回0
        insurance_rule = global_dict['GetInsuranceFundRule'].get(social_security_rule_code, {}).get(sb_code)
        if not insurance_rule:
        return 0
        if has_sb_base:
        social_security_base = sb_base or 0
        else:
        if sb_type == 1:
        social_security_base = global_dict.get('F_Get_Sb_Fund_Base', {}).get(employee_id, {}).get(sb_code,{}).get('company_base',0)
        elif sb_type == 2:
        social_security_base = global_dict.get('F_Get_Sb_Fund_Base', {}).get(employee_id, {}).get(sb_code,{}).get('individual_base',0)

      if sb_type == 1:
      min_base = insurance_rule['min_base_company'] or 0
      max_base = insurance_rule['max_base_company'] or 0
      elif sb_type == 2:
      min_base = insurance_rule['min_base'] or 0
      max_base = insurance_rule['max_base'] or 0
      else:
      return 0

      1. 判断社保基数
        if social_security_base and max_base and social_security_base > max_base:
        social_security_base = max_base
        if social_security_base and min_base and social_security_base < min_base:
        social_security_base = min_base
        if social_security_base and max_base and min_base and max_base >= social_security_base >= min_base:
        return social_security_base
        return social_security_base
      显示
      payroll_period = str(payslip_run_record.payroll_period.name) all_bases = env ['social.security.base'] .search( [('start_month','<=',payroll_period),'|',('end_month','=',False),('end_month','>=',payroll_period)] ) all_sb_bases={} for item in all_bases: if all_sb_bases.get(item.employee_id.id): all_sb_bases [item.employee_id.id] .update({item.insurance_id.code: { 'individual_base':item.individual_base, 'company_base':item.company_base} }) else: all_sb_bases [item.employee_id.id] = {item.insurance_id.code: { 'individual_base':item.individual_base, 'company_base':item.company_base} } result = all_sb_bases def F_Get_Sb_Personal_Base(*args): if len(args) == 1: sb_code = args [0] sb_type = 1 has_sb_base = False elif len(args) == 2: sb_code = args [0] sb_type = args [1] has_sb_base = False elif len(args) == 3: sb_code = args [0] sb_type = args [1] sb_base = args [2] has_sb_base = True else: return 0 employee_id = individual_dict ['ref_employee_id'] year_month_now = str(global_dict ['ref_payroll_period_name'] ) social_security_start_month = individual_dict.get('ref_social_insurance_report_month') or individual_dict ['ref_social_security_start_month'] social_security_end_month = individual_dict ['ref_social_security_end_month'] 如果不存在社保起缴月或者社保起缴月大于薪资月,那么返回0 if social_security_start_month: social_security_start_month = social_security_start_month [0:7] .replace('-', '') if social_security_start_month > year_month_now: return 0 else: return 0 如果存在社保停缴月,并且社保停缴月小于薪资月,那么返回0 if social_security_end_month: social_security_end_month = social_security_end_month [0:7] .replace('-', '') if social_security_end_month < year_month_now: return 0 social_security_rule_code = individual_dict ['ref_hr_employee_social_security_id_code'] 如果不存在的对应的规则,那么返回0 insurance_rule = global_dict ['GetInsuranceFundRule'] .get(social_security_rule_code, {}).get(sb_code) if not insurance_rule: return 0 if has_sb_base: social_security_base = sb_base or 0 else: if sb_type == 1: social_security_base = global_dict.get('F_Get_Sb_Fund_Base', {}).get(employee_id, {}).get(sb_code,{}).get('company_base',0) elif sb_type == 2: social_security_base = global_dict.get('F_Get_Sb_Fund_Base', {}).get(employee_id, {}).get(sb_code,{}).get('individual_base',0) if sb_type == 1: min_base = insurance_rule ['min_base_company'] or 0 max_base = insurance_rule ['max_base_company'] or 0 elif sb_type == 2: min_base = insurance_rule ['min_base'] or 0 max_base = insurance_rule ['max_base'] or 0 else: return 0 判断社保基数 if social_security_base and max_base and social_security_base > max_base: social_security_base = max_base if social_security_base and min_base and social_security_base < min_base: social_security_base = min_base if social_security_base and max_base and min_base and max_base >= social_security_base >= min_base: return social_security_base return social_security_base

      1、安装Social Security Base后,原函数【员工社保基数】不能获取到员工身上各险种的基数值
      2、期望客制化一个函数【新员工社保基数】
      输入:社保计算公式(社保编码,计算类型,社保基数)
      计算类型:1代表企业部分,2代表个人部分,默认为1
      社保基数:如果不填,取员工身上的社保基数值
      输出:根据社保编码,社保类型计算该员工实际参与计算的社保基数

            wenqiang.liu 刘文强
            xin.li 李欣
            表决:
            0 为这个问题表决

              创建日期:
              已更新:
              已解决: