Exemplo n.º 1
0
        public void UpdateSaldoAfterPlanning(EmployeeWeek week)
        {
            EmployeeWeekTimePlanning entity = GetByDate(week.EmployeeId, week.BeginDate);

            if (entity == null)
            {
                entity = new EmployeeWeekTimePlanning();
                EmployeeWeekProcessor.AssignTo(entity, week);
                UpdateEntity(entity);
            }
            else
            {
                if (EmployeeWeekProcessor.IsModified(entity, week))
                {
                    EmployeeWeekProcessor.AssignTo(entity, week);
                    UpdateEntity(entity);
                }
            }

            UpdateSaldoFrom(week.EmployeeId, DateTimeHelper.GetNextMonday(week.BeginDate), week.Saldo);
        }
Exemplo n.º 2
0
        public virtual void UpdateEntityAfterRecording(EmployeeWeek week)
        {
            EmployeeWeekTimeRecording        entity = GetByDate(week.EmployeeId, week.BeginDate);
            List <EmployeeWeekTimeRecording> list   = GetEntitiesByEmployeeId(week.EmployeeId);

            if (entity == null)
            {
                entity = new EmployeeWeekTimeRecording();
                EmployeeWeekProcessor.AssignTo(entity, week);
                UpdateEntity(entity);

                if (list == null)
                {
                    list = new List <EmployeeWeekTimeRecording>();

                    _index[week.EmployeeId] = list;
                }

                _entities.Add(entity);
                list.Add(entity);

                list.Sort();
            }
            else
            {
                if (EmployeeWeekProcessor.IsModified(entity, week))
                {
                    EmployeeWeekProcessor.AssignTo(entity, week);
                    UpdateEntity(entity);
                }
            }



            if (list != null)
            {
                int previous_saldo = entity.Saldo;
                foreach (EmployeeWeekTimeRecording next_entity in list)
                {
                    if (next_entity.WeekBegin <= week.BeginDate)
                    {
                        continue;
                    }

                    if (next_entity.CalculateSaldo(previous_saldo))
                    {
                        UpdateEntity(next_entity);
                        previous_saldo = next_entity.Saldo;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            SrvEmployeeWeekPlanningList planList = new SrvEmployeeWeekPlanningList(week.EmployeeId, week.EndDate.AddDays(1));

            //planList.UpdateSaldoFrom2(week.EmployeeId, week.EndDate.AddDays(1), week.Saldo);
            planList.UpdateSaldoAfterRecording(week.EmployeeId, list, week.EndDate.AddDays(1));
        }