Ejemplo n.º 1
0
        public ModelSOTPEmpDetail GetDetailPending(int prid, int EmpID, ViewUserEmp LoggedInUser)
        {
            ModelSOTPEmpDetail vm  = new ModelSOTPEmpDetail();
            PR_PayrollPeriod   prp = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), prid);
            HR_Employee        emp = db.HR_Employee.First(aa => aa.EmployeeID == EmpID);

            //if (DateTime.Today > prp.SupervisorCutOffDate)
            //    vm.IsLate = true;
            //else
            vm.IsLate  = false;
            vm.EmpID   = (int)EmpID;
            vm.EmpName = emp.FullName;
            vm.DeptID  = (int)emp.SectionID;
            vm.List    = OTHelperRecommended.GetConvertedDailyOTList(db.ViewDailyOTEntries.Where(aa => aa.EmployeeID == vm.EmpID && aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate).ToList());
            if (vm.List.Count > 0)
            {
                vm.SystemOT    = OTHelperManager.ConverMinIntoHours(vm.List.Sum(aa => aa.SystemOTMins));
                vm.ClaimedOT   = OTHelperManager.ConverMinIntoHours(vm.List.Sum(aa => aa.ClaimedOTMins));
                vm.TotalDays   = vm.List.Count();
                vm.TotalAmount = vm.List.Sum(aa => aa.OTAmount);
            }
            vm.DivRemainingBudget = OTHelperManager.GetDivRemainingBudget(OTHelperManager.GetDivisionIDs(OTHelperManager.ConvertDeptIDList(emp.SectionID), db.HR_Section.ToList()), db.BG_OTDivision.ToList(), (int)prp.FinYearID);
            vm.PeriodName         = prp.PName;
            vm.PeriodID           = prp.PID;
            vm.OTPolicy           = "OT Days Forward Policy: Maximum Days in Week = " + emp.Att_OTPolicy.DaysInWeek.ToString() + " , Maximum Days in Month = " + emp.Att_OTPolicy.DaysInMonth.ToString();
            vm.OTPolicyDays       = "OT Claimed Hours Policy: Normal Day= " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayOTStartLimitHour) + " to " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayOTEndLimitHour) + ", Rest & GZ Day= " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayGOTStartLimitHour) + " to " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayGOTEndLimitHour);
            vm.Count = vm.List.Count;

            ViewBag.DecisionID  = new SelectList(OTHelperManager.GetOTStatusForApprover(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F");
            ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForRecommender(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName");
            return(vm);
        }
        public ActionResult SOTDetailList(int?EmpID, int?PayrollPeriodID)
        {
            ViewUserEmp        LoggedInUser = Session["LoggedUser"] as ViewUserEmp;
            ModelSOTPEmpDetail vm           = new ModelSOTPEmpDetail();
            int prid = Convert.ToInt32(Session["PRID"].ToString());

            vm         = GetDetailPending(prid, (int)EmpID, LoggedInUser);
            vm.Message = new List <string>();
            return(View(vm));
        }
Ejemplo n.º 3
0
        private List <string> IsValidate(ModelSOTPEmpDetail model, string[] checkedEmpDates)
        {
            List <string> messages = new List <string>();

            if (model.IsLate == true)
            {
                if (model.Justification == null || model.Justification == "")
                {
                    messages.Add("Please provide justification for late subission of overtime");
                }
            }
            if (model.Certified == false)
            {
                messages.Add("Please verify this employee does not claim daily overtime allowance on these dates");
            }
            if (checkedEmpDates != null)
            {
                foreach (var id in checkedEmpDates)
                {
                    int    chNo    = Convert.ToInt32(id);
                    string COTHour = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                    if (COTHour.Count() == 4)
                    {
                        try
                        {
                            int COTMins = OTHelperManager.ConvertStringTimeToMin(COTHour);
                        }
                        catch (Exception ex)
                        {
                            messages.Add("Claimed Overtime is not in correct format");
                        }
                    }
                    else
                    {
                        messages.Add("Claimed Overtime is not in correct format");
                    }
                }
            }
            else
            {
                messages.Add("Select Atleast One Entry");
            }


            return(messages);
        }
Ejemplo n.º 4
0
        public ModelSOTPEmpDetail GetDetailPendingHR(int prid, int EmpID, ViewUserEmp LoggedInUser)
        {
            ModelSOTPEmpDetail vm  = new ModelSOTPEmpDetail();
            PR_PayrollPeriod   prp = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), prid);
            HR_Employee        emp = db.HR_Employee.First(aa => aa.EmployeeID == EmpID);

            if (DateTime.Today > prp.SupervisorCutOffDate)
            {
                vm.IsLate = true;
            }
            else
            {
                vm.IsLate = false;
            }
            vm.EmpID   = (int)EmpID;
            vm.EmpName = emp.FullName;
            int amount = 0;

            if (LoggedInUser.UserType == "H" || LoggedInUser.UserType == "A")
            {
                ViewBag.DecisionID  = new SelectList(OTHelperManager.GetOTStatusForSupervisor(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F");
                ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForSupervisor(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName");
            }
            else
            {
                ViewBag.DecisionID  = new SelectList(OTHelperManager.GetOTStatusForSupervisor(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F");
                ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForSupervisor(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName");
            }
            vm.List = OTHelperRecommended.GetConvertedDailyOTListSimple(db.ViewDailyOTEntries.Where(aa => aa.EmpID == EmpID && aa.OTProcessingPeriodID == prp.PID).ToList());
            vm.DivRemainingBudget = OTHelperManager.GetDivRemainingBudget(OTHelperManager.ConvertDeptIDList(emp.SectionID), db.BG_OTDivision.ToList(), (int)prp.FinYearID);
            vm.PeriodName         = prp.PName;
            vm.PeriodID           = prp.PID;
            vm.OTPolicy           = "Policy Details: Maximum Days in Week = " + emp.Att_OTPolicy.DaysInWeek.ToString() + " , Maximum Days in Month = " + emp.Att_OTPolicy.DaysInMonth.ToString();
            vm.TotalAmount        = amount;
            vm.Count = vm.List.Count;
            return(vm);
        }
Ejemplo n.º 5
0
        public ActionResult AOTDetailList(ModelSOTPEmpDetail model)
        {
            List <string>    messages        = new List <string>();
            ViewUserEmp      LoggedInUser    = Session["LoggedUser"] as ViewUserEmp;
            var              checkedEmpDates = Request.Form.GetValues("cbEmployee");
            HR_Employee      emp             = db.HR_Employee.First(aa => aa.EmployeeID == model.EmpID);
            PR_PayrollPeriod prp             = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), model.PeriodID);

            model.Certified = true;
            messages        = IsValidate(model, checkedEmpDates);
            if (messages.Count == 0)
            {
                List <Att_OTDailyEntry> attOts     = db.Att_OTDailyEntry.Where(aa => aa.EmpID == model.EmpID && aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate).ToList();
                List <Att_OTDailyEntry> TempattOts = new List <Att_OTDailyEntry>();
                foreach (var id in checkedEmpDates)
                {
                    int              chNo    = Convert.ToInt32(id);
                    string           EmpDate = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                    string           COTHour = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                    int              COTMins = OTHelperManager.ConvertStringTimeToMin(COTHour);
                    Att_OTDailyEntry obj     = attOts.First(aa => aa.EmpDate == EmpDate);
                    obj.ApprovedOTMin = COTMins;
                    obj.OTAmount      = OTHelperManager.GetOTAmount(emp.HR_Grade, obj.ApprovedOTMin, obj.DutyCode);
                    TempattOts.Add(obj);
                }
                if (emp.Att_OTPolicy.DaysInMonth > 0)
                {
                    List <Att_OTDailyEntry> atoTemp = new List <Att_OTDailyEntry>();
                    atoTemp.AddRange(TempattOts);
                    //atoTemp.AddRange(attOts.Where(aa => aa.StatusID == "F" || aa.StatusID == "A").ToList());
                    // check for Monthly Limit
                    if (atoTemp.Count > emp.Att_OTPolicy.DaysInMonth)
                    {
                        messages.Add("Your Monthly overtime claim limit exceeds.");
                    }
                    else
                    {
                        // check for weekly limit
                        if (emp.Att_OTPolicy.DaysInWeek > 0)
                        {
                            if (OTHelperManager.IsValidWeekPolicy(atoTemp.OrderByDescending(aa => aa.OTDate).ToList(), prp, emp.Att_OTPolicy.DaysInWeek))
                            {
                                messages.Add("Your weekly overtime claim limit exceeds.");
                            }
                        }
                    }
                }
                // check for daily ot limit
                {
                    List <string> msgs = OTHelperManager.IsValidDailyOT(TempattOts, emp.Att_OTPolicy);
                    if (msgs.Count > 0)
                    {
                        messages.AddRange(msgs);
                    }
                }
                if (checkedEmpDates != null)
                {
                    if (messages.Count == 0)
                    {
                        int CurrentPeriodID = db.PR_PayrollPeriod.OrderByDescending(aa => aa.PID).First().PID;
                        foreach (var id in checkedEmpDates)
                        {
                            int              chNo      = Convert.ToInt32(id);
                            string           oldStatus = "P";
                            string           EmpDate   = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                            string           COTHour   = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                            Att_OTDailyEntry atot      = attOts.First(aa => aa.EmpDate == EmpDate);
                            // Save Log
                            db.Att_OTDForward.Add(OTHelperManager.CreateOTLog(atot, LoggedInUser, model.RecommendID, model.Justification, model.DecisionID, "Recommend", CurrentPeriodID));
                            oldStatus     = atot.StatusID;
                            atot.StatusID = model.DecisionID;
                            if (LoggedInUser.UserType == "R")
                            {
                                if (atot.StatusID == "R")
                                {
                                    atot.FtoARDateTime        = DateTime.Now;
                                    atot.FtoARUserID          = LoggedInUser.UserID;
                                    atot.CancelByID           = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = CurrentPeriodID;
                                }
                                else
                                {
                                    if (model.IsLate == true)
                                    {
                                        atot.Remarks = model.Justification;
                                    }
                                    atot.ApprovedByID         = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = CurrentPeriodID;
                                    atot.FtoARDateTime        = DateTime.Now;
                                    atot.FtoARUserID          = LoggedInUser.UserID;
                                }
                            }
                        }
                        db.SaveChanges();

                        // Cancel All others
                        foreach (var item in attOts.Where(aa => aa.EmpID == model.EmpID && aa.StatusID == "P").ToList())
                        {
                            item.StatusID             = "R";
                            item.PtoFCDateTime        = DateTime.Now;
                            item.PtoFCUserID          = LoggedInUser.UserID;
                            item.CancelByID           = LoggedInUser.UserID;
                            item.OTProcessingPeriodID = CurrentPeriodID;
                        }
                        db.SaveChanges();
                        return(Json("OK"));
                    }
                }
                else
                {
                    messages.Add("No Entry Selected");
                }
            }
            return(Json(messages));
        }
Ejemplo n.º 6
0
        public ActionResult HROTDetailList(ModelSOTPEmpDetail model)
        {
            List <string>    messages        = new List <string>();
            ViewUserEmp      LoggedInUser    = Session["LoggedUser"] as ViewUserEmp;
            var              checkedEmpDates = Request.Form.GetValues("cbEmployee");
            HR_Employee      emp             = db.HR_Employee.First(aa => aa.EmployeeID == model.EmpID);
            PR_PayrollPeriod prp             = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), model.PeriodID);

            //messages = IsValidate(model);
            if (messages.Count == 0)
            {
                List <Att_OTDailyEntry> attOts     = db.Att_OTDailyEntry.Where(aa => aa.EmpID == model.EmpID && aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate).ToList();
                List <Att_OTDailyEntry> TempattOts = new List <Att_OTDailyEntry>();
                foreach (var id in checkedEmpDates)
                {
                    int    chNo    = Convert.ToInt32(id);
                    string EmpDate = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                    string COTHour = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                    TempattOts.Add(attOts.First(aa => aa.EmpDate == EmpDate));
                }
                if (emp.Att_OTPolicy.DaysInMonth > 0)
                {
                    // check for Monthly Limit
                    if (TempattOts.Count > emp.Att_OTPolicy.DaysInMonth)
                    {
                        messages.Add("Your Monthly overtime claim limit exceeds.");
                    }
                    else
                    {
                        // check for weekly limit
                        if (emp.Att_OTPolicy.DaysInWeek > 0)
                        {
                            if (OTHelperManager.IsValidWeekPolicy(TempattOts.OrderByDescending(aa => aa.OTDate).ToList(), prp, emp.Att_OTPolicy.DaysInWeek))
                            {
                                messages.Add("Your weekly overtime claim limit exceeds.");
                            }
                        }
                    }
                }
                // check for daily ot limit
                {
                    //if (OTHelperManager.IsValidDailyOT(TempattOts, emp.Att_OTPolicy))
                    //    messages.Add("Your daily overtime claim limit exceeds.");
                }
                if (checkedEmpDates != null)
                {
                    if (messages.Count == 0)
                    {
                        foreach (var id in checkedEmpDates)
                        {
                            int              chNo    = Convert.ToInt32(id);
                            string           EmpDate = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                            string           COTHour = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                            Att_OTDailyEntry atot    = attOts.First(aa => aa.EmpDate == EmpDate);
                            atot.StatusID = Request.Form["DecisionID"].ToString();
                            if (LoggedInUser.UserType == "N")
                            {
                                if (atot.StatusID == "C")
                                {
                                    //atot.NtoPDateTime = DateTime.Now;
                                    atot.CancelByID = LoggedInUser.UserID;
                                }
                                else
                                {
                                    atot.ForwardToID = Convert.ToInt32(Request.Form["RecommendID"]);
                                    //atot.NtoPDateTime = DateTime.Now;
                                    //atot.NtoPUserID = LoggedInUser.UserID;
                                    //atot.OTProcessingPeriod = model.PeriodID;
                                }
                            }
                            else if (LoggedInUser.UserType == "R")
                            {
                                if (atot.StatusID == "R")
                                {
                                    atot.PtoFCDateTime = DateTime.Now;
                                    atot.RejectByID    = LoggedInUser.UserID;
                                }
                                else
                                {
                                    atot.ForwardToID          = Convert.ToInt32(Request.Form["RecommendID"]);
                                    atot.PtoFCDateTime        = DateTime.Now;
                                    atot.PtoFCUserID          = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = model.PeriodID;
                                }
                            }
                            else if (LoggedInUser.UserType == "P")
                            {
                                if (atot.StatusID == "R")
                                {
                                    atot.FtoARDateTime = DateTime.Now;
                                    atot.RejectByID    = LoggedInUser.UserID;
                                }
                                else
                                {
                                    atot.ApprovedByID         = LoggedInUser.UserID;
                                    atot.FtoARDateTime        = DateTime.Now;
                                    atot.FtoARUserID          = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = model.PeriodID;
                                }
                            }
                            db.SaveChanges();
                        }
                        return(RedirectToAction("REmpPending", new { DeptID = emp.SectionID, PayrollPeriodID = prp.PID }));
                    }
                }
            }
            ModelSOTPEmpDetail vm = new ModelSOTPEmpDetail();

            //vm = GetDetailPending(model.PeriodID, (int)emp.EmployeeID, LoggedInUser);
            vm.Message = messages;
            return(View(vm));
        }