Esempio n. 1
0
        /// <summary>
        /// Generate Monthly PayRoll
        /// </summary>
        /// <param name="generate">Flag to generate</param>
        /// <param name="year">Year</param>
        /// <param name="month">Month</param>
        /// <returns></returns>
        public ActionResult GenerateMonthlyPayRoll(bool generate = false, int year = 0, int month = 0, int action = -1)
        {
            EmployeesController employees = new EmployeesController();

            List <MEmployees> listEmployees = null;

            List <MPayRoll> listPayRolls = null;

            ViewBag.Year  = year;
            ViewBag.Month = month;

            if (generate)
            {
                //Get days by month
                DateTime dateFirst = new DateTime(year, month, 1);
                DateTime dateLast  = new DateTime(year, month + 1, 1).AddDays(-1);

                //Get employee
                employees     = new EmployeesController();
                listEmployees = employees.Get().Where(item => item.Active == true).ToList();

                //Generates Payroll
                string            msgResult         = string.Empty;
                PayRollController payRollController = new PayRollController();
                foreach (MEmployees employee in listEmployees)
                {
                    if (
                        payRollController.Get().Where
                        (
                            item => item.PayRollInfoID == employee.PayRollInfo_.PayRollInfoID &&
                            ((DateTime)item.PayRollDate).Year == year &&
                            ((DateTime)item.PayRollDate).Month == month
                        ).Count() == 0)
                    {
                        //Payroll
                        payRollController.Post(dateFirst, dateLast, dateLast, employee.PayRollInfo_.PayRollInfoID);
                        msgResult += string.Format("- <span style='color: rgba(0, 0, 0, 0.55); font-weight: 600;'>Employee [ {0} {1} ] - PayRoll generated successfully</span> <br>", employee.Name, employee.LastNames);
                    }
                    else
                    {
                        msgResult += string.Format("- <span style='color: rgba(0, 0, 0, 0.55); font-weight: 600;'>Employee [ {0} {1} ] - PayRoll was already generated</span> <br>", employee.Name, employee.LastNames);
                    }
                }

                return(Json(msgResult, JsonRequestBehavior.AllowGet));
            }
            else
            {
                listPayRolls = new PayRollController().Get().Where(item => ((DateTime)item.PayRollDate).Year == year && ((DateTime)item.PayRollDate).Month == month && ((bool)item.Employee.Active) == true).ToList();

                return(View(listPayRolls));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Check PayRoll Tickets
        /// </summary>
        /// <param name="generate">Flag to generate</param>
        /// <param name="year">Year</param>
        /// <param name="month">Month</param>
        /// <returns></returns>
        public ActionResult CheckPayRollTickets(int employeeID = 0)
        {
            List <MPayRoll> listPayRolls = null;

            ViewBag.EmployeeSelected = employeeID;

            listPayRolls = new PayRollController().Get().Where(item => ((bool)item.GetEmployee(Guid.Parse(this.Token)).Active) == true).OrderByDescending(item => item.PayRollDate).ToList();

            if (employeeID != 0)
            {
                listPayRolls = new PayRollController().Get().Where(item => item.GetEmployee(Guid.Parse(this.Token)).EmployeeID == employeeID).OrderByDescending(item => item.PayRollDate).ToList();
            }

            return(View(listPayRolls));
        }