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

贝卡尔特--帮忙写一个函数,获取去年12月份的员工薪资档案项

XMLWord打印

    • Icon: Change Change
    • 解决结果: 完成
    • Icon: Medium Medium
    • 202003
    • Y-易路产品-
    • 贝卡尔特 bekaert bketuat
    • 基础通用功能
    • 隐藏
      def F_GetLastYearPayrollArchive(archive_code):
          result = 0
          employee_id = individual_dict['ref_employee_id']
          year_month_now = str(global_dict['ref_payroll_period_name'])
          last_year = str(int(year_month_now[:4]) - 1)
          period_start = last_year + '-12-01'
          period_end = last_year + '-12-31'
          # 拿到该员工的薪资档案
          employee_archives = global_dict['F_employee_archives'].get(employee_id, {}).get(archive_code, []) # [{'effective_date': 'x', 'expired_date': 'x', 'amount': 10.01}]
      
          # 遍历薪资档案项,取得去年12月份薪资档案项最大值
          for archive in employee_archives:
              if not archive['expired_date'] and archive['effective_date'] <= period_end and archive['amount'] > result:
                  result = archive['amount']
              elif archive['effective_date'] <= period_end and archive['expired_date'] >= period_start and archive['amount'] > result:
                  result = archive['amount']
      
          return result
      

      获取去年12月份的员工薪资档案项。
      示例: result = F_GetLastYearPayrollArchive('contract_bs')
      返回: 去年12月份合同工资最大值

      显示
      def F_GetLastYearPayrollArchive(archive_code): result = 0 employee_id = individual_dict[ 'ref_employee_id' ] year_month_now = str (global_dict[ 'ref_payroll_period_name' ]) last_year = str ( int (year_month_now[:4]) - 1) period_start = last_year + '-12-01' period_end = last_year + '-12-31' # 拿到该员工的薪资档案 employee_archives = global_dict[ 'F_employee_archives' ].get(employee_id, {}).get(archive_code, []) # [{ 'effective_date' : 'x' , 'expired_date' : 'x' , 'amount' : 10.01}] # 遍历薪资档案项,取得去年12月份薪资档案项最大值 for archive in employee_archives: if not archive[ 'expired_date' ] and archive[ 'effective_date' ] <= period_end and archive[ 'amount' ] > result: result = archive[ 'amount' ] elif archive[ 'effective_date' ] <= period_end and archive[ 'expired_date' ] >= period_start and archive[ 'amount' ] > result: result = archive[ 'amount' ] return result 获取去年12月份的员工薪资档案项。 示例: result = F_GetLastYearPayrollArchive('contract_bs') 返回: 去年12月份合同工资最大值

      客户折算去年年费用的时候,需要用到去年12月份的员工薪资档案项,帮忙写一个函数。如果员工没有有效的去年12月份的薪资档案项那么取0。

            rogan 王全根
            zhzl 朱真乐
            表决:
            0 为这个问题表决

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