예제 #1
0
        //清理无效的记录
        public static List <EmployeeInfo> ClearInvalidRecord()
        {
            List <EmployeeInfo> empListChanged = new List <EmployeeInfo>();
            List <EmployeeInfo> empList        = EmployeeInfo.GetHasPayEmployeeList();
            //最近一次发工资的日期
            DateTime lastSalaryDate = SalaryResult.GetLastSalaryDate();

            if (lastSalaryDate == DateTime.MinValue)
            {
                return(empListChanged);
            }

            //上月最后一天(相当于该员工有工资的最后一个月,这里是相对的概念)
            DateTime preMonthLastDayDate = new DateTime(lastSalaryDate.Year, lastSalaryDate.Month, 1).AddMonths(1).AddDays(-1);
            //上上月
            DateTime prePreMonthLastDayDate = preMonthLastDayDate.AddMonths(-1);
            DateTime expiredDate            = prePreMonthLastDayDate;

            foreach (EmployeeInfo emp in empList)
            {
                //2018-7-24   管培生薪酬体系特殊,不随公司与职务等级变化,不设异动判断
                if (emp.是管培生)
                {
                    continue;
                }

                MonthlySalary ms = GetEffective(emp.员工编号, lastSalaryDate);
                if (ms != null)
                {
                    SalaryResult sr = SalaryResult.GetFromCache(emp.员工编号, lastSalaryDate.Year, lastSalaryDate.Month);
                    if (sr != null)
                    {
                        SalaryResult prev_sr = SalaryResult.GetFromCache(emp.员工编号, prePreMonthLastDayDate.Year, prePreMonthLastDayDate.Month);
                        //如果公司、职等都没变
                        if (prev_sr == null || (prev_sr.公司编号 == sr.公司编号 && ms.职等 == sr.工资职等))
                        {
                            continue;
                        }
                        expiredDate = new DateTime(sr.年度, sr.月份, 1).AddDays(-1);
                    }
                    else
                    {
                        continue;
                    }

                    if (ms.截止日期 < ms.开始执行日期)
                    {
                        continue;
                    }

                    //截止日期为上上月最后一天
                    ms.截止日期 = expiredDate;
                    ms.Save();

                    empListChanged.Add(emp);
                }
            }
            return(empListChanged);
        }
예제 #2
0
        public static MonthlySalary AddMonthlySalary(string emplid, DateTime startDate)
        {
            MonthlySalary item = GetMonthlySalary(emplid, startDate);

            if (item == null)
            {
                item        = new MonthlySalary();
                item.标识     = Guid.NewGuid();
                item.员工编号   = emplid;
                item.开始执行日期 = startDate;

                item.Save();
            }
            return(item);
        }