public static MonthlySalary GetEffective(string empNo, DateTime date) { GroupOperator criteria = new GroupOperator(GroupOperatorType.And, new BinaryOperator("员工编号", empNo, BinaryOperatorType.Equal), new BinaryOperator("开始执行日期", date.Date, BinaryOperatorType.LessOrEqual) ); XPCollection objset = new XPCollection(MyHelper.XpoSession, typeof(MonthlySalary), criteria, new SortProperty("开始执行日期", SortingDirection.Descending)); if (objset.Count > 0) { MonthlySalary item = (MonthlySalary)objset[0]; if (item.截止日期 == DateTime.MinValue || item.截止日期 >= date.Date) { return(item); } else { return(null); } } else { return(null); } }
public static MonthlySalaryInput AddMonthlySalaryInput(string emplid, int period, bool isVerify, bool copyEffective) { MonthlySalaryInput item = GetMonthlySalaryInput(emplid, period, isVerify); if (item == null) { item = new MonthlySalaryInput(); if (copyEffective) { //将当前执行的标准带过来 MonthlySalary effectiveMonthlySalary = MonthlySalary.GetEffective(emplid, DateTime.Today); if (effectiveMonthlySalary != null) { item.CopyEffective = copyEffective; effectiveMonthlySalary.CopyWatchMember(item); } } item.标识 = Guid.NewGuid(); item.员工编号 = emplid; item.期号 = period; item.是验证录入 = isVerify; item.薪酬体系 = ""; item.录入人 = " "; item.录入时间 = DateTime.Now; item.Save(); } return(item); }
//清理无效的记录 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); }
protected override void OnSaving() { MonthlySalary found = GetMonthlySalary(this.员工编号, this.开始执行日期); if (found != null && found.标识 != this.标识) { throw new Exception("本期已存在该员工的标准,不能创建。"); } else { base.OnSaving(); } MONTHLY_SALARY_CACHE.Set(CacheKey, this, TimeSpan.FromHours(1)); }
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); }
/// <summary> /// 获取下一条执行标准 /// </summary> /// <returns></returns> public MonthlySalary GetNext() { GroupOperator criteria = new GroupOperator(GroupOperatorType.And, new BinaryOperator("员工编号", 员工编号, BinaryOperatorType.Equal), new BinaryOperator("开始执行日期", 开始执行日期, BinaryOperatorType.Greater) ); XPCollection objset = new XPCollection(MyHelper.XpoSession, typeof(MonthlySalary), criteria, new SortProperty("开始执行日期", SortingDirection.Ascending)); if (objset.Count > 0) { MonthlySalary item = (MonthlySalary)objset[0]; return(item); } else { return(null); } }
//更新到正式表 public void UpdateToFormalTable() { MonthlySalary m = MonthlySalary.GetMonthlySalary(this.员工编号, this.开始执行日期); if (m == null) { m = new MonthlySalary(); m.标识 = Guid.NewGuid(); } this.CopyWatchMember(m); m.序号 = this.序号; m.备注 = m.调整类型; m.截止日期 = DateTime.MinValue; m.Save(); //历史记录失效 List <MonthlySalary> list = MonthlySalary.GetMonthlySalarys(this.员工编号); MonthlySalary prev = null; foreach (MonthlySalary item in list) { if (item.标识 == m.标识 || item.截止日期 != DateTime.MinValue || prev == null) { prev = item; continue; } item.截止日期 = prev.开始执行日期.AddDays(-1); item.Save(); prev = item; } //更新生效标记 if (!this.已生效) { this.生效时间 = DateTime.Now; this.Save(); MonthlySalaryInput opposite = 另一人录入的记录; opposite.生效时间 = DateTime.Now; opposite.Save(); } }
public static MonthlySalary GetMonthlySalary(Guid id) { MonthlySalary obj = (MonthlySalary)Session.DefaultSession.GetObjectByKey(typeof(MonthlySalary), id); return(obj); }
public EmployeeSalaryStructure(EmployeeInfo empInfo) { DateTime 期间开始 = DateTime.Today; 员工信息 = empInfo; 薪酬结构 = SalaryStructure.GetEffective(empInfo.员工编号, 期间开始); 借款工资 = WageLoan.GetEffective(empInfo.员工编号, 期间开始); 报账工资 = RembursementSalary.GetEffective(empInfo.员工编号, 期间开始); 月薪标准 = MonthlySalary.GetEffective(empInfo.员工编号, 期间开始); //处理,获取相关数据 this.员工编号 = empInfo.员工编号; this.姓名 = empInfo.姓名; this.性别 = empInfo.性别; this.职务 = empInfo.职务名称; this.公司 = empInfo.公司; this.部门 = empInfo.部门名称; this.职等 = empInfo.职等; if (月薪标准 != null) { this.开始执行日期 = 月薪标准.开始执行日期; this.年薪_12个月 = 月薪标准.执行_月薪 * 12; this.年薪_合计 = 月薪标准.执行_月薪 * 12; this.月薪项目_小计 = 月薪标准.执行_月薪; } if (薪酬结构 != null) { this.结构类型 = 薪酬结构.类型; this.年薪_奖励 = 薪酬结构.年薪_奖励; this.年薪_绩效工资 = 薪酬结构.年薪_绩效工资; this.年薪_12个月 = 薪酬结构.年薪_12个月; this.年薪_合计 = 薪酬结构.年薪_合计; this.月薪项目_月工资 = 薪酬结构.月薪项目_月工资; this.月薪项目_年休假 = 薪酬结构.月薪项目_年休假; this.月薪项目_满勤奖 = 薪酬结构.月薪项目_满勤奖; this.月薪项目_交通餐饮补贴 = 薪酬结构.月薪项目_交通餐饮补贴; this.月薪项目_小计 = 薪酬结构.月薪项目_小计; this.月薪项目_减项_绩效工资 = 薪酬结构.月薪项目_减项_绩效工资; this.开始执行日期 = 薪酬结构.开始执行日期; } else { this.结构类型 = "标准"; this.年薪_奖励 = 0; this.月薪项目_交通餐饮补贴 = PsHelper.GetTrafficSubsidies(员工编号, 期间开始); this.月薪项目_满勤奖 = PsHelper.GetFullAttendancePayFromCache(empInfo.薪资体系, empInfo.薪等, 期间开始); this.月薪项目_年休假 = PsHelper.GetVacPayFromCache(empInfo.薪资体系, empInfo.薪等, 期间开始); this.月薪项目_月工资 = 月薪项目_小计 - 月薪项目_满勤奖 - 月薪项目_年休假 - 月薪项目_交通餐饮补贴; } if (借款工资 != null) { 月薪项目_减项_工资借款 = 借款工资.月借款额度; } if (报账工资 != null) { 月薪项目_减项_报账工资 = 报账工资.月度可报账标准_税前; } }