private IActionResult BonusAndShopBonus(int monthDay, int day, CurrentWorkPlace data, ShopPromotion shopBonus, int attendence, WorkerPromotion bonus, decimal salaryForDay, decimal SalaryForRealDate) { var absentDaysSalary = attendence * salaryForDay; var shpBonus = shopBonus.Reward; var awardForWorker = bonus.Reward; var TotalSalary = SalaryForRealDate - absentDaysSalary + shpBonus + awardForWorker; PayrollViewModel payrollView = new PayrollViewModel() { WorkerId = data.WorkerId, Worker = data.Worker, PositionId = data.PositionId, Position = data.Position, WorkerPromotionId = bonus.Id, Bonus = bonus.Reward, ShopBonus = shpBonus, ShopPromotionId = shopBonus.Id, CountofAbsentDays = attendence, TotalSalary = TotalSalary }; if (day == monthDay) { ConfigurePayrollViewModel(payrollView); } return(View(payrollView)); }
private IActionResult BonusAndVacation(int monthDay, int day, CurrentWorkPlace data, int attendence, WorkerPromotion bonus, Vacation holiday, decimal salaryForDay, decimal SalaryForRealDate) { decimal absentDaysSalary = attendence * salaryForDay; decimal awardForWorker = bonus.Reward; TimeSpan tetilihesabla = (holiday.VacationEnded - holiday.VacationStarted); int tetilBonus = tetilihesabla.Days / 2; decimal tetilTotal = (tetilBonus * salaryForDay); decimal TotalSalary = SalaryForRealDate - absentDaysSalary + tetilBonus + awardForWorker; PayrollViewModel payrollView = new PayrollViewModel() { WorkerId = data.WorkerId, Worker = data.Worker, PositionId = data.PositionId, Position = data.Position, VacationBonus = tetilTotal, CountofAbsentDays = attendence, WorkerPromotionId = bonus.Id, Bonus = bonus.Reward, TotalSalary = TotalSalary }; if (day == monthDay) { ConfigurePayrollViewModel(payrollView); } return(View(payrollView)); }
public void AddNewPayroll(int employeeId, decimal philhealth, decimal sss, decimal pagibig, decimal grosspay) { decimal netPayComputation = grosspay - (philhealth + sss + pagibig); try { using (var uow = new UnitOfWork.UnitOfWork()) { var viewmodel = new PayrollViewModel() { EmployeeId = employeeId, GrossPay = grosspay, PagIbig = pagibig, SSS = sss, PhilHealth = philhealth, NetPay = netPayComputation }; uow.Payroll.AddNewPayroll(viewmodel); uow.SaveChanges(); } } catch (FieldAccessException ex) { } catch (EncoderFallbackException ex) { //todo: add logger here... } catch (Exception ex) { //todo: add logger here... } }
private IActionResult VacationAndShopBonus(int monthDay, int day, CurrentWorkPlace data, ShopPromotion shopBonus, int attendence, Vacation holiday, decimal salaryForDay, decimal SalaryForRealDate) { var absentDaysSalary = attendence * salaryForDay; var shpBonus = shopBonus.Reward; var tetilihesabla = (holiday.VacationEnded - holiday.VacationStarted); var tetilBonus = tetilihesabla.Days / 2; var tetilTotal = (tetilBonus * salaryForDay); var TotalSalary = SalaryForRealDate - absentDaysSalary + shpBonus + tetilTotal; PayrollViewModel payrollView = new PayrollViewModel() { WorkerId = data.WorkerId, Worker = data.Worker, PositionId = data.PositionId, Position = data.Position, CountofAbsentDays = attendence, ShopBonus = shpBonus, ShopPromotionId = shopBonus.Id, VacationBonus = tetilTotal, TotalSalary = TotalSalary }; if (day == monthDay) { ConfigurePayrollViewModel(payrollView); } return(View(payrollView)); }
public ActionResult ViewPayroll(PayrollViewModel viewModel) { var pc = new PayrollCalculator(db); var stubs = pc.GetPayroll(viewModel.StartDate, viewModel.NumberOfWeeks); return(View(stubs)); }
public ActionResult Index([Bind(Include = "StartDate, NumberOfWeeks")] PayrollViewModel viewModel) { if (ModelState.IsValid) { return(RedirectToAction("ViewPayroll", viewModel)); } return(View()); }
public async Task <IActionResult> Payroll(PayrollViewModel model) { if (!ModelState.IsValid) { return(View(await PayrollViewModel.ReBuildAsync(model, this.PayrollService))); } return(View(await PayrollViewModel.CreateAsync(model.From, model.To, model.EmployeeId, this.PayrollService, this.Mapper))); }
public async Task <IActionResult> Payroll(string errorMessage, DateTime from, DateTime to, string employeeId) { if (errorMessage != null) { ModelState.AddModelError(string.Empty, errorMessage); return(View(await PayrollViewModel.CreateAsync(from, to, employeeId, this.PayrollService, this.Mapper))); } return(View(await PayrollViewModel.CreateAsync(this.PayrollService))); }
// GET: Payroll public ActionResult Index(PayrollViewModel model) { model.PaySlips = model.PaySlips ?? new PaySlip(); model.Compensations = model.Compensations ?? new List <PayrollCompensationViewModel>(); model.Deductions = model.Deductions ?? new List <PayrollDeductionViewModel>(); model.DeMinimis = model.DeMinimis ?? new List <PayrollDeMinimisViewModel>(); SetDropdowns(); return(View(model)); }
// GET: Payroll public ActionResult Index(string date = "") { var viewModel = new PayrollViewModel(); var payrolls = new List <PayrollDao>(); var payrollDates = _payrollService.GetPayrollDates(6).Select(x => new SelectListItem { Text = x.FormattedDate, Value = x.SerializedDate }); viewModel.PayrollDates = payrollDates; if (!String.IsNullOrEmpty(date)) { var dates = date.Split('-'); var payrollStartDate = dates[0].DeserializeDate(); var payrollEndDate = dates[1].DeserializeDate(); ViewBag.StartDate = payrollStartDate; ViewBag.EndDate = payrollEndDate; GeneratePayroll(payrollStartDate, payrollEndDate); //populate the viewmodel here from service data //sort it in the service by surname var employeePayrollList = _employeePayrollService.GetByDateRange (payrollStartDate, payrollEndDate); foreach (EmployeePayrollPerCompany payroll in employeePayrollList) { var payrollDto = new PayrollDao { PayrollId = payroll.EmployeePayrollPerCompanyId, FirstName = payroll.Employee.FirstName, LastName = payroll.Employee.LastName, MiddleName = payroll.Employee.MiddleName, TotalDeduction = payroll.TotalDeduction, TotalGross = payroll.TotalGross, TotalNet = payroll.TotalNet, Company = payroll.Company }; payrolls.Add(payrollDto); } viewModel.Date = date; } var pagination = _webService.GetPaginationModel(Request, payrolls.Count); viewModel.Payrolls = _webService.TakePaginationModel(payrolls, pagination); viewModel.Pagination = pagination; return(View(viewModel)); }
// GET: Payroll public ActionResult Index() { var model = new PayrollViewModel() { PaySlips = new PaySlip(), Compensations = new List <PayrollCompensationViewModel>(), Deductions = new List <PayrollDeductionViewModel>() }; return(View(model)); }
public void AddNewPayroll(PayrollViewModel model) { var employee = Employees.FirstOrDefault(x => x.EmployeeId == model.EmployeeId); var payroll = new Payroll() { Employee = employee, GrossPay = model.GrossPay, NetPay = model.NetPay, SSS = model.SSS, Pagibig = model.PagIbig, Philhealth = model.PhilHealth }; _table.Add(payroll); }
// GET: Payroll/Edit/5 public ActionResult Edit(int id) { using (var db = new nominaDBContext()) { var viewModel = new PayrollViewModel() { Payroll = new Payroll(), employeeList = db.Employee.Include(e => e.Payroll).Where(e => e.Payroll.Count() == 0 && e.Active).ToList() }; return(View(viewModel)); } }
public async Task <PayrollViewModel> GetPayrollAsync(string language) { var data = new PayrollViewModel(); data.message = new messageModel(); try { var userId = JwtHelper.GetUserIdFromToken(HttpContext); if (String.IsNullOrEmpty(userId)) { throw new Exception("Unauthorized Access"); } using (var context = new StandardcanContext()) { var jsonData = JsonConvert.SerializeObject(new { emp_id = userId, lang = language }); SystemLog systemLog = new SystemLog() { module = "api/Payroll/GetPayroll", data_log = jsonData }; await _systemLogService.InsertSystemLogAsync(systemLog); SqlParameter emp_id = new SqlParameter("emp_id", userId ?? ""); SqlParameter lang = new SqlParameter("lang", language ?? ""); var spData = context.SpMbSalary.FromSqlRaw("sp_mb_salary @emp_id, @lang", emp_id, lang).ToList(); data.content = new List <PayrollContentViewModel>(); foreach (var item in spData) { PayrollContentViewModel payroll = new PayrollContentViewModel(); payroll.title1 = item.title1; payroll.title2 = item.title2; payroll.detail = item.detail; payroll.link_frame = item.link_frame; data.content.Add(payroll); } data.message.status = "1"; data.message.msg = "Success"; } } catch (Exception ex) { data.message.status = "2"; data.message.msg = ex.Message; } return(data); }
public IHttpActionResult Get([FromUri] PayrollRequestDataViewModel payrollRequest) { if (!ModelState.IsValid) { // TODO: add logs, add error info in responce message if required return(BadRequest("Request example: http://localhost:52039/api/payrollservice/SP?HoursWorked=20&HourlyRate=10&countrycode=SP")); } var payrollResult = _payrollService.GetCalculatedPayroll( payrollRequest.CountryCode, payrollRequest.HoursWorked, payrollRequest.HourlyRate); return(Ok(PayrollViewModel.Map(payrollResult))); }
public ActionResult Save(Payroll payroll) { if (!ModelState.IsValid) { using (var db = new nominaDBContext()) { var viewModel = new PayrollViewModel() { employeeList = db.Employee.Include(e => e.Payroll).Where(e => e.Payroll.Count() == 0 && e.Active).ToList(), Payroll = payroll }; return(View("Edit", viewModel)); } } using (var db = new nominaDBContext()) { var employeeInDb = db.Employee.Find(payroll.EmployeeId); var afp = Convert.ToDouble(employeeInDb.GrossSalary) * 0.0287; var ars = Convert.ToDouble(employeeInDb.GrossSalary) * 0.0304; var taxableSalary = employeeInDb.GrossSalary - Convert.ToDecimal((afp + ars)); var isr = calculateISR(Convert.ToDouble(taxableSalary)); var retentionTotal = afp + ars + isr; var newPayroll = new Payroll() { EmployeeId = payroll.EmployeeId, GrossSalary = employeeInDb.GrossSalary, RetentionAfp = afp, RetentionArs = ars, TaxableSalary = taxableSalary, RetentionIsr = isr, RetentionTotal = retentionTotal, NetIncome = employeeInDb.GrossSalary - Convert.ToDecimal(retentionTotal) }; db.Payroll.Add(newPayroll); db.SaveChanges(); } return(RedirectToAction("Index")); }
private void ConfigurePayrollViewModel(PayrollViewModel model) { var date = DateTime.Now.Date; Payroll payroll = new Payroll() { WorkerId = model.WorkerId, Worker = model.Worker, PositionId = model.PositionId, Position = model.Position, VacationBonus = model.VacationBonus, CountofAbsentDays = model.CountofAbsentDays, Bonus = model.Bonus, ShopBonus = model.ShopBonus, TotalSalary = model.TotalSalary, DateOfPaidSalaries = date }; _dbContext.Payrolls.Add(payroll); _dbContext.SaveChanges(); }
private IActionResult AbsentOnly(int monthDay, int day, CurrentWorkPlace data, int attendence, decimal salaryForDay, decimal SalaryForRealDate) { decimal absentDaysSalary = attendence * salaryForDay; //Bugunki Tarixe local tarixe gore hesablama //qaib ve bugunki tarixe gore hesablamag decimal TotalSalary = SalaryForRealDate - absentDaysSalary; PayrollViewModel payrollView = new PayrollViewModel() { WorkerId = data.WorkerId, Worker = data.Worker, PositionId = data.PositionId, Position = data.Position, CountofAbsentDays = attendence, TotalSalary = TotalSalary }; if (day == monthDay) { ConfigurePayrollViewModel(payrollView); } return(View(payrollView)); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var services = new ServiceCollection(); services.AddDbContext <IPSASDbContext>(); services.AddScoped <TeachersListViewModel>(); services.AddScoped <PayrollViewModel>(); services.AddScoped <PayslipViewModel>(); services.AddScoped <SettingsViewModel>(); services.AddScoped <TeachersList>(); services.AddScoped <Payroll>(); services.AddScoped <Views.Payslip>(); services.AddScoped <SettingsWindow>(); ServiceProvider = services.BuildServiceProvider(); PayrollViewModel = ServiceProvider.GetService <PayrollViewModel>(); var teachersListWindow = ServiceProvider.GetService <TeachersList>(); teachersListWindow.Show(); }
public ActionResult Calculate(PayrollViewModel model) { model.PaySlips = model.PaySlips; model.Compensations = model.Compensations ?? new List <PayrollCompensationViewModel>(); model.Deductions = model.Deductions ?? new List <PayrollDeductionViewModel>(); if (!(model.PaySlips.BasicSalary > 0) || !(model.PaySlips.ExpectedWorkedHours > 0) || !(model.PaySlips.TotalHoursWorked > 0)) { return(View("Index", model)); } if (!ModelState.IsValid) { if (model.PaySlips.BasicSalary != 0) { return(View("Details", model)); } else { return(View("Index", model)); } } var BasicPay = ComputeExpectedPay(model.PaySlips.BasicSalary, model.PaySlips.TotalHoursWorked, model.PaySlips.ExpectedWorkedHours); // Add Overtime if applicable var overtimePay = ComputeOvertimePay(model.PaySlips.OvertimeWorkedHours == null ? 0 : (int)model.PaySlips.OvertimeWorkedHours, model.PaySlips.OvertimeRatePerHour == null ? 0 : (decimal)model.PaySlips.OvertimeRatePerHour); List <PayrollCompensationViewModel> compensationsList = model.Compensations ?? new List <PayrollCompensationViewModel>(); if (!compensationsList.Any(m => m.Compensation == Compensations.OvertimePay) && overtimePay > 0) { compensationsList.Add(new PayrollCompensationViewModel() { Compensation = Compensations.OvertimePay, Value = overtimePay }); } // Add SSS if not already in list List <PayrollDeductionViewModel> deductionsList = model.Deductions ?? new List <PayrollDeductionViewModel>(); if (!deductionsList.Any(m => m.Deduction == Deductions.SSS)) { deductionsList.Add(new PayrollDeductionViewModel() { Deduction = Deductions.SSS, Value = ComputeSSS(BasicPay) }); } // Add PHIC if not already in list if (!deductionsList.Any(m => m.Deduction == Deductions.PHIC)) { deductionsList.Add(new PayrollDeductionViewModel() { Deduction = Deductions.PHIC, Value = ComputePHIC(BasicPay) }); } // Add PAGIBIG if not already in list if (!deductionsList.Any(m => m.Deduction == Deductions.PAGIBIG)) { deductionsList.Add(new PayrollDeductionViewModel() { Deduction = Deductions.PAGIBIG, Value = ComputePAGIBIG(BasicPay) }); } model.PaySlips.TotalDeductions = model.Deductions.Sum(m => m.Value); model.PaySlips.TotalCompensations = model.Compensations.Sum(m => m.Value) + BasicPay; model.PaySlips.TaxableIncome = ComputeTaxableIncome(BasicPay + overtimePay, model.Deductions.Select(m => m.Value).ToArray()); model.PaySlips.WithHoldingTax = ComputeTax(model.PaySlips.TaxableIncome); model.PaySlips.TakeHomePay = ComputeTakeHomePay(model.PaySlips.TotalCompensations, model.PaySlips.TotalDeductions, model.PaySlips.WithHoldingTax); return(View("Details", model));; }
public Payroll(PayrollViewModel payrollViewModel) { InitializeComponent(); DataContext = payrollViewModel; Init(); }
public ActionResult Calculate(PayrollViewModel model) { model.PaySlips = model.PaySlips; model.Compensations = model.Compensations ?? new List <PayrollCompensationViewModel>(); model.Deductions = model.Deductions ?? new List <PayrollDeductionViewModel>(); model.DeMinimis = model.DeMinimis ?? new List <PayrollDeMinimisViewModel>(); if (model.PaySlips == null) { return(View("Index", model)); } if (!ModelState.IsValid) { if (model.PaySlips.BasicSalary != 0 && model.PaySlips.EarnerType != null) { return(View("Index", model)); } } var BasicPay = ComputeExpectedPay(model.PaySlips.BasicSalary, model.PaySlips.TotalHoursWorked, model.PaySlips.ExpectedWorkedHours); List <PayrollCompensationViewModel> compensationsList = model.Compensations ?? new List <PayrollCompensationViewModel>(); List <PayrollDeductionViewModel> deductionsList = model.Deductions ?? new List <PayrollDeductionViewModel>(); // Default Values var SSS = ComputeSSS(BasicPay); var PHIC = ComputePHIC(BasicPay); var PAGIBIG = ComputePAGIBIG(BasicPay); var OTPAY = ComputeOvertimePay(model.PaySlips.OvertimeWorkedHours == null || model.PaySlips.OvertimeWorkedHours == 0 ? 0 : (int)model.PaySlips.OvertimeWorkedHours, model.PaySlips.OvertimeRatePerHour == null || model.PaySlips.OvertimeRatePerHour == 0 ? 0 : (decimal)model.PaySlips.OvertimeRatePerHour); // Add Overtime if applicable if (!compensationsList.Any(m => m.Compensation == CompensationType.OvertimePay) && OTPAY > 0) { var otpay_value = OTPAY > 0 ? 0 : compensationsList.Where(m => m.Compensation == CompensationType.OvertimePay).SingleOrDefault().Value; compensationsList.Add(new PayrollCompensationViewModel() { Compensation = CompensationType.OvertimePay, Value = otpay_value > 0 ? otpay_value : OTPAY }); } // Add SSS if not already in list if (!deductionsList.Any(m => m.Deduction == DeductionType.SSS)) { deductionsList.Add(new PayrollDeductionViewModel() { Deduction = DeductionType.SSS, Value = SSS }); } // Add PHIC if not already in list if (!deductionsList.Any(m => m.Deduction == DeductionType.PHIC)) { deductionsList.Add(new PayrollDeductionViewModel() { Deduction = DeductionType.PHIC, Value = PHIC }); } // Add PAGIBIG if not already in list if (!deductionsList.Any(m => m.Deduction == DeductionType.PAGIBIG)) { deductionsList.Add(new PayrollDeductionViewModel() { Deduction = DeductionType.PAGIBIG, Value = PAGIBIG }); } model.PaySlips.TotalDeductions = model.Deductions.Sum(m => m.Value); model.PaySlips.TotalDeMinimis = ComputeDeMinimis(model.DeMinimis, model.PaySlips, false); model.PaySlips.TotalDeminimisExcess = ComputeDeMinimis(model.DeMinimis, model.PaySlips, true); model.PaySlips.TotalCompensations = model.Compensations.Sum(m => m.Value) + BasicPay + model.PaySlips.TotalDeminimisExcess; model.PaySlips.TaxableIncome = ComputeTaxableIncome(BasicPay + OTPAY + model.PaySlips.TotalDeminimisExcess, model.Deductions.Select(m => m.Value).ToArray()); model.PaySlips.WithHoldingTax = ComputeTax(model.PaySlips.TaxableIncome); model.PaySlips.TakeHomePay = ComputeTakeHomePay(model.PaySlips.TotalCompensations + model.PaySlips.TotalDeMinimis, model.PaySlips.TotalDeductions, model.PaySlips.WithHoldingTax); SetDropdowns(); return(View("Index", model));; }
// POST api/<controller> public void Post(PayrollViewModel vm) { payroll.AddNewPayroll(vm.EmployeeId, vm.PhilHealth, vm.SSS, vm.PagIbig, vm.GrossPay); }