Пример #1
0
        protected override List <Overtime> CalculateReportData()
        {
            var users       = _usersActiveInMonthReporter.Report();
            var attendances = _attendanceReporter.Report();

            var timeTrackingUsers = users.Where(x => x.IsTracking.HasValue && x.IsTracking.Value);
            var workHours         = _workHoursReporter.Report();

            Logger.Info("Calculating overtimes for {0} users", users.Count);

            var overtimes = attendances
                            .Where(x => x.Date.Month == _month && x.Date.Year == _year)
                            .GroupBy(x => x.User)
                            .Join(timeTrackingUsers, gu => gu.Key, u => u.Login, (gu, u) => new Overtime
            {
                Login            = gu.Key,
                HoursWorked      = gu.Sum(x => x.HoursWorked),
                ContractType     = u.ContractType,
                FirstName        = u.FirstName,
                LastName         = u.LastName,
                CostCenter       = u.CostCenter,
                Month            = _month,
                Year             = _year,
                Absences         = gu.Sum(x => x.AbsenceTotal),
                WorkHoursInMonth = CalculateWorkHoursInMonth(u, workHours)
            })
                            .ToList();


            return(overtimes);
        }
Пример #2
0
        protected override List <FoodStampData> CalculateReportData()
        {
            Logger.Info("Calculating food stamp data");

            var entitledUsers = _usersActiveInMonthReporter.Report()
                                .Where(x => x.GetContractType() == ContractType.Employee);

            var monthWorkDays = _monthWorkHoursReporter.Report() / 8;

            var absences = _absenceReporter.Report()
                           .Where(x => x.Date.Month == _previousMonth && x.Date.Year == _previousYear)
                           .ToList();

            var result = entitledUsers.Select(x =>
            {
                var absencesForAdjustment = absences.Count(a => a.UserName == x.Login &&
                                                           a.Hours >= HoursForAbsenceAdjustment);
                return(new FoodStampData
                {
                    Month = _month,
                    Year = _year,
                    FirstName = x.FirstName,
                    LastName = x.LastName,
                    FoodStampCountEntitlement = monthWorkDays,
                    AdjustmentForAbsences = absencesForAdjustment
                });
            });

            return(result.ToList());
        }
Пример #3
0
        protected override List <SalaryData> CalculateReportData()
        {
            Logger.Info("Calculating salary data");
            var jiraAbsences = _jiraAbsenceReporter.Report();

            var users         = _usersActiveInMonthReporter.Report();
            var salariedUsers = users.Where(x => SalariedContractTypes.Contains(x.GetContractType())).ToList();

            Logger.Info("Found {0} salaried users", salariedUsers.Count);

            var relevantAttendance = _attendanceReporter.Report()
                                     .Where(x => x.Date.Year == _year && x.Date.Month == _month)
                                     .GroupBy(x => x.User)
                                     .Select(x => new
            {
                User                      = x.Key,
                HoursWorkedTotal          = x.Sum(y => y.HoursWorked),
                AbsenceVacationTotal      = x.Sum(y => y.AbsenceVacation),
                AbsenceDoctorTotal        = x.Sum(y => y.AbsenceDoctor),
                AbsenceDoctorFamilyTotal  = x.Sum(y => y.AbsenceDoctorFamily),
                AbsencePersonalLeaveTotal = x.Sum(y => y.AbsencePersonalLeave)
            })
                                     .Join(salariedUsers, a => a.User, u => u.Login,
                                           (a, u) => new
            {
                u.Login,
                u.Title,
                u.StartDate,
                u.Benefit,
                u.FirstName,
                u.LastName,
                u.Salary,
                u.Rate,
                ContractType = u.GetContractType(),
                a.HoursWorkedTotal,
                a.AbsenceVacationTotal,
                a.AbsenceDoctorTotal,
                a.AbsenceDoctorFamilyTotal,
                a.AbsencePersonalLeaveTotal
            });

            var result = relevantAttendance.Select(x =>
            {
                decimal?salary = null;
                if (x.ContractType == ContractType.Employee)
                {
                    salary = x.Salary;
                }
                else if (x.ContractType == ContractType.PartTimeEmployee)
                {
                    salary = x.Rate * x.HoursWorkedTotal;
                }

                return(new SalaryData
                {
                    Year = _year,
                    Month = _month,
                    Title = x.Title,
                    StartDate = x.StartDate,
                    Benefit = x.Benefit,
                    FirstName = x.FirstName,
                    Login = x.Login,
                    LastName = x.LastName,
                    DoctorFamilyHours = x.AbsenceDoctorFamilyTotal,
                    DoctorHours = x.AbsenceDoctorTotal,
                    VacationDays = x.AbsenceVacationTotal / 8,
                    Salary = salary,
                    IllnessDays = CalculateIllnessDays(x.Login, jiraAbsences),
                    PersonalLeaveDays = x.AbsencePersonalLeaveTotal / 8
                });
            });

            return(result.ToList());
        }