Exemplo n.º 1
0
        internal static Att_OTDForward CreateOTLog(Att_OTDailyEntry atot, ViewUserEmp LoggedInUser, int RecommendToID, string Justification, string StatusID, string Operation, int CurrentPeriodID)
        {
            Att_OTDForward atf = new Att_OTDForward();

            atf.OTDailyEntryID  = atot.POTAID;
            atf.ForwardFrom     = LoggedInUser.UserID;
            atf.ForwardTo       = RecommendToID;
            atf.UserID          = LoggedInUser.UserID;
            atf.EmpID           = atot.EmpID;
            atf.ProcessPeriodID = CurrentPeriodID;
            atf.Remarks         = Justification;
            atf.CliamedOTMins   = atot.ApprovedOTMin;
            atf.OldStatusID     = atot.StatusID;
            atf.Operation       = Operation;
            atf.NewStatusID     = StatusID;
            atf.CDTime          = DateTime.Now;
            atf.OTPeriodID      = atot.PeriodID;
            return(atf);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }