Esempio n. 1
0
        public ActionResult GetEmpLeaveBalance(string EmpNo, int?FinancialYearID)
        {
            Expression <Func <VHR_EmployeeProfile, bool> > SpecificData = c => c.OEmpID == EmpNo;
            List <VHR_EmployeeProfile> emps = EmployeeService.GetIndexSpecific(SpecificData);
            VMLeaveBalance             vm   = new VMLeaveBalance();

            if (emps.Count() > 0)
            {
                int EmployeeID = emps[0].PEmployeeID;
                Expression <Func <LeaveQuotaYear, bool> > SpecificData2 = c => c.EmployeeID == EmployeeID && c.FinancialYearID == FinancialYearID;
                List <LeaveQuotaYear> LvQuota = LeaveQuotaYearService.GetIndexSpecific(SpecificData2);
                //1   Annual
                //2   Casual
                //3   Sick
                //4   CPL
                if (LvQuota.Where(aa => aa.LeaveTypeID == 2).Count() > 0)
                {
                    vm.BalanceCL = LvQuota.First(aa => aa.LeaveTypeID == 2).GrandRemaining;
                    vm.TotalCL   = LvQuota.First(aa => aa.LeaveTypeID == 2).GrandTotal;
                }
                if (LvQuota.Where(aa => aa.LeaveTypeID == 1).Count() > 0)
                {
                    vm.BalanceAL    = LvQuota.First(aa => aa.LeaveTypeID == 1).YearlyRemaining;
                    vm.TotalAL      = LvQuota.First(aa => aa.LeaveTypeID == 1).YearlyTotal;
                    vm.BalanceAccum = LvQuota.First(aa => aa.LeaveTypeID == 1).CFRemaining;
                    vm.TotalAccum   = LvQuota.First(aa => aa.LeaveTypeID == 1).CFFromLastYear;
                }
                if (LvQuota.Where(aa => aa.LeaveTypeID == 3).Count() > 0)
                {
                    vm.BalanceSL = LvQuota.First(aa => aa.LeaveTypeID == 3).GrandRemaining;
                    vm.TotalSL   = LvQuota.First(aa => aa.LeaveTypeID == 3).GrandTotal;
                }
                if (LvQuota.Where(aa => aa.LeaveTypeID == 4).Count() > 0)
                {
                    vm.BalanceCPL = LvQuota.First(aa => aa.LeaveTypeID == 4).GrandRemaining;
                    vm.TotalCPL   = LvQuota.First(aa => aa.LeaveTypeID == 4).GrandTotal;
                }
                if (LvQuota.Where(aa => aa.LeaveTypeID == 11).Count() > 0)
                {
                    vm.BalanceEAL = LvQuota.First(aa => aa.LeaveTypeID == 11).GrandRemaining;
                    vm.TotalEAL   = LvQuota.First(aa => aa.LeaveTypeID == 11).GrandTotal;
                }
                if (LvQuota.Where(aa => aa.LeaveTypeID == 12).Count() > 0)
                {
                    vm.BalanceCME = LvQuota.First(aa => aa.LeaveTypeID == 12).GrandRemaining;
                    vm.TotalCME   = LvQuota.First(aa => aa.LeaveTypeID == 12).GrandTotal;
                }

                return(PartialView("LeaveBalance", vm));
            }
            else
            {
                return(Json("No", JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 2
0
        public List <VMLeaveBalance> GetYearlyLeaveBalance(List <VHR_EmployeeProfile> dbEmps, int FinancialYearID)
        {
            Expression <Func <LeaveQuotaYear, bool> > SpecificEntries = c => c.FinancialYearID == FinancialYearID;
            List <LeaveQuotaYear> dbLeaveQuotaYears = LeaveQuotaYearRepository.FindBy(SpecificEntries);
            Expression <Func <FinancialYear, bool> > SpecificFinancialYear = c => c.PFinancialYearID == FinancialYearID;
            FinancialYear         dbFinancialYear    = FinancialYearRepository.FindBy(SpecificFinancialYear).First();
            List <VMLeaveBalance> vmLeaveBalanceList = new List <VMLeaveBalance>();

            foreach (var dbEmp in dbEmps)
            {
                VMLeaveBalance vmLeaveBalance = new VMLeaveBalance();

                vmLeaveBalance.PEmployeeID  = dbEmp.PEmployeeID;
                vmLeaveBalance.OEmpID       = dbEmp.OEmpID;
                vmLeaveBalance.EmployeeName = dbEmp.EmployeeName;
                //vmLeaveBalance.OUName = dbEmp.OUName;
                vmLeaveBalance.LocationName       = dbEmp.LocationName;
                vmLeaveBalance.JobTitleName       = dbEmp.JobTitleName;
                vmLeaveBalance.EmploymentTypeName = dbEmp.EmploymentTypeName;
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).Count() > 0) // AL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).First();
                    vmLeaveBalance.TotalAL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceAL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailAL   = vmLeaveBalance.TotalAL - vmLeaveBalance.BalanceAL;
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).Count() > 0) // ACCU
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).First();
                    vmLeaveBalance.TotalAccum   = dbLeaveQuotaYear.CFFromLastYear;
                    vmLeaveBalance.BalanceAccum = dbLeaveQuotaYear.CFRemaining;
                    vmLeaveBalance.AvailAccum   = vmLeaveBalance.TotalAccum - vmLeaveBalance.BalanceAccum;
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 2).Count() > 0) // CL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 2).First();
                    vmLeaveBalance.TotalCL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceCL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailCL   = vmLeaveBalance.TotalCL - vmLeaveBalance.BalanceCL;
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 3).Count() > 0) //SL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 3).First();
                    vmLeaveBalance.TotalSL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceSL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailSL   = vmLeaveBalance.TotalSL - vmLeaveBalance.BalanceSL;
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 4).Count() > 0) //CPL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 4).First();
                    vmLeaveBalance.TotalCPL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceCPL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailCPL   = vmLeaveBalance.TotalCPL - vmLeaveBalance.BalanceCPL;
                }
                Expression <Func <LeaveData, bool> > SpecificEntries99 = c => c.LeaveTypeID == 9 && c.EmpID == dbEmp.PEmployeeID;
                List <LeaveData> dbLeaveDatas = LeaveDataRepository.FindBy(SpecificEntries99);
                vmLeaveBalance.AvailHajjLeaves = dbLeaveDatas.Where(aa => aa.EmpID == dbEmp.PEmployeeID && aa.HalfLeave == false && aa.LeaveTypeID == 9).Count() + (dbLeaveDatas.Where(aa => aa.HalfLeave == true && aa.EmpID == dbEmp.PEmployeeID && aa.LeaveTypeID == 9).Count() / 2);

                vmLeaveBalanceList.Add(vmLeaveBalance);
            }



            return(vmLeaveBalanceList);
        }
