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

【海正博锐】写季度、半年度调薪函数

XMLWord打印

    • Icon: Change Change
    • 解决结果: 完成
    • Icon: Block Block
    • 202012
    • Y-易路产品-
    • bioray
    • 基础通用功能
    • 隐藏

      新增一个预计算公式一个引用公式:
      预计算公式:
      employeeIds = employee_snapshot_dict.keys()
      payroll_period_id = payslip_run_record.payroll_period.id
      payroll_period_rec = env['payroll.period'].search([('id', '=',payroll_period_id)])
      payroll_period_name = payroll_period_rec.name
      result = {}
      for employeeid in employeeIds:
      employee = env['hr.employee'].search([('id','=',employeeid)])
      if employee.payroll_archive_ids:
      perform_quarterly_list = [[],[]]
      perform_semi_annual_list = [[],[]]
      for payroll_archive in employee.payroll_archive_ids:
      if payroll_archive.code=='perform_quarterly':
      perform_quarterly_list[0].append(payroll_archive.amount)
      perform_quarterly_list[1].append(payroll_archive.expired_date)
      if payroll_archive.code=='perform_semi_annual':
      perform_semi_annual_list[0].append(payroll_archive.amount)
      perform_semi_annual_list[1].append(payroll_archive.expired_date)
      result[employeeid] =

      { 'perform_quarterly_list': perform_quarterly_list, 'perform_semi_annual_list': perform_semi_annual_list }

      引用公式:
      def F_SeasonHalfyearAdjustConvert(cal_type):
      data_dic = global_dict.get('F_season_halfyear_adjust_convert', {})
      period_name = global_dict.get('ref_payroll_period_name')
      employee_id = individual_dict['ref_employee_id']
      data_dic = data_dic.get(employee_id,{})
      result_list = [0, 0]
      the_month = period_name%100
      the_year = period_name//100
      if the_month in [3,6,9,12]:
      if cal_type=='perform_quarterly':
      the_list = data_dic.get('perform_quarterly_list',[[],[]])
      month_begin = the_month - 2
      elif cal_type=='perform_semi_annual':
      the_list = data_dic.get('perform_semi_annual_list',[[],[]])
      month_begin = the_month - 5
      end_day = 31 if the_month in [3,12] else 30
      date_begin = datetime.date(year=the_year,month=month_begin,day=1).strftime('%Y-%m-%d')
      date_end = datetime.date(year=the_year,month=the_month,day=end_day).strftime('%Y-%m-%d')
      amount_list = the_list[0]
      date_list = the_list[1]
      count_date_list = []
      for index,a_date in enumerate(date_list):
      if a_date and index==0:
      continue
      if a_date and index > 0:
      if date_begin <= a_date <= date_end:
      count_date_list.append(a_date)
      if count_date_list:
      count_day = count_date_list[0]
      before_days = F_GetDaysof(date_begin, count_day, 2)
      af_begin_date = (datetime.datetime.strptime(count_day,'%Y-%m-%d') + relativedelta.relativedelta(days=1)).strftime('%Y-%m-%d')
      af_days = F_GetDaysof(af_begin_date, date_end, 2)
      count_day_index = date_list.index(count_day)
      before_amount = amount_list[count_day_index]
      after_amount = 0 if count_day_index==0 else amount_list[count_day_index-1]
      total = (float(before_amount)*float(before_days) + float(after_amount)*float(af_days))/(before_days+af_days)
      result_list[0] = total
      result_list[1] = after_amount - before_amount
      return result_list

      显示
      新增一个预计算公式一个引用公式: 预计算公式: employeeIds = employee_snapshot_dict.keys() payroll_period_id = payslip_run_record.payroll_period.id payroll_period_rec = env ['payroll.period'] .search( [('id', '=',payroll_period_id)] ) payroll_period_name = payroll_period_rec.name result = {} for employeeid in employeeIds: employee = env ['hr.employee'] .search( [('id','=',employeeid)] ) if employee.payroll_archive_ids: perform_quarterly_list = [[],[]] perform_semi_annual_list = [[],[]] for payroll_archive in employee.payroll_archive_ids: if payroll_archive.code=='perform_quarterly': perform_quarterly_list [0] .append(payroll_archive.amount) perform_quarterly_list [1] .append(payroll_archive.expired_date) if payroll_archive.code=='perform_semi_annual': perform_semi_annual_list [0] .append(payroll_archive.amount) perform_semi_annual_list [1] .append(payroll_archive.expired_date) result [employeeid] = { 'perform_quarterly_list': perform_quarterly_list, 'perform_semi_annual_list': perform_semi_annual_list } 引用公式: def F_SeasonHalfyearAdjustConvert(cal_type): data_dic = global_dict.get('F_season_halfyear_adjust_convert', {}) period_name = global_dict.get('ref_payroll_period_name') employee_id = individual_dict ['ref_employee_id'] data_dic = data_dic.get(employee_id,{}) result_list = [0, 0] the_month = period_name%100 the_year = period_name//100 if the_month in [3,6,9,12] : if cal_type=='perform_quarterly': the_list = data_dic.get('perform_quarterly_list',[[],[]]) month_begin = the_month - 2 elif cal_type=='perform_semi_annual': the_list = data_dic.get('perform_semi_annual_list',[[],[]]) month_begin = the_month - 5 end_day = 31 if the_month in [3,12] else 30 date_begin = datetime.date(year=the_year,month=month_begin,day=1).strftime('%Y-%m-%d') date_end = datetime.date(year=the_year,month=the_month,day=end_day).strftime('%Y-%m-%d') amount_list = the_list [0] date_list = the_list [1] count_date_list = [] for index,a_date in enumerate(date_list): if a_date and index==0: continue if a_date and index > 0: if date_begin <= a_date <= date_end: count_date_list.append(a_date) if count_date_list: count_day = count_date_list [0] before_days = F_GetDaysof(date_begin, count_day, 2) af_begin_date = (datetime.datetime.strptime(count_day,'%Y-%m-%d') + relativedelta.relativedelta(days=1)).strftime('%Y-%m-%d') af_days = F_GetDaysof(af_begin_date, date_end, 2) count_day_index = date_list.index(count_day) before_amount = amount_list [count_day_index] after_amount = 0 if count_day_index==0 else amount_list [count_day_index-1] total = (float(before_amount)*float(before_days) + float(after_amount)*float(af_days))/(before_days+af_days) result_list [0] = total result_list [1] = after_amount - before_amount return result_list

      季度(每年3月、6月、9月、12月薪资月中发放):旧考核工资基数/季度计薪天数*季度调薪前天数(季度初至调薪日的天数) + 新考核工资基数/季度计薪天数*调薪后天数(调薪日至季度末的天数)
      半年度(每年6月、12月薪资月中发放):旧考核工资基数/半年度计薪天数*调薪前天数(半年度初至调薪日的天数) + 新考核工资基数/半年度计薪天数*调薪后天数(调薪日至半年度末的天数)
      这个是怪兽项目当时让CSC帮忙写的季度折算函数,可以让CSC参考这个帮忙写季度、半年度折算函数
      https://pm.ersoft.cn/browse/SLAL2-1219

            grant.yang 杨光磊
            victor.huan 环志伟
            表决:
            0 为这个问题表决

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