Exemplo n.º 1
0
        public IEnumerable <Att_OvertimeModel> Get(Guid id)
        {
            var service = new Att_OvertimeServices();
            List <Att_OvertimeEntity> lst     = new List <Att_OvertimeEntity>();
            List <object>             objpara = new List <object>();

            objpara.AddRange(new object[3]);
            objpara[0] = id;
            objpara[1] = 1;
            objpara[2] = int.MaxValue - 1;
            var rs = service.GetData <Att_OvertimeEntity>(id, ConstantSql.hrm_att_sp_get_OvertimeByProfileId, UserLogin, ref status).FirstOrDefault();

            lst.Add(rs);
            return(lst.Select(item => new Att_OvertimeModel
            {
                ID = item.ID,
                ProfileID = item.ProfileID,
                ProfileName = item.ProfileName,
                Status = item.Status,
                WorkDate = item.WorkDate,
                RegisterHours = item.RegisterHours,
                MethodPayment = item.MethodPayment,
                ReasonOT = item.ReasonOT,
                ShiftID = item.ShiftID,
                OvertimeTypeID = item.OvertimeTypeID,
                UserApproveID = item.UserApproveID,
                UserApproveID2 = item.UserApproveID2,
                ShiftName = item.ShiftName,
                OvertimeTypeName = item.OvertimeTypeName
            }));
        }
Exemplo n.º 2
0
        public void NUnit_Overtime_Domain_Add()
        {
            Att_OvertimeServices service = new Att_OvertimeServices();
            var result  = "";
            int countSC = 0;

            for (int i = 1; i <= 10; i++)
            {
                var model = new Att_Overtime
                {
                    ProfileID     = 1,
                    MethodPayment = "MethodPayment " + i,
                };
                result = service.Add <Att_Overtime>(model);
                NUnit.Framework.Assert.IsNull(result);
                if (result != "")
                {
                    countSC += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + model.Id
                                      + " | " + model.MethodPayment
                                      );
                }
            }
            Console.WriteLine("Total success record: " + countSC);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Xử lí lưu xác nhận tăng ca
        /// </summary>
        /// <param name="contract"></param>
        /// <returns></returns>
        public Att_OvertimeModel Post(IEnumerable <Att_OvertimeModel> listmodel)
        {
            Att_OvertimeModel model = new Att_OvertimeModel();
            var    service          = new Att_OvertimeServices();
            string result           = service.SaveOvertimeConfirm(listmodel.Select(item => new Att_OvertimeEntity
            {
                ID           = item.ID,
                ConfirmHours = item.ConfirmHours
            }
                                                                                   ));

            return(model);
        }
Exemplo n.º 4
0
        public void NUnit_Overtime_Domain_GetById()
        {
            Att_OvertimeServices service = new Att_OvertimeServices();
            var status = string.Empty;
            var model  = new Att_Overtime {
                Id = 5
            };
            var result = service.GetById <Att_OvertimeEntity>(model.Id, ref status);

            NUnit.Framework.Assert.IsNotNull(result);
            Console.Write("SearchResult: " + result.Id
                          + " | " + result.ProfileID
                          + " | " + result.MethodPayment
                          );
        }
Exemplo n.º 5
0
        public void NUnit_Overtime_Domain_Remove()
        {
            Att_OvertimeServices service = new Att_OvertimeServices();
            int rs    = 0;
            var model = new Att_Overtime {
                Id = 5
            };
            var result = service.Remove <Att_Overtime>(model.Id);

            NUnit.Framework.Assert.IsNull(result);
            if (result != "")
            {
                rs += 1;
                Console.WriteLine("Process Success >>> Remove >>> " + model.Id);
            }
        }
Exemplo n.º 6
0
        //SonVo - 20140617 - chuyển thành trạng thái Sumit
        public ActionResult SubmitOvertime(string selectedIds)
        {
            List <Guid> ids = new List <Guid>();

            if (selectedIds != null)
            {
                ids = selectedIds
                      .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                      .Select(x => new Guid(x))
                      .ToList();
            }
            Att_OvertimeServices service = new Att_OvertimeServices();

            service.SubmitOvertime(ids);
            return(Json(""));
        }
