예제 #1
0
        public static EmployeeSalaryViewModel GetById(int id)
        {
            EmployeeSalaryViewModel result = new EmployeeSalaryViewModel();

            using (var db = new PayrollContext())
            {
                result = (from e in db.EmployeeSalary
                          join p in db.PayrollPeriod on
                          e.PayrollPeriodId equals p.Id
                          join s in db.SalaryComponent on
                          e.SalaryComponentId equals s.Id
                          select new EmployeeSalaryViewModel
                {
                    Id = e.Id,
                    BadgeId = e.BadgeId,
                    PayrollPeriodId = e.PayrollPeriodId,
                    PeriodMonth = p.PeriodMonth,
                    PeriodYear = p.PeriodYear,
                    SalaryComponentId = e.SalaryComponentId,
                    SalaryComponentName = s.Description,
                    BasicValue = e.BasicValue,
                    FinalValue = e.FinalValue,
                    IsActivated = e.IsActivated
                }
                          ).FirstOrDefault();
            }
            return(result);
        }
예제 #2
0
        private async Task <EmployeeSalaryViewModel> CalculateEmployeeSalary(EmployeeSalaryViewModel employeeSalaryViewModel)
        {
            EmployeeSalaryViewModel evm = new EmployeeSalaryViewModel();

            evm.TotalNoOfHoursWorked = 0;
            evm.Salary = 0;
            DateTime monthStartDate    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            var      todaysDateandTime = DateTime.Now;
            var      currentDate       = todaysDateandTime.Date;

            //Selecting Employee matches accessCode
            var dtemployeeList = await this.employeeService.GetEmployeeDetailsByaccessCode(employeeSalaryViewModel.AccessCode);

            //Getting Data from EmployeeTask(SalaryData) by passing EmployeeId and startDate
            var empSalaryData = await this.employeeTaskService.GetEmpHourCapacityOfTheDate(dtemployeeList.EmployeeId, monthStartDate, currentDate);


            evm.FullName = dtemployeeList.FirstName + " " + dtemployeeList.Surname;

            evm.StartDate = monthStartDate;
            evm.EndDate   = currentDate;

            //Calculating the Employee Salary
            foreach (var item in empSalaryData)
            {
                evm.TotalNoOfHoursWorked += item.TotalNoOfHours;
                evm.Salary = (decimal)(evm.Salary + (item.TotalNoOfHours * item.PayPerTask));
            }

            return(evm);
        }
        public ActionResult Save(EmployeeSalaryViewModel obj)
        {
            // IEnumerable<EmployeeSalaryViewModel> en = customerDueFeesList;
            // en = jss.Deserialize<IEnumerable<EmployeeSalaryViewModel>>(obj.EmployeeSalaryViewModelList);
            List <EmployeeSalaryViewModel> employeeSalaryViewModelList;
            JavaScriptSerializer           jss = new JavaScriptSerializer();
            EmployeeSalary employeeSalary      = new EmployeeSalary();

            employeeSalaryViewModelList = jss.Deserialize <List <EmployeeSalaryViewModel> >(obj.SalaryList);
            foreach (var employeeSalaryViewModel in employeeSalaryViewModelList)
            {
                if (employeeSalaryViewModel.FullName == null)
                {
                    //for the last row of table
                }
                else
                {
                    employeeSalary.FullName            = employeeSalaryViewModel.FullName;
                    employeeSalary.WorkHours           = employeeSalaryViewModel.WorkHours;
                    employeeSalary.RatePerHour         = employeeSalaryViewModel.RatePerHour;
                    employeeSalary.OverTimeHours       = employeeSalaryViewModel.OverTimeHours;
                    employeeSalary.RatePerHourOvertime = employeeSalaryViewModel.RatePerHourOvertime;
                    employeeSalary.Date     = employeeSalaryViewModel.Date;
                    employeeSalary.SalaryId = employeeSalaryViewModel.SalaryId;
                    _dbContext.EmployeeSalaries.Add(employeeSalary);
                    _dbContext.SaveChanges();
                }
            }
            return(Json(new { success = true }));
        }
예제 #4
0
        public static EmployeeSalaryViewModel GetById(int id)
        {
            EmployeeSalaryViewModel result = new EmployeeSalaryViewModel();

            using (var db = new PayrollContext())
            {
                result = (from d in db.EmployeeSalary
                          join pp in db.PayrollPeriod on
                          d.PayrollPeriodId equals pp.Id
                          join sc in db.SalaryComponent on
                          d.SalaryComponentId equals sc.Id
                          where d.Id == id
                          select new EmployeeSalaryViewModel
                {
                    Id = d.Id,
                    BadgeId = d.BadgeId,
                    PayrollPeriodId = d.PayrollPeriodId,
                    SalaryComponentCode = sc.Code,
                    SalaryComponentName = sc.Description,
                    SalaryComponentId = d.SalaryComponentId,
                    BasicValue = d.BasicValue,
                    FinalValue = d.FinalValue,
                    IsActivated = d.IsActivated
                }).FirstOrDefault();
            }
            return(result);
        }
예제 #5
0
        public async Task <ActionResult> ViewTotalDuetoEmployee()
        {
            EmployeeSalaryViewModel employeeSalaryViewModel = new EmployeeSalaryViewModel();

            await GetAllEmployees(employeeSalaryViewModel);

            employeeSalaryViewModel.DispalyGrid = false;

            return(View(employeeSalaryViewModel));
        }
예제 #6
0
        public ActionResult RemoveComponent(string bId, int scId)
        {
            List <EmployeeSalaryViewModel> models = EmployeeSalaryRepo.GetByBadgeId(bId, scId);

            if (models.Count > 0)
            {
                EmployeeSalaryViewModel model = models[0];
                return(PartialView("_RemoveComponent", model));
            }
            return(PartialView("_RemoveComponent", new EmployeeSalaryViewModel()));
        }
예제 #7
0
        public ActionResult GetSalaryComponent(int jobPositionId, int salaryComponentId)
        {
            EmployeeSalaryViewModel     model = EmployeeSalaryRepo.GetByComponentId(salaryComponentId);
            SalaryDefaultValueViewModel sd    = SalaryDefaultValueRepo.GetByJobPosition(jobPositionId, salaryComponentId);

            if (sd != null)
            {
                model.BasicValue = sd.Value;
            }
            return(PartialView("_GetSalaryComponent", model));
        }
예제 #8
0
 public ActionResult Edit(EmployeeSalaryViewModel model)
 {
     if (ModelState.IsValid)
     {
         Responses responses = EmployeeSalaryRepo.Update(model);
         if (responses.Success)
         {
             return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { success = false, message = "Error msg" }, JsonRequestBehavior.AllowGet));
         }
     }
     return(Json(new { success = false, message = "Invalid" }, JsonRequestBehavior.AllowGet));
 }
 public ActionResult Create(EmployeeSalaryViewModel model)
 {
     if (ModelState.IsValid)
     {
         Responses responses = EmployeeSalaryRepo.Update(model);
         if (responses.Success)
         {
             return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { success = false, message = responses.Message }, JsonRequestBehavior.AllowGet));
         }
     }
     return(Json(new { success = false, message = ModelState.ToString() }, JsonRequestBehavior.AllowGet));
 }
예제 #10
0
        /// <summary>
        /// Calculates employee salary by month for the given employee to be used in statistics view
        /// </summary>
        /// <param name="username"></param>
        /// <returns><see cref="EmployeeSalaryViewModel"/></returns>
        public async Task <EmployeeSalaryViewModel> EmployeeSalary(string username)
        {
            var user = await _employeeRepository.GetEmployeeWithPaymentsAsync(username);

            var payments = user.Payments.Where(p => p.Year == DateTime.Now.Year).OrderBy(p => p.Month);

            EmployeeSalaryViewModel model = new EmployeeSalaryViewModel
            {
                TotalPay    = payments.Select(p => p.TotalPay).ToArray(),
                OvertimePay = payments.Select(p => p.OverTimePay).ToArray(),
                NormalPay   = payments.Select(p => p.NormalPay).ToArray(),
                MonthNames  = CultureInfo.CreateSpecificCulture("en-GB").DateTimeFormat.MonthNames
            };

            return(model);
        }
예제 #11
0
        public static Responses Update(EmployeeSalaryViewModel entity)
        {
            Responses result = new Responses();

            try
            {
                using (var db = new PayrollContext())
                {
                    if (entity.Id != 0)
                    {
                        EmployeeSalary employeesalary = db.EmployeeSalary.Where(o => o.Id == entity.Id).FirstOrDefault();
                        if (employeesalary != null)
                        {
                            employeesalary.BadgeId           = entity.BadgeId;
                            employeesalary.PayrollPeriodId   = entity.PayrollPeriodId;
                            employeesalary.SalaryComponentId = entity.SalaryComponentId;
                            employeesalary.BasicValue        = entity.BasicValue;
                            employeesalary.FinalValue        = entity.FinalValue;
                            employeesalary.IsActivated       = entity.IsActivated;
                            employeesalary.ModifyBy          = "Azam";
                            employeesalary.ModifyDate        = DateTime.Now;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        EmployeeSalary employeesalary = new EmployeeSalary();
                        employeesalary.BadgeId           = entity.BadgeId;
                        employeesalary.PayrollPeriodId   = entity.PayrollPeriodId;
                        employeesalary.SalaryComponentId = entity.SalaryComponentId;
                        employeesalary.BasicValue        = entity.BasicValue;
                        employeesalary.FinalValue        = entity.FinalValue;
                        employeesalary.IsActivated       = entity.IsActivated;
                        employeesalary.CreateBy          = "Azam";
                        employeesalary.CreateDate        = DateTime.Now;
                        db.EmployeeSalary.Add(employeesalary);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.Success = false;
            }
            return(result);
        }
예제 #12
0
        public async Task <ActionResult> GetEmployeeSalary(EmployeeSalaryViewModel employeeSalaryViewModel)
        {
            _logger.LogInformation("View total due over a specific timeframe");

            try
            {
                EmployeeSalaryViewModel evm = await CalculateEmployeeSalary(employeeSalaryViewModel);

                return(View(evm));
            }

            catch (Exception ex)
            {
                _logger.LogError("Error Getting Employee Salary {0}", ex.Message);
                return(View(ex.InnerException.Message));
            }
        }
예제 #13
0
        public static EmployeeSalaryViewModel GetByComponentId(int id)
        {
            EmployeeSalaryViewModel result = new EmployeeSalaryViewModel();

            using (var db = new PayrollContext())
            {
                result = (from sc in db.SalaryComponent
                          where sc.Id == id
                          select new EmployeeSalaryViewModel
                {
                    Id = sc.Id,
                    SalaryComponentId = sc.Id,
                    SalaryComponentCode = sc.Code,
                    SalaryComponentName = sc.Description
                }).FirstOrDefault();
            }
            return(result);
        }
예제 #14
0
        public async Task <ActionResult> ViewTotalDuetoEmployee(int EmployeeId, DateTime startDate, DateTime endDate)
        {
            _logger.LogInformation("View total due over a specific timeframe");
            EmployeeSalaryViewModel evm = new EmployeeSalaryViewModel();

            try
            {
                await GetTotalDue(EmployeeId, startDate, endDate, evm);

                return(View(evm));
            }

            catch (Exception ex)
            {
                _logger.LogError("Error Retrieving View total due of Employee {0}", ex.Message);
                return(View(ex.InnerException.Message));
            }
        }
예제 #15
0
 // PUT api/<controller>/5
 public Responses Put(int id, [FromBody] EmployeeSalaryViewModel entity)
 {
     entity.Id = id;
     return(EmployeeSalaryRepo.Update(entity));
 }
예제 #16
0
 // POST api/<controller>
 public Responses Post([FromBody] EmployeeSalaryViewModel entity)
 {
     return(EmployeeSalaryRepo.Update(entity));
 }
        public ActionResult Edit(Guid?id, DateTime?date)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var employeeAttendences = _dbContext.EmployeeAttendences.Where(a => a.Date == date).ToList();

            if (employeeAttendences == null)
            {
                return(HttpNotFound());
            }
            SalaryViewModel salaryViewModel = new SalaryViewModel();

            salaryViewModel.Date = date;
            decimal?grandTotalWorkHours     = 0;
            decimal?grandTotalOverTimeHours = 0;
            List <EmployeeSalaryViewModel> viewModelList = new List <EmployeeSalaryViewModel>();

            foreach (var attendence in employeeAttendences)
            {
                EmployeeSalaryViewModel empSalaryViewModel = new EmployeeSalaryViewModel();
                var workHours = attendence.WorkHours;
                empSalaryViewModel.WorkHours = workHours;
                var overTimeHours = attendence.OverTimeHours;
                empSalaryViewModel.OverTimeHours = overTimeHours;

                var empId    = attendence.EmployeeId;
                var employee = _dbContext.Contacts.Where(a => a.Id == empId).FirstOrDefault();
                var employeeSalaryDetails = _dbContext.EmployeeSalaryDetails.Where(a => a.ContactId == empId).FirstOrDefault();
                if (employeeSalaryDetails == null)
                {
                    empSalaryViewModel.RatePerHour         = null;
                    empSalaryViewModel.RatePerHourOvertime = null;
                    empSalaryViewModel.FullName            = employee.FullName;
                }
                else
                {
                    var ratePerHour = employeeSalaryDetails.RatePerHour;
                    empSalaryViewModel.RatePerHour = ratePerHour;
                    var totalWorkHour = ratePerHour * workHours;
                    empSalaryViewModel.WorkHourTotal = totalWorkHour;

                    var rateOverTime = employeeSalaryDetails.RatePerHourOvertime;
                    empSalaryViewModel.RatePerHourOvertime = rateOverTime;
                    var totalOverTime = overTimeHours * rateOverTime;
                    empSalaryViewModel.OverTimeTotal = totalOverTime;

                    grandTotalOverTimeHours = totalOverTime + grandTotalOverTimeHours;
                    grandTotalWorkHours     = totalWorkHour + grandTotalWorkHours;

                    empSalaryViewModel.FullName = employee.FullName;
                }
                salaryViewModel.GrandTotalWorkHours     = grandTotalWorkHours;
                salaryViewModel.GrandTotalOverTimeHours = grandTotalOverTimeHours;
                // empSalaryViewModel.RatePerHour =;
                viewModelList.Add(empSalaryViewModel);
                salaryViewModel.EmployeeSalaryViewModel = viewModelList;
            }

            return(View(salaryViewModel));
        }
예제 #18
0
        private async Task GetAllEmployees(EmployeeSalaryViewModel employeeSalaryViewModel)
        {
            var employeeList = await this.employeeService.GetEmployees();

            employeeSalaryViewModel.Employees = employeeList;
        }
예제 #19
0
        private async Task GetTotalDue(int EmployeeId, DateTime startDate, DateTime endDate, EmployeeSalaryViewModel evm)
        {
            evm.TotalNoOfHoursWorked = 0;
            evm.Salary = 0;

            var dtoEmpTask = await this.employeeTaskService.GetEmpHourCapacityOfTheDate(EmployeeId, startDate, endDate);

            var dtemployeeList = await this.employeeService.GetEmployeeById(dtoEmpTask.Select(x => x.EmployeeId).FirstOrDefault());

            evm.FullName    = dtemployeeList.FirstName + " " + dtemployeeList.Surname;
            evm.DispalyGrid = true;

            //Calculating the Employee Salary
            foreach (var item in dtoEmpTask)
            {
                evm.TotalNoOfHoursWorked += item.TotalNoOfHours;
                evm.Salary = (decimal)(evm.Salary + (item.TotalNoOfHours * item.PayPerTask));
            }
        }