Esempio n. 3
0
        public static List <VMLeaveBalance> GetYearlyLeaveBalance(List <VHR_EmployeeProfile> dbEmps, FinancialYear dbFinYear, List <LeaveQuotaYear> dbLeaveQuotaYears, List <LeavePolicy> dbLeavePolicies,
                                                                  List <LeaveData> dbLeaveDatas, ABESSPEntities db)
        {
            List <VMLeaveBalance> vmLeaveBalanceList = new List <VMLeaveBalance>();

            foreach (var dbEmp in dbEmps)
            {
                float          TotalLvDays    = 21;
                VMLeaveBalance vmLeaveBalance = new VMLeaveBalance();
                if (dbEmp.ALPolicyID != null && dbLeavePolicies.Where(aa => aa.PLeavePolicyID == dbEmp.ALPolicyID).Count() > 0)
                {
                    TotalLvDays = (float)dbLeavePolicies.First(aa => aa.PLeavePolicyID == dbEmp.ALPolicyID).TotalDays;
                }
                vmLeaveBalance.PEmployeeID   = dbEmp.PEmployeeID;
                vmLeaveBalance.EmployeeName  = dbEmp.EmployeeName;
                vmLeaveBalance.DOJ           = dbEmp.DOJ;
                vmLeaveBalance.ServiceLength = GetServiceLength(dbEmp.DOJ, dbEmp.ResignDate);
                if (dbEmp.Status == "Resigned")
                {
                    vmLeaveBalance.OEmpID = dbEmp.OEmpID + " (Resigned Date: " + dbEmp.ResignDate.Value.ToString("dd-MM-yyyy") + ")";
                    int PayrollPeriodIDEnd      = ATAssistant.GetPayrollPeriodIDEnd(dbEmp.ResignDate.Value, db.PayrollPeriods.ToList());
                    List <MonthData> monthDatas = db.MonthDatas.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.AbsentDays > 0).ToList();
                    if (monthDatas.Count() > 0)
                    {
                        vmLeaveBalance.Absents = (float)monthDatas.Sum(aa => aa.AbsentDays);
                    }
                }
                else
                {
                    vmLeaveBalance.OEmpID = dbEmp.OEmpID;
                }
                // vmLeaveBalance.OUName = dbEmp.OUName;
                vmLeaveBalance.LocationName       = dbEmp.LocationName;
                vmLeaveBalance.JobTitleName       = dbEmp.JobTitleName;
                vmLeaveBalance.EmploymentTypeName = dbEmp.EmploymentTypeName;
                vmLeaveBalance.LWOP = dbLeaveDatas.Where(aa => aa.EmpID == dbEmp.PEmployeeID && aa.HalfLeave == false).Count() + (dbLeaveDatas.Where(aa => aa.EmpID == dbEmp.PEmployeeID && aa.HalfLeave == true).Count() / 2);
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).Count() > 0) // AL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).First();
                    vmLeaveBalance.TotalAL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceAL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailAL   = vmLeaveBalance.TotalAL - vmLeaveBalance.BalanceAL;
                    if (dbEmp.Status == "Resigned")
                    {
                        // Check for if employee join in same financial year
                        float Divider     = 1;
                        float WorkingDays = 0;
                        if (dbEmp.DOJ.Value >= dbFinYear.FYStartDate)
                        {
                            Divider     = (dbFinYear.FYEndDate.Value - dbEmp.DOJ.Value).Days + 1;
                            WorkingDays = (dbEmp.ResignDate.Value - dbEmp.DOJ.Value).Days + 1;
                        }
                        else
                        {
                            Divider     = 365;
                            WorkingDays = (dbEmp.ResignDate.Value - dbFinYear.FYStartDate.Value).Days + 1;
                        }
                        float  ProRataLeave = (float)(vmLeaveBalance.TotalAL * WorkingDays) / Divider;
                        double decimalValue = Math.Round((double)ProRataLeave, 1);
                        vmLeaveBalance.ProrataAL = decimalValue;
                    }
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).Count() > 0) // ACCU
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 1).First();
                    vmLeaveBalance.TotalAccum   = dbLeaveQuotaYear.CFFromLastYear;
                    vmLeaveBalance.BalanceAccum = dbLeaveQuotaYear.CFRemaining;
                    vmLeaveBalance.AvailAccum   = vmLeaveBalance.TotalAccum - vmLeaveBalance.BalanceAccum;
                    vmLeaveBalance.ProrataAccum = vmLeaveBalance.BalanceAccum;
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 2).Count() > 0) // CL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 2).First();
                    vmLeaveBalance.TotalCL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceCL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailCL   = vmLeaveBalance.TotalCL - vmLeaveBalance.BalanceCL;
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 3).Count() > 0) //SL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 3).First();
                    vmLeaveBalance.TotalSL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceSL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailSL   = vmLeaveBalance.TotalSL - vmLeaveBalance.BalanceSL;
                }
                if (dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 4).Count() > 0) //CPL
                {
                    LeaveQuotaYear dbLeaveQuotaYear = dbLeaveQuotaYears.Where(aa => aa.EmployeeID == dbEmp.PEmployeeID && aa.LeaveTypeID == 4).First();
                    vmLeaveBalance.TotalCPL   = dbLeaveQuotaYear.YearlyTotal;
                    vmLeaveBalance.BalanceCPL = dbLeaveQuotaYear.YearlyRemaining;
                    vmLeaveBalance.AvailCPL   = vmLeaveBalance.TotalCPL - vmLeaveBalance.BalanceCPL;
                }
                vmLeaveBalanceList.Add(vmLeaveBalance);
            }



            return(vmLeaveBalanceList);
        }