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

【PRO-协和国际】个别假期需要入离职折算

XMLWord打印

    • X-协和国际学校-Y2021053
    • PRO
    • 时间管理
    • 隐藏
      def is_month_end(the_date):
        is_end = the_date.month != (the_date+datetime.timedelta(days=1)).month
        return is_end
      
      def is_month_begin(the_date):
        is_begin = the_date.day == 1
        return is_begin
      
      
      def zhesuan_month(period_start_date, period_end_date, employee_hire_date, leave_date, the_num):
        small_date = employee_hire_date if employee_hire_date>period_start_date and employee_hire_date<period_end_date else period_start_date
        if leave_date:
          big_date = leave_date if leave_date>period_start_date and leave_date<period_end_date else period_end_date
        else:
          big_date = period_end_date
        if (period_end_date+relativedelta.relativedelta(days=1)).year!=period_start_date.year:
          total_months = 12+(period_end_date+relativedelta.relativedelta(days=1)).month-period_start_date.month
        else:
          total_months = (period_end_date + relativedelta.relativedelta(days=1)).month - period_start_date.month
        if (big_date+relativedelta.relativedelta(days=1)).year!=small_date.year:
          sub_month = 12+(big_date+relativedelta.relativedelta(days=1)).month-small_date.month
        else:
          sub_month = (big_date + relativedelta.relativedelta(days=1)).month - small_date.month
        return the_num*sub_month/total_months
      
      employee_info = self.data['employees_info'][employee_id]
      period_info = self.data['periods_info'][period_id]
      package_info = self.data['packages_info'][package_rule_info['holiday_package_id']]
      rule_obj = env['hr.holiday.rule.function']
      precision_round = rule_obj.precision_round
      
      period = env['hr.holiday.period'].search([('id','=',period_id)])
      
      
      init_num = rule['init_num']
      precision = rule['graininess'] if rule['graininess'] != "0" else "0.01"  # 颗粒度
      round_rule = rule['carry_rule']  # 进位规则
      employee_hire_date = employee_info['employee_hire_date']
      is_entry_convert_enable = rule['is_entry_convert_enable']  # 启用入职折算
      is_resignation_convert_enable = rule['is_resignation_convert_enable']  # 启用离职折算
      period_start_date = period_info['start_date']
      period_end_date = period_info['end_date']
      
      if is_month_begin(employee_hire_date):
        employee_hire_date = employee_hire_date
      else:
        employee_hire_date = employee_hire_date+relativedelta.relativedelta(months=1)
        employee_hire_date = employee_hire_date+relativedelta.relativedelta(days=-employee_hire_date.day+1)
      
      if leave_date:
        if is_month_end(leave_date):
          leave_date=leave_date
        else:
          leave_date=leave_date+relativedelta.relativedelta(days=-leave_date.day+1)
      
      the_num = zhesuan_month(period_start_date, period_end_date, employee_hire_date, leave_date, init_num)
      
      
      result = precision_round(the_num, precision, round_rule)
      
      显示
      def is_month_end(the_date): is_end = the_date.month != (the_date+datetime.timedelta(days=1)).month return is_end def is_month_begin(the_date): is_begin = the_date.day == 1 return is_begin def zhesuan_month(period_start_date, period_end_date, employee_hire_date, leave_date, the_num): small_date = employee_hire_date if employee_hire_date>period_start_date and employee_hire_date<period_end_date else period_start_date if leave_date: big_date = leave_date if leave_date>period_start_date and leave_date<period_end_date else period_end_date else : big_date = period_end_date if (period_end_date+relativedelta.relativedelta(days=1)).year!=period_start_date.year: total_months = 12+(period_end_date+relativedelta.relativedelta(days=1)).month-period_start_date.month else : total_months = (period_end_date + relativedelta.relativedelta(days=1)).month - period_start_date.month if (big_date+relativedelta.relativedelta(days=1)).year!=small_date.year: sub_month = 12+(big_date+relativedelta.relativedelta(days=1)).month-small_date.month else : sub_month = (big_date + relativedelta.relativedelta(days=1)).month - small_date.month return the_num*sub_month/total_months employee_info = self.data[ 'employees_info' ][employee_id] period_info = self.data[ 'periods_info' ][period_id] package_info = self.data[ 'packages_info' ][package_rule_info[ 'holiday_package_id' ]] rule_obj = env[ 'hr.holiday.rule.function' ] precision_round = rule_obj.precision_round period = env[ 'hr.holiday.period' ].search([( 'id' , '=' ,period_id)]) init_num = rule[ 'init_num' ] precision = rule[ 'graininess' ] if rule[ 'graininess' ] != "0" else "0.01" # 颗粒度 round_rule = rule[ 'carry_rule' ] # 进位规则 employee_hire_date = employee_info[ 'employee_hire_date' ] is_entry_convert_enable = rule[ 'is_entry_convert_enable' ] # 启用入职折算 is_resignation_convert_enable = rule[ 'is_resignation_convert_enable' ] # 启用离职折算 period_start_date = period_info[ 'start_date' ] period_end_date = period_info[ 'end_date' ] if is_month_begin(employee_hire_date): employee_hire_date = employee_hire_date else : employee_hire_date = employee_hire_date+relativedelta.relativedelta(months=1) employee_hire_date = employee_hire_date+relativedelta.relativedelta(days=-employee_hire_date.day+1) if leave_date: if is_month_end(leave_date): leave_date=leave_date else : leave_date=leave_date+relativedelta.relativedelta(days=-leave_date.day+1) the_num = zhesuan_month(period_start_date, period_end_date, employee_hire_date, leave_date, init_num) result = precision_round(the_num, precision, round_rule)

      Annual leave, sick leave, flex day and personal day入离职折算:按月折算,只有当月1号入职才会算上本月,否则从下月开始折算,额度不满0.5向下进位。例:员工2月1号入职,假期折算额度=6/12*假期额度,如果不是2月的1号入职,则假期折算额度=5/12*假期额度;离职只有处于月底最后一天离职时才会算上本月,例:假如21年6.30号离职,离职折算才会算上六月,否则不算上六月

      工作日历以学期算:当年8.1-次年7.31

            grant.yang 杨光磊
            shufan.guo 郭书凡
            表决:
            0 为这个问题表决

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

                预估时间:
                初始预估 - 尚未指定
                尚未指定
                剩余:
                剩余的估算 - 0小时
                0小时
                实际工作时间:
                耗费时间 - 4小时
                4小时