예제 #1
0
        public string ApproveLeaveApplication(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, string Message)
        {
            //gets the First entry and comment box for the approval of the leave application
            LeaveApplication lvapplication = LeaveApplicationRepository.GetSingle((int)vmESSPCommon.PID);
            //if (DDService.IsDateLieBetweenActivePayroll(lvapplication.FromDate))
            //{
            //Gets Employee Information about the access of the location and company of the employee.
            List <VHR_EmployeeProfile> _emp     = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).ToList();
            VHR_EmployeeProfile        employee = DDService.GetEmployeeInfo(LoggedInUser).Where(aa => aa.PEmployeeID == lvapplication.EmpID).First();
            //Gets Employee Leave policy on the Type of leave applied
            LeavePolicy lvPolicy = AssistantLeave.GetEmployeeLeavePolicyID(_emp, lvapplication.LeaveTypeID, DDService.GetLeavePolicy().ToList());

            Expression <Func <PayrollPeriod, bool> > SpecificEntries96 = c => lvapplication.FromDate >= c.PRStartDate && lvapplication.FromDate <= c.PREndDate && c.PeriodStageID == "C";
            List <PayrollPeriod> dbPayrollPeriods = PayrollPeriodService.GetIndexSpecific(SpecificEntries96).ToList();

            if (dbPayrollPeriods.Count() > 0)
            {
                Message = "Cannot Approve leaves of Closed Payroll Period";
            }
            if (Message == "")
            {
                //Check the Leave balance if there are some leaves remaining of the employee whose leave is being approved.
                if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
                {
                    //Changes Leave Stage ID to "A" (Approved).
                    lvapplication.LeaveStageID = "A";
                    //Gets the leave Type through generic service.
                    LeaveType lvType = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                    LeaveApplicationService.BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
                    LeaveApplicationRepository.Edit(lvapplication);
                    LeaveApplicationRepository.Save();
                    UnitOfWork.Commit();
                    //Adds leave to leave data frim where its impact is generated on the reports.
                    LeaveApplicationService.AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
                    //Add Leaves to Att Data where Daily and Monthy Reporcessing of attendance occurs on the day
                    LeaveApplicationService.AddLeaveToAttData(lvapplication, lvType);
                    VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                    VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                    // Add notification to the Employee that leave has been approved.
                    DDService.SaveNotification((int)EmpUser.PUserID, "/ESSP/ESSPLeaveApp/Index",
                                               Convert.ToInt32(NTLeaveEnum.LeaveApproved), true, lvapplication.LineManagerID, lvapplication.PLeaveAppID);
                    //Add entry in the flow table
                    SaveLeaveApplicationFlow((int)EmpUser.PUserID, lvapplication.LineManagerID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);

                    //Save Email in the Notification Email table from where through services email is generated to employee about the approval of the leave Application.
                    Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                    VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();
                    DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                            ESSPText.GetApprovedLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveApproved));

                    // Disable Notification of the pending Leave.
                    int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                    Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                    DDService.DeleteNotification(SpecificEntries);
                }
            }
            return(Message);
        }
예제 #2
0
        public void ApprovalCode(VMESSPCommon vmESSPCommon, VMLoggedUser LoggedInUser, LeaveApplication lvapplication, LeavePolicy lvPolicy)
        {
            if (LeaveApplicationService.CheckLeaveBalance(lvapplication, lvPolicy))
            {
                //Changes Leave Stage ID to "A" (Approved).
                lvapplication.LeaveStageID = "A";
                //Gets the leave Type through generic service.
                LeaveType lvType = DDService.GetLeaveType().First(aa => aa.PLeaveTypeID == lvapplication.LeaveTypeID);
                LeaveApplicationService.BalanceLeaves(lvapplication, lvType, AssistantLeave.GetPayRollPeriodID(DDService.GetPayrollPeriod().ToList(), lvapplication.FromDate));
                LeaveApplicationRepository.Edit(lvapplication);
                LeaveApplicationRepository.Save();
                UnitOfWork.Commit();
                //Adds leave to leave data frim where its impact is generated on the reports.
                LeaveApplicationService.AddLeaveToLeaveData(lvapplication, lvType, lvPolicy);
                //Add Leaves to Att Data where Daily and Monthy Reporcessing of attendance occurs on the day
                LeaveApplicationService.AddLeaveToAttData(lvapplication, lvType);
                VHR_UserEmployee LMUser  = DDService.GetEmployeeUser(lvapplication.LineManagerID, null);
                VHR_UserEmployee EmpUser = DDService.GetEmployeeUser(null, lvapplication.EmpID);
                // Add notification to the Employee that leave has been approved.
                DDService.SaveNotification((int)EmpUser.PUserID, "/ESSP/ESSPLeaveApp/Index",
                                           Convert.ToInt32(NTLeaveEnum.LeaveApproved), true, lvapplication.LineManagerID, lvapplication.PLeaveAppID);
                //Add entry in the flow table
                SaveLeaveApplicationFlow((int)EmpUser.PUserID, lvapplication.LineManagerID, lvapplication.LeaveStageID, lvapplication.PLeaveAppID, "", vmESSPCommon.Comment);

                //Save Email in the Notification Email table from where through services email is generated to employee about the approval of the leave Application.
                Expression <Func <VAT_LeaveApplication, bool> > SpecificEntries3 = c => c.PLeaveAppID == lvapplication.PLeaveAppID;
                VAT_LeaveApplication vlvApplication = VEPESSPLeaveApplicationReporsitory.FindBy(SpecificEntries3).First();
                DDService.GenerateEmail(EmpUser.OfficialEmailID, "", "Leave Application # " + lvapplication.PLeaveAppID.ToString(),
                                        ESSPText.GetApprovedLeaveText(vlvApplication, EmpUser.UserEmployeeName, LMUser.UserEmployeeName, LMUser.DesignationName), LoggedInUser.PUserID, Convert.ToInt32(NTLeaveEnum.LeaveApproved));

                // Disable Notification of the pending Leave.
                int notiTypeID1 = Convert.ToInt32(NTLeaveEnum.LeavePending);
                Expression <Func <Notification, bool> > SpecificEntries = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID1) && c.PID == lvapplication.PLeaveAppID);
                DDService.DeleteNotification(SpecificEntries);

                // Disable Notification of the pending Leave.
                int notiTypeID2 = Convert.ToInt32(NTLeaveEnum.LeaveRecommend);
                Expression <Func <Notification, bool> > SpecificEntries2 = c => (c.UserID == LoggedInUser.PUserID && c.Status == true && (c.NotificationTypeID == notiTypeID2) && c.PID == lvapplication.PLeaveAppID);
                DDService.DeleteNotification(SpecificEntries2);
            }
        }