Exemplo n.º 7
0
        public void NUnit_Overtime_Domain_Edit()
        {
            Att_OvertimeServices service = new Att_OvertimeServices();
            var model = new Att_Overtime
            {
                Id            = 5,
                ProfileID     = 1,
                MethodPayment = "Update Name ",
            };
            var result = service.Edit <Att_Overtime>(model);

            NUnit.Framework.Assert.IsNull(result);
            if (result != "")
            {
                Console.WriteLine("Process Success >>> Update >>> " + model.Id
                                  + " | " + model.ProfileID
                                  + " | " + model.MethodPayment
                                  );
            }
        }
Exemplo n.º 8
0
        public IEnumerable <Att_OvertimeModel> Post(Att_ComputeOvertimeModel model)
        {
            Att_WorkDayServices serviceWorkDay = new Att_WorkDayServices();
            var status     = string.Empty;
            var lstWorkDay = serviceWorkDay.GetWorkDaysByInOut(model.DateFrom, model.DateTo);
            Cat_ShiftServices serviceShift = new Cat_ShiftServices();
            var lstShift = serviceShift.GetDataNotParam <Cat_ShiftEntity>(ConstantSql.hrm_cat_sp_get_Shift, UserLogin, ref status);

            //Cat_ShiftItemServices serviceShiftItem = new Cat_ShiftItemServices();
            //var lstShiftItem = serviceShiftItem.GetCatShiftItem();
            var lstShiftItem = new List <Cat_ShiftItemEntity>();
            Cat_DayOffServices servicesDayOff = new Cat_DayOffServices();
            var lstDayOff = servicesDayOff.GetAllUseEntity <Cat_DayOffEntity>(ref status).ToList();

            Cat_OvertimeTypeServices servicesOvertimeType = new Cat_OvertimeTypeServices();
            var lstOvertimeType = servicesOvertimeType.GetDataNotParam <Cat_OvertimeTypeEntity>(ConstantSql.hrm_cat_sp_get_OvertimeType, UserLogin, ref status);

            var Att_OvertimeInfoFillterAnalyze = new Att_OvertimeInfoFillterAnalyze()
            {
                isAllowGetAfterShift           = model.isAllowGetAfterShift,
                isAllowGetBeforeShift          = model.isAllowGetBeforeShift,
                isAllowGetInShift              = model.isAllowGetInShift,
                isAllowGetOTOutterShift        = model.isAllowGetOTOutterShift,
                isAllowGetTypeBaseOnActualDate = model.isAllowGetTypeBaseOnActualDate,
                isAllowGetTypeBaseOnBeginShift = model.isAllowGetTypeBaseOnBeginShift,
                isAllowGetTypeBaseOnEndShift   = model.isAllowGetTypeBaseOnEndShift,
                MininumOvertimeHour            = model.MininumOvertimeHour
            };

            var service = new Att_OvertimeServices();
            var result  = service.AnalyzeOvertime(lstWorkDay,
                                                  lstShift,
                                                  lstShiftItem,
                                                  lstDayOff,
                                                  lstOvertimeType,
                                                  Att_OvertimeInfoFillterAnalyze, UserLogin).ToList().Translate <Att_OvertimeModel>();

            return(result);
        }
Exemplo n.º 9
0
        public List <Att_OvertimeEntity> LoadData(Att_OvertimeEntity overtime, string ProfileIds, bool ByShiftProfile, string UserLogin)
        {
            List <Att_OvertimeEntity> listOvertimeInsert = new List <Att_OvertimeEntity>();

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork        = (IUnitOfWork)(new UnitOfWork(context));
                var repoCat_DayOff    = new CustomBaseRepository <Cat_DayOff>(unitOfWork);
                var repoAtt_LeaveDay  = new CustomBaseRepository <Att_LeaveDay>(unitOfWork);
                var repoAtt_Pregnancy = new CustomBaseRepository <Att_Pregnancy>(unitOfWork);

                List <Att_Pregnancy> _LstPregnancy = new List <Att_Pregnancy>();
                Att_OvertimeServices overtimeDAO   = new Att_OvertimeServices();
                string status = string.Empty;

                string      proStr            = Common.DotNetToOracle(ProfileIds);
                var         lstProfileDetails = GetData <Hre_ProfileEntity>(proStr, ConstantSql.hrm_hr_sp_get_ProfileByIds, UserLogin, ref status);
                List <Guid> listProfileId     = lstProfileDetails.Select(s => s.ID).ToList();

                string        key      = "HRM_ATT_OT";
                List <object> lstSysOT = new List <object>();
                lstSysOT.Add(key);
                lstSysOT.Add(null);
                lstSysOT.Add(null);
                var config = GetData <Sys_AllSettingEntity>(lstSysOT, ConstantSql.hrm_sys_sp_get_AllSetting, UserLogin, ref status);
                if (config == null)
                {
                    return(listOvertimeInsert);
                }

                var OTThanTwoHour     = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_ISALLOWADDHOURWHENOTTHANTWOHOUR.ToString()).FirstOrDefault();
                var OTBreakTime       = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_DONOTSPLITOTBREAKTIME.ToString()).FirstOrDefault();
                var inmaternityregime = config.Where(s => s.Name == AppConfig.HRM_ATT_OT_ALLOWREGISTEROTWHENINMATERNITYREGIME.ToString()).FirstOrDefault();


                List <Cat_DayOff> lstDayOff = repoCat_DayOff.FindBy(s => s.IsDelete == null).ToList();
                if (OTThanTwoHour.Value1 == bool.TrueString)
                {
                    lstDayOff = lstDayOff.Where(dayoff => dayoff.Type == HolidayType.E_HOLIDAY_HLD.ToString()).ToList();
                }

                bool isAllowCutOTBreakHour = false;
                if (OTBreakTime.Value1 == bool.TrueString)
                {
                    isAllowCutOTBreakHour = true;
                }

                Att_OvertimeEntity baseOT = null;

                //Trung.Le 20120621 #0014337 Nếu như CÓ THÊM đăng ký Leave loại nghỉ lễ (Mã: HLD) thì ngày đó tương đương với ngày nghỉ lễ
                string              LeavedayTypeCode_HLD = LeavedayTypeCode.HLD.ToString();
                string              E_HOLIDAY_HLD        = HolidayType.E_HOLIDAY_HLD.ToString();
                DateTime            DateFromOvertime     = overtime.WorkDate.Date;
                DateTime            DateEndOvertime      = overtime.WorkDate.Add(TimeSpan.FromHours(overtime.RegisterHours)).Date;
                string              E_APPROVED           = LeaveDayStatus.E_APPROVED.ToString();
                List <Att_LeaveDay> lstLeaveDayHoliday   = repoAtt_LeaveDay
                                                           .FindBy(att => att.IsDelete == null && DateEndOvertime >= att.DateStart && DateFromOvertime <= att.DateEnd &&
                                                                   att.Status == E_APPROVED && att.Cat_LeaveDayType.Code == LeavedayTypeCode_HLD &&
                                                                   listProfileId.Contains(att.ProfileID))
                                                           .ToList();


                if (overtime.ID == Guid.Empty)
                {
                    //baseOT = GetBaseDataOvertime(baseOT, overtime, profile);
                    string _pregnancyType = PregnancyType.E_LEAVE_EARLY.ToString();
                    _LstPregnancy = repoAtt_Pregnancy
                                    .FindBy(prg => prg.Type == _pregnancyType && prg.DateEnd >= overtime.WorkDate.Date && prg.DateStart <= overtime.WorkDate)
                                    .ToList();

                    Hre_Profile _hreProfile = new Hre_Profile();
                    foreach (var profile in lstProfileDetails)
                    {
                        overtime.ProfileID   = profile.ID;
                        overtime.ProfileName = profile.ProfileName;
                        overtime.CodeEmp     = profile.CodeEmp;

                        listOvertimeInsert.AddRange(AnalysisOvertime(overtime,
                                                                     GetListDayOffPerProfile(lstLeaveDayHoliday, profile, lstDayOff, E_HOLIDAY_HLD) //lstDayOff
                                                                     , _LstPregnancy, ByShiftProfile, isAllowCutOTBreakHour, UserLogin));
                    }
                }
                #region overtime.ID == Guid.Empty && strListId.Length > 1
                //if (overtime.ID == Guid.Empty && strListId.Length > 1)
                //{
                //    List<Hre_Profile> listAllProfile = EntityService.GetEntityList<Hre_Profile>(GuidContext, LoginUserID.Value, pf => listProfileId.Contains(pf.ID));
                //    foreach (Guid _pfID in listProfileId)
                //    {
                //        if (_pfID != pfid)
                //        {
                //            baseOT = GetBaseDataOvertime(baseOT, overtime, profile);

                //            List<Hre_Profile> _listPfTemp = listAllProfile.Where(pf => pf.ID == _pfID).ToList();
                //            if (_listPfTemp.Count != 1)
                //            {
                //                continue;
                //            }
                //            profile = _listPfTemp[0];
                //            baseOT.Hre_Profile = profile;
                //            listOvertimeInsert.AddRange(overtimeDAO.AnalysisOvertime(baseOT,
                //                GetListDayOffPerProfile(lstLeaveDayHoliday, profile, lstDayOff, E_HOLIDAY_HLD) //lstDayOff
                //                , _LstPregnancy, GuidContext, LoginUserID.Value, rdbByShiftProfile, isAllowCutOTBreakHour));
                //        }
                //    }
                //}
                #endregion
                #region tan.do danh dau nguoi huong che do thai san
                //_listbaseData = new List<BaseDataOvertime>();
                if (inmaternityregime.Value1 != bool.TrueString)
                {
                    DateTime    time        = overtime.WorkDate;
                    string      type        = PregnancyStatus.E_LEAVE_EARLY.ToString();
                    List <Guid> guids       = listOvertimeInsert.Select(s => s.ProfileID).ToList();
                    var         pregnancies = repoAtt_Pregnancy
                                              .FindBy(s => s.IsDelete == null && s.DateStart <= time && time <= s.DateEnd && s.Type == type &&
                                                      guids.Contains(s.ProfileID))
                                              .ToList();
                    foreach (var baseDataOvertime in listOvertimeInsert)
                    {
                        foreach (var attPregnancy in pregnancies)
                        {
                            if (baseDataOvertime.ProfileID == attPregnancy.ProfileID)
                            {
                                //_listbaseData.Add(baseDataOvertime);
                            }
                        }
                    }
                }
                #endregion
                return(listOvertimeInsert);
            }
        }
Exemplo n.º 10
0
        //[Test]
        public void NUnit_Overtime_Domain_AnalyzeOvertime()
        {
            #region listWorkDay
            List <Att_WorkDayEntity> listWorkDay    = new List <Att_WorkDayEntity>();
            Att_WorkDayEntity        _workDayEntity = new Att_WorkDayEntity()
            {
                ProfileID    = 1,
                WorkDate     = DateTime.Parse("01-09-14"),
                FirstInTime  = DateTime.Parse("01-09-14 07:00:00"),
                LastOutTime  = DateTime.Parse("02-09-14 07:00:00"),
                InTime1      = DateTime.Parse("01-09-14 07:00:00"),
                OutTime1     = DateTime.Parse("02-09-14 07:00:00"),
                ShiftID      = 1,
                WorkDuration = (float)14.5
            };
            listWorkDay.Add(_workDayEntity);
            #endregion

            #region listShift
            List <Cat_ShiftEntity> listShift    = new List <Cat_ShiftEntity>();
            Cat_ShiftEntity        _shiftEntity = new Cat_ShiftEntity()
            {
                Id             = 1,
                ShiftName      = "Ca Test",
                InTime         = DateTime.Parse("01-09-14 07:00:00"),
                CoOut          = 9.5,
                CoBreakIn      = 4,
                CoBreakOut     = 5.5,
                NightTimeStart = DateTime.Parse("01-09-14 21:00:00"),
                NightTimeEnd   = DateTime.Parse("02-09-14 05:00:00")
            };
            listShift.Add(_shiftEntity);
            #endregion

            #region listShiftItem
            List <Cat_ShiftItemEntity> listShiftItem     = new List <Cat_ShiftItemEntity>();
            Cat_ShiftItemEntity        _shiftItemEntity1 = new Cat_ShiftItemEntity()
            {
                ShiftItemName = "Giao Ca Sang",
                ShiftID       = 1,
                CoFrom        = 4,
                CoTo          = 5.5
            };
            Cat_ShiftItemEntity _shiftItemEntity2 = new Cat_ShiftItemEntity()
            {
                ShiftItemName = "Giao Ca Toi",
                ShiftID       = 1,
                CoFrom        = 9.5,
                CoTo          = 10
            };
            listShiftItem.Add(_shiftItemEntity1);
            listShiftItem.Add(_shiftItemEntity2);
            #endregion

            #region listDayOff
            List <Cat_DayOffEntity> listDayOff     = new List <Cat_DayOffEntity>();
            Cat_DayOffEntity        _DayOffEntity1 = new Cat_DayOffEntity()
            {
                DateOff = DateTime.Parse("02-09-14"),
            };
            listDayOff.Add(_DayOffEntity1);
            #endregion

            #region listOvertimeType
            List <Cat_OvertimeTypeEntity> listOvertimeType     = new List <Cat_OvertimeTypeEntity>();
            Cat_OvertimeTypeEntity        _OvertimeTypeEntity1 = new Cat_OvertimeTypeEntity()
            {
                OvertimeTypeName = "OT - 3.0",
                OvertimeTypeCode = "E_HOLIDAY",
                Rate             = 3,
                TaxRate          = 1,
            };
            Cat_OvertimeTypeEntity _OvertimeTypeEntity5 = new Cat_OvertimeTypeEntity()
            {
                OvertimeTypeName = "OT - 3.5",
                OvertimeTypeCode = "E_HOLIDAY_NIGHTSHIFT",
                Rate             = 3.5,
                TaxRate          = 1,
            };
            Cat_OvertimeTypeEntity _OvertimeTypeEntity2 = new Cat_OvertimeTypeEntity()
            {
                OvertimeTypeName = "OT - 2.0",
                OvertimeTypeCode = "E_WEEKEND",
                Rate             = 1,
                TaxRate          = 1,
            };

            Cat_OvertimeTypeEntity _OvertimeTypeEntity3 = new Cat_OvertimeTypeEntity()
            {
                OvertimeTypeName = "OT - 1.5",
                OvertimeTypeCode = "E_WORKDAY",
                Rate             = 1.5,
                TaxRate          = 1,
            };

            Cat_OvertimeTypeEntity _OvertimeTypeEntity4 = new Cat_OvertimeTypeEntity()
            {
                OvertimeTypeName = "OT - 2.0",
                OvertimeTypeCode = "E_WORKDAY_NIGHTSHIFT",
                Rate             = 2,
                TaxRate          = 1,
            };

            listOvertimeType.Add(_OvertimeTypeEntity1);
            listOvertimeType.Add(_OvertimeTypeEntity2);
            listOvertimeType.Add(_OvertimeTypeEntity3);
            listOvertimeType.Add(_OvertimeTypeEntity4);
            #endregion

            #region listOvertimeInfoFillterAnalyze
            Att_OvertimeInfoFillterAnalyze _OvertimeInfoFillterAnalyzeEntity = new Att_OvertimeInfoFillterAnalyze()
            {
                isAllowGetOTOutterShift        = true,
                isAllowGetBeforeShift          = false,
                isAllowGetAfterShift           = true,
                isAllowGetInShift              = false,
                isAllowGetTypeBaseOnActualDate = true,
                isAllowGetTypeBaseOnBeginShift = true,
                isAllowGetTypeBaseOnEndShift   = false,
                isAllowGetNightShift           = true,
                // cắt h qua đêm 12h khuya
                isBreakMiddleNight  = true,
                MininumOvertimeHour = 0.5
            };
            #endregion

            Att_OvertimeServices      service    = new Att_OvertimeServices();
            List <Att_OvertimeEntity> listResult = service.AnalyzeOvertime(listWorkDay, listShift, listShiftItem, listDayOff, listOvertimeType, _OvertimeInfoFillterAnalyzeEntity);
        }