public override void FillLastSaldo(Dictionary<long, EmployeeWeek> dict, long[] ids, DateTime aBeginWeek, bool bPlanning) { if (!bPlanning) throw new ArgumentException("Austria don't support time recording"); DateTime todayMonday = DateTimeHelper.GetMonday(DateTime.Today); Debug.Assert(aBeginWeek.DayOfWeek == DayOfWeek.Monday); DateTime currentMonday = aBeginWeek; bool bPastWeek = todayMonday > currentMonday; bool bFutureWeek = todayMonday < currentMonday; bool bCurrentWeek = todayMonday == currentMonday; if (bCurrentWeek) { return; } if (bFutureWeek) { SrvEmployeeWeekPlanningList cache_weeks = new SrvEmployeeWeekPlanningList(ids, todayMonday); foreach (EmployeeWeek week in dict.Values) { List<EmployeeWeekTimePlanning> list_weeks = cache_weeks.GetEntitiesByEmployeeId(week.EmployeeId); DateTime minDate = todayMonday; EmployeeWeekTimePlanning prevWeekEntity = null; if (list_weeks != null && list_weeks.Count > 0) { foreach (EmployeeWeekTimePlanning entity in list_weeks) { if (entity.WeekBegin < currentMonday && minDate <= entity.WeekBegin) { prevWeekEntity = entity; minDate = prevWeekEntity.WeekBegin; } } } if (prevWeekEntity != null) { Debug.Assert(prevWeekEntity.WeekBegin < currentMonday); Debug.Assert(prevWeekEntity.WeekBegin > todayMonday); week.LastSaldo = prevWeekEntity.Saldo; } } return; } if (bPastWeek) { foreach (EmployeeWeek week in dict.Values) { if (week.NewWeek) week.LastSaldo = 0; else { week.LastSaldo = EmployeeWeekProcessor.GetLastSaldoFromSaldo(week); } } } }
public void UpdateAllInFlag(DateTime date) { DateTime fromDate = DateTimeHelper.GetMonday(date); AllInManagers = new CacheEmployeesAllIn(); AllInManagers.LoadByEmployee(Employee.ID); PlanningWeeks = new SrvEmployeeWeekPlanningList(Employee.ID, fromDate); PlanningDays = new SrvEmployeesPlanningDayList(Employee.ID, fromDate); PlanningWeeks.AllInManager = AllInManagers; List<EmployeeWeekTimePlanning> list = PlanningWeeks.GetEntitiesByEmployeeId(Employee.ID); if (list != null && list.Count > 0) { int lastSaldo = GetLastSaldoForPlanning(fromDate); bool bAllIn = false; foreach (EmployeeWeekTimePlanning week_entity in list) { if (week_entity.WeekBegin < fromDate) continue; bAllIn = AllInManagers.GetAllIn(week_entity.EmployeeID, week_entity.WeekBegin, week_entity.WeekEnd); Debug.WriteLine(Employee.FullName + week_entity.Dump ()); if (week_entity.AllIn != bAllIn) { week_entity.AllIn = bAllIn; if (!week_entity.AllIn) { week_entity.AdditionalCharge = PlanningDays.GetAdditionalChargesForWeekRange(week_entity.EmployeeID , week_entity.WeekBegin, week_entity.WeekEnd); ; week_entity.CalculateSaldo(lastSaldo); } else { week_entity.AdditionalCharge = 0; } PlanningWeeks.UpdateEntity(week_entity); } Debug.WriteLine(Employee.FullName + week_entity.Dump()); lastSaldo = week_entity.Saldo; } } }