public IActionResult MySalaries() { string username = User.Identity.Name; var positions = _context.Positions.ToList(); var userSalaries = _context.Salaries.Where(s => s.Worker.Email.Equals(username)).ToList(); int total = 0; var salaryViewModels = new List <SalaryViewModel>(); userSalaries.ForEach(salary => { SalaryViewModel viewModel = new SalaryViewModel(); viewModel.SalaryID = salary.SalaryID; viewModel.Bonus = salary.Bonus; total += salary.Bonus; var position = positions.Find(p => p.PositionID == salary.PositionID); viewModel.PositionName = position.Name; viewModel.PositionAmount = position.Amount; total += position.Amount; salaryViewModels.Add(viewModel); }); ViewData["UserName"] = username; ViewData["ViewModel"] = salaryViewModels; ViewData["Total"] = total; return(View("Views/Custom/MySalaries.cshtml")); }
public ResponseData AddByEntity(SalaryViewModel data) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { tb_Salary model = new tb_Salary(); model.SaID = data.SaID; model.SaLevel = data.SaLevel; model.SaStep = data.SaStep; model.SaRate = data.SaRate; model.CreateBy = UtilityService.User.UserID; model.CreateDate = DateTime.Now; model.ModifyBy = UtilityService.User.UserID; model.ModifyDate = DateTime.Now; db.tb_Salary.Add(model); db.SaveChanges(); } catch (Exception) { } return(result); } }
public ActionResult Manage(string SalaryDate) { try { ViewBag.SalaryDate = GetSalaryDateList(); var _salary = new SalaryViewModel(); var _idsList = new List <int>(); _salary.SalaryList = new List <SalaryInfo>(); _salary.SalaryDate = SalaryDate; using (PaySlipRepository Repo = new PaySlipRepository()) { _idsList = Repo.GetEmployeeIdsListIncludeSelectedDate(_salary.SalaryDate); } using (SalaryRepository Repo = new SalaryRepository()) { _salary.SalaryList = Repo.GetSalaryList(); } if (_idsList.Count() > 0) { _salary.SalaryList = _salary.SalaryList.Where(t => !_idsList.Contains((int)t.EmployeeInfoId)).ToList(); } return(View(_salary)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Salary", "Manage"))); } }
public ActionResult GetCalculoNomina(string fechaString, int idEmpleado) { DateTime fecha = DateTime.ParseExact(fechaString, "d-M-yyyy", CultureInfo.InvariantCulture); SalaryViewModel salModel = new SalaryViewModel(); StringBuilder sb = new StringBuilder(); var serviceNomina = GetService.nominaService; var lstSuedos = serviceNomina.GetSalarios(fecha, fecha.AddMonths(1), idEmpleado); foreach (var sueldo in lstSuedos) { salModel = new SalaryViewModel(); salModel.CopyPropertiesFrom(sueldo); sb.Append("<tr><td>" + salModel.Nombre + "</td><td>" + salModel.getDescripcionRol() + "</td><td>" + (salModel.interno ? "Si" : "No") + "</td><td>" + salModel.DiasLaborados + "</td><td>" + salModel.Entregas + "</td><td>" + salModel.Adicional + "</td><td>" + salModel.BonoXHora + "</td><td>" + salModel.Subtotal + "</td><td>" + "( " + salModel.PorcentajeIva + "%) " + salModel.MontoIva + "</td><td>" + salModel.MontoTotal + "</td><td>" + salModel.ValesDespensa + "</td><td>" + (salModel.MontoTotal + salModel.ValesDespensa).ToString("#.##") + "</ td ></ tr > "); } return(Content(sb.ToString())); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Salary salary = db.Salaries.Find(id); if (salary == null) { return(HttpNotFound()); } SalaryViewModel model = new SalaryViewModel { Id = salary.SerialId, EmployeeName = salary.Employee.FullName, IssueDate = DateTime.Now, BasicSalary = salary.BasicSalary, PerformanceBasedSalary = salary.PerformanceBasedSalary }; ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FullName"); return(View(model)); }
public static SalaryListViewModel GetSalaryByUser(string username) { Entities entities = new Entities(); var salaries = entities.Incomes.Where(x => x.Username.Equals(username) && x.IncomeType == (int)Constants.Constants.INCOME_TYPE.SALARY_INCOME && !x.DisabledDate.HasValue).OrderBy(x => x.Name).ToList(); SalaryListViewModel result = new SalaryListViewModel(); foreach (var salary in salaries) { SalaryViewModel viewModel = new SalaryViewModel { Id = salary.Id, Source = salary.Name, IncomeDay = salary.IncomeDay, Income = salary.Value, AnnualIncome = salary.Value * 12, Note = salary.Note }; result.Salaries.Add(viewModel); } result.TotalIncome = result.Salaries.Sum(x => x.Income.Value); result.TotalAnnualIncome = result.TotalIncome * 12; result.IsInitialized = UserQueries.IsCompleteInitialized(username); return(result); }
public ActionResult SalaryDetail(int?id) { SalaryViewModel model = new SalaryViewModel(); if (id.HasValue) { model = new SalaryRepository().GetByID((int)id); } return(PartialView("_Salary", model)); }
public JsonResult GetEmployeeSalary(SalaryViewModel obj) { try { var salaries = unitOfWork.SalaryRepository.Get(null, x => x.OrderBy(id => id.EmployeeNo)); var employee = unitOfWork.EmployeeDetailsRepository.Get(null, x => x.OrderBy(id => id.EmployeeNo)); var result = from emp in employee join sal in salaries on emp.EmployeeNo equals sal.EmployeeNo into eGroup where (obj.EmployeeName is null || emp.EmployeeName.ToLower() == obj.EmployeeName) from sal in eGroup.DefaultIfEmpty() select new { employeeNo = sal.EmployeeNo, employeeName = emp.EmployeeName, joiningDate = emp.JoiningDate, bankAccountNumber = emp.BankAccountNumber, overtimeOrExtraduty = sal.OvertimeOrExtraDuties, transpotationAllowance = sal.TranspotationAllowance, otherAllowance = sal.OtherAllowance, telephoneAllowance = sal.TelephoneAllowance, foodAllowance = sal.FoodAllowance, taxiCharges = sal.TaxiCharges, roomRent = sal.RoomRent, serviceBenefits = sal.ServiceBenefits, grossSalary = sal.GrossSalary, socialInsurance = sal.SocialInsurance, leaveDeduction = sal.LeaveDeduction, advanceDeduction = sal.AdvanceDeduction, otherDeduction = sal.OtherAllowance, totalDeduction = sal.TotalDeduction, netSalary = sal.NetSalary, remarks = sal.Remarks, basic = sal.Basic, totalSalaryPayment = sal.TotalSalaryPayment, modeOfPayment = sal.ModeOfPayment, salaryApprovalStatusId = sal.SalaryApprovalStatusId, nextActionId = sal.NextActionId, approvedBy = sal.ApprovedBy, checkedBy = sal.CheckedBy, preparedBy = sal.PreparedBy, createdDate = sal.CreatedDate, createdBy = sal.CreatedBy, modifiedBy = sal.ModifiedBy, modifiedDate = sal.ModifiedDate }; return(Json(result)); } catch (Exception ex) { _logger.LogError(ex.ToString()); return(null); } }
public ActionResult Edit(SalaryViewModel salary) { if (ModelState.IsValid) { var entity = Mapper.Map <Salary>(salary); salaryService.Update(entity); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(employeeService.GetAll(), "Id", "FirstName", salary.EmployeeId); return(View(salary)); }
public IActionResult Index() { var loginId = User.Identity.Name; // get information user var employee = dbContext.Employees.Find(m => m.Id.Equals(loginId)).FirstOrDefault(); var viewModel = new SalaryViewModel { Employee = employee }; return(View(viewModel)); }
public ActionResult Delete(int?id, SalaryViewModel obj) { try { var v = db.Salaries.Where(a => a.SalaryId == id).First(); db.Entry(v).State = EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public ActionResult Index() { var viewModel = new SalaryViewModel(); viewModel.SalaryModels = DbContext.SalaryModels.ToList(); ViewData["Message"] = DbContext.SalaryModels.ToList(); var LD = DbContext.SalaryModels.Include(c => c.PersonModel).ToList(); return(View(LD)); }
public ActionResult Edit(int?id, SalaryViewModel obj) { try { db.Salaries.Find(id).Scale = obj.Scale; db.Salaries.Find(id).SalaryAmount = obj.SalaryAmount; db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Salaries/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SalaryViewModel salary = Mapper.Map <SalaryViewModel>(salaryService.Get(id.Value)); if (salary == null) { return(HttpNotFound()); } return(View(salary)); }
// GET: Salaries/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SalaryViewModel salary = Mapper.Map <SalaryViewModel>(salaryService.Get(id.Value)); if (salary == null) { return(HttpNotFound()); } ViewBag.EmployeeId = new SelectList(employeeService.GetAll(), "Id", "FirstName", salary.EmployeeId); return(View(salary)); }
public JsonResult SaveSalary(SalaryViewModel model) { ResponseData result = new Models.ResponseData(); if (model.SaID != 0) { result = new SalaryRepository().UpdateByEntity(model); } else { result = new SalaryRepository().AddByEntity(model); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(SalaryViewModel obj) { try { Salary s = new Salary(); s.Scale = obj.Scale; s.SalaryAmount = obj.SalaryAmount; db.Salaries.Add(s); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
// GET: Salaries/Edit/5 public ActionResult Edit(int?id) { SalaryViewModel obj = new SalaryViewModel(); Salary s = db.Salaries.Find(id); if (s == null) { return(HttpNotFound()); } else { obj.SalaryId = s.SalaryId; obj.Scale = s.Scale; obj.SalaryAmount = s.SalaryAmount; } return(View(obj)); }
public static List <SalaryViewModel> MapToSalaryViewModelList(this IList <Salary> Salaries) { List <SalaryViewModel> SalariesVM = new List <SalaryViewModel>(); if (Salaries != null && Salaries.Count > 0) { foreach (Salary salary in Salaries) { SalaryViewModel salaryViewModel = salary.MapToViewModel(); if (salaryViewModel != null) { SalariesVM.Add(salaryViewModel); } } } return(SalariesVM); }
public ActionResult Edit(int id, SalaryViewModel model) { if (ModelState.IsValid) { Salary salary = db.Salaries.Find(id); if (salary == null) { return(HttpNotFound()); } salary.BasicSalary = model.BasicSalary; salary.PerformanceBasedSalary = model.PerformanceBasedSalary; db.Entry(salary).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FullName"); return(View(model)); }
public static Salary MapToModel(this SalaryViewModel SalaryVM) { Salary salary = null; if (SalaryVM != null) { salary = new Salary { Amount = SalaryVM.Amount, Comments = SalaryVM.Comments, Description = SalaryVM.Description, Id = SalaryVM.SalaryId, MonthlyBudgetId = SalaryVM.MonthlyBudgetId, PaymentDate = SalaryVM.PaymentDate, CreationDate = SalaryVM.CreationDate, LastModifited = SalaryVM.LastModified }; } return(salary); }
// GET: Salaries public ActionResult Index() { try { List <Salary> list = db.Salaries.ToList(); List <SalaryViewModel> viewList = new List <SalaryViewModel>(); foreach (Salary s in list) { SalaryViewModel obj = new SalaryViewModel(); obj.SalaryId = s.SalaryId; obj.Scale = s.Scale; obj.SalaryAmount = s.SalaryAmount; viewList.Add(obj); } return(View(viewList)); } catch (Exception ex) { throw ex; } }
public static SalaryViewModel MapToViewModel(this Salary Salary) { SalaryViewModel SalaryVM = null; if (Salary != null) { SalaryVM = new SalaryViewModel { Amount = Salary.Amount, Comments = Salary.Comments, Description = Salary.Description, MonthlyBudgetId = Salary.MonthlyBudgetId, PaymentDate = Salary.PaymentDate, SalaryId = Salary.Id, CreationDate = Salary.CreationDate, LastModified = Salary.LastModifited }; } return(SalaryVM); }
public async Task <IActionResult> Calculate(SalaryViewModel salaryVM) { List <Salary> salary = new List <Salary>(); foreach (var item in salaryVM.SelectedWorkers) { if (item.IsChecked == true) { salary.Add(new Salary() { EmployeeId = item.EmployeeId, TotalSalary = item.TotalSalary, CalculatedDate = item.OldCalculate }); } } _context.Salaries.AddRange(salary); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(SalaryForWorker))); }
public ResponseData UpdateByEntity(SalaryViewModel newdata) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { var data = db.tb_Salary.Single(x => x.SaID == newdata.SaID); data.SaLevel = newdata.SaLevel; data.SaStep = newdata.SaStep; data.SaRate = newdata.SaRate; data.ModifyBy = UtilityService.User.UserID; data.ModifyDate = DateTime.Now; db.SaveChanges(); } catch (Exception) { } return(result); } }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Salary salary = db.Salaries.Find(id); if (salary == null) { return(HttpNotFound()); } var model = new SalaryViewModel { Id = salary.SerialId, EmployeeName = salary.Employee.FullName, IssueDate = salary.IssueDate, BasicSalary = salary.BasicSalary, PerformanceBasedSalary = salary.PerformanceBasedSalary }; return(View(model)); }
public JsonResult Save(SalaryViewModel model) { Response response; try { int status = 200; string message = string.Empty; using (var db = new KiaGalleryContext()) { int userId = GetAuthenticatedUserId(); if (model.id != null && model.id > 0) { var entity = db.Salary.Single(x => x.Id == model.id); entity.WorkHours = model.workHours; entity.Mission = model.mission; entity.Reward = model.reward; entity.Remuneration = model.remuneration; entity.Others = model.others; entity.LoanInstallment = model.loanInstallment; entity.Imprest = model.imprest; entity.CommodityItem = model.commodityItem; entity.Imprest = model.imprest; entity.Insurance = model.insurance; entity.ModifyUserId = userId; entity.ModifyDate = DateTime.Now; entity.Ip = Request.UserHostAddress; message = "پرسنل با موفقیت ویرایش شد."; } else { var entity = new Salary() { WorkHours = model.workHours, HourlyWageRate = model.hourlyWageRate, OvertimeRate = model.overtimeRate, Mission = model.mission, Reward = model.reward, Remuneration = model.remuneration, Others = model.others, LoanInstallment = model.loanInstallment, Imprest = model.imprest, CommodityItem = model.commodityItem, Insurance = model.insurance, MonthCalculated = model.monthCalculatedDate, CreateUserId = userId, ModifyUserId = userId, CreateDate = DateTime.Now, ModifyDate = DateTime.Now, Ip = Request.UserHostAddress }; db.Salary.Add(entity); message = "پرسنل با موفقیت ایجاد شد."; } db.SaveChanges(); } response = new Response() { status = status, message = message }; } catch (Exception ex) { response = Core.GetExceptionResponse(ex); } return(Json(response, JsonRequestBehavior.AllowGet)); }
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)); }
public void Update(SalaryViewModel salaryToUpdate) { }
public IActionResult LoadSalary(int skip) { var workers = _context.Users.ToList(); string k = ""; var month = DateTime.Now.Month; var year = DateTime.Now.Year; int daysInMonth = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); int currentDay = DateTime.Now.Day; var empId = _context.Salaries.Where(x => x.CalculatedDate.Year == year && x.CalculatedDate.Month == month).ToList(); foreach (var item in empId) { k += ("//" + item.EmployeeId + "//"); } SalaryViewModel salaryModel = new SalaryViewModel(); salaryModel.SelectedWorkers = workers.Where(x => !k.Contains("/" + x.EmployeeId + "/")).Select(x => new SelectedWorker { Department = _context.Positions.Where(y => y.ID == x.PositionId).Select(y => y.Department.Name).FirstOrDefault(), ID = x.Id, Name = _context.Employees.Where(y => y.Worker.Id == x.Id).Select(y => y.Name).FirstOrDefault(), IDCardNumber = _context.Employees.Where(y => y.Worker.Id == x.Id) .Select(y => y.PersonalityCardNumber).FirstOrDefault(), Surname = _context.Employees.Where(y => y.Worker.Id == x.Id).Select(y => y.Surname).FirstOrDefault(), Position = _context.Positions.Where(y => y.ID == x.PositionId).Select(y => y.Name).FirstOrDefault(), IsChecked = false, EmployeeId = x.EmployeeId, OldCalculate = Convert.ToDateTime(DateTime.Now.ToShortDateString()), Bonus = _context.WorkerBonus.Where(y => y.WorkerId == x.Id && y.BonusDate.Year == year && y.BonusDate.Month == month).Sum(y => y.BonusSalary) + _context.CompanyWorkPlaceBonus.Include(m => m.CompanyWorkPlace) .Where(y => y.CompanyWorkPlace.EmployeeId == x.EmployeeId && y.CompanyWorkPlace.ChangedDate.Year == year && y.CompanyWorkPlace.ChangedDate.Month == month).Select(y => y.BonusSalary).FirstOrDefault(), MonthlySalary = _context.Positions.Where(y => y.ID == x.PositionId).Select(y => y.Salary).FirstOrDefault() / daysInMonth * currentDay, ExcusableAbsens = _context.WorkerAbsens.Where(y => y.AbsenceId == 1 && y.WorkerId == x.Id && y.Date.Year == year && y.Date.Month == month).Count() + _context.CompanyWorkPlaceAbsences.Where(y => y.CompanyWorkPlace.EmployeeId == x.EmployeeId && y.CompanyWorkPlace.ChangedDate.Year == year && y.CompanyWorkPlace.ChangedDate.Month == month) .Select(y => y.ExcusableAbsens).FirstOrDefault(), UnExcusableAbsens = _context.WorkerAbsens.Where(y => y.AbsenceId == 2 && y.WorkerId == x.Id && y.Date.Year == year && y.Date.Month == month).Count() + _context.CompanyWorkPlaceAbsences.Where(y => y.CompanyWorkPlace.EmployeeId == x.EmployeeId && y.CompanyWorkPlace.ChangedDate.Year == year && y.CompanyWorkPlace.ChangedDate.Month == month) .Select(y => y.UnExcusableAbsens).FirstOrDefault(), AbsensCount = _context.WorkerAbsens.Where(y => y.AbsenceId == 1 && y.WorkerId == x.Id).Count() + _context.CompanyWorkPlaceAbsences.Where(y => y.CompanyWorkPlace.EmployeeId == x.EmployeeId) .Select(y => y.ExcusableAbsens).FirstOrDefault() + _context.WorkerAbsens.Where(y => y.AbsenceId == 2 && y.WorkerId == x.Id).Count() + _context.CompanyWorkPlaceAbsences.Where(y => y.CompanyWorkPlace.EmployeeId == x.EmployeeId) .Select(y => y.UnExcusableAbsens).FirstOrDefault(), TotalSalary = (_context.Positions.Where(y => y.ID == x.PositionId).Select(y => y.Salary).FirstOrDefault() / daysInMonth * currentDay - _context.Positions.Where(y => y.ID == x.PositionId).Select(y => y.Salary).FirstOrDefault() / daysInMonth * _context.WorkerAbsens.Where(y => y.AbsenceId == 2 && y.WorkerId == x.Id && y.Date.Year == year && y.Date.Month == month).Count() + _context.CompanyWorkPlaceAbsences.Where(y => y.CompanyWorkPlace.EmployeeId == x.EmployeeId && y.CompanyWorkPlace.ChangedDate.Year == year && y.CompanyWorkPlace.ChangedDate.Month == month) .Select(y => y.UnExcusableAbsens).FirstOrDefault()) + _context.WorkerBonus.Where(y => y.WorkerId == x.Id && y.BonusDate.Year == year && y.BonusDate.Month == month).Sum(y => y.BonusSalary) + _context.CompanyWorkPlaceBonus.Include(m => m.CompanyWorkPlace) .Where(y => y.CompanyWorkPlace.EmployeeId == x.EmployeeId && y.CompanyWorkPlace.ChangedDate.Year == year && y.CompanyWorkPlace.ChangedDate.Month == month).Select(y => y.BonusSalary).FirstOrDefault() }).Skip(skip).Take(2).ToList(); return(View(salaryModel)); }