예제 #1
0
        public IEnumerable <PayrollDetailsDTO> toPayrollNew(int?Y, int?M)
        {
            var list = new List <PayrollDetailsDTO>();

            foreach (var record in _pinhuaContext.AttendanceReportResults.Where(a => a.Y == Y && a.M == M))
            {
                var file          = _mapper.Map <人员档案, PersonnelFilesDTO>(_pinhuaContext.人员档案.AsNoTracking().FirstOrDefault(p => p.人员编号 == record.编号));
                var schemaDetails = _pinhuaContext.WageSchemaDetailsByTime.AsNoTracking().Where(p => p.SchemaId == file.SchemaId);
                var result        = schemaDetails.FirstOrDefault(p => p.Id == file.PostId && p.Sex == file.Sex);
                var x             = new PayrollDetailsDTO
                {
                    Id                   = record.编号,
                    Name                 = record.姓名,
                    Sex                  = file.Sex,
                    AllHours             = record.总工时,
                    DaytimeHours         = record.正班,
                    OvertimeHours        = record.加班,
                    TimesOfDinner        = record.用餐,
                    IsFullAttendance     = record.是否全勤 == "是",
                    Post                 = _pinhuaContext.岗位主表.AsNoTracking().FirstOrDefault(p => p.Id == file.PostId).OperatingPost,
                    DaytimeAmount        = record.正班 * result.DaytimePrice,
                    OvertimeAmount       = record.加班 * result.OvertimePrice,
                    FullAttendanceAmount = record.是否全勤 == "是" ? record.正班 * result.FullAttendancePrice : 0,
                    DinnerAmount         = record.用餐 * -2,
                    PriceOverview        = $"{(record.是否全勤 == "是" ? result.DaytimePrice + result.FullAttendancePrice : result.DaytimePrice)?.ToString("0.0")} / {result.OvertimePrice?.ToString("0.0")}",
                };
                x.AllHoursAmountWithFullAttendance = x.DaytimeAmount + x.OvertimeAmount + x.FullAttendanceAmount;
                x.FinalAmount = x.DaytimeAmount + x.OvertimeAmount + x.FullAttendanceAmount + x.DinnerAmount;
                list.Add(x);
            }
            return(list.OrderBy(p => p.Id));
        }
예제 #2
0
        public IList <PayrollDetailsDTO> toPayroll(IList <AttendanceReportDTO> data)
        {
            var list = new List <PayrollDetailsDTO>();

            foreach (var record in data)
            {
                var file          = _mapper.Map <人员档案, PersonnelFilesDTO>(_pinhuaContext.人员档案.AsNoTracking().FirstOrDefault(p => p.人员编号 == record.Id));
                var schemaDetails = _pinhuaContext.WageSchemaDetailsByTime.AsNoTracking().Where(p => p.SchemaId == file.SchemaId);
                var result        = schemaDetails.FirstOrDefault(p => p.Id == file.PostId && p.Sex == file.Sex);
                var x             = new PayrollDetailsDTO
                {
                    Id                   = record.Id,
                    Name                 = record.Name,
                    Sex                  = record.Sex,
                    AllHours             = record.AllHours,
                    OvertimeHours        = record.OvertimeHours,
                    DaytimeHours         = record.DaytimeHours,
                    DaysOfLeave          = record.DaysOfLeave,
                    DaysOfWork           = record.DaysOfWork,
                    TimesOfDinner        = record.TimesOfDinner,
                    IsFullAttendance     = record.IsFullAttendance,
                    Post                 = _pinhuaContext.岗位主表.AsNoTracking().FirstOrDefault(p => p.Id == file.PostId).OperatingPost,
                    DaytimeAmount        = record.DaytimeHours * result.DaytimePrice,
                    OvertimeAmount       = record.OvertimeHours * result.OvertimePrice,
                    FullAttendanceAmount = record.IsFullAttendance ? record.DaytimeHours * result.FullAttendancePrice : 0,
                    DinnerAmount         = record.TimesOfDinner * -2,
                    PriceOverview        = $"{(record.IsFullAttendance ? result.DaytimePrice + result.FullAttendancePrice : result.DaytimePrice)?.ToString("0.0")} / {result.OvertimePrice?.ToString("0.0")}",
                };
                x.AllHoursAmountWithFullAttendance = x.DaytimeAmount + x.OvertimeAmount + x.FullAttendanceAmount;
                x.FinalAmount = x.DaytimeAmount + x.OvertimeAmount + x.FullAttendanceAmount + x.DinnerAmount;
                list.Add(x);
            }
            return(list);
        }