public IActionResult Create() { ViewBag.employees = _employeeService.GetAllEmployeesForPayController(); ViewBag.allTaxYears = _paymentRecordService.GetAllTaxYear(); var model = new PaymentRecordCreateViewmodel(); return(View(model)); }
public async Task <IActionResult> Create(PaymentRecordCreateViewmodel model) { if (ModelState.IsValid) { var payroll = new PaymentRecord() { Id = model.Id, EmployeeId = model.EmployeeId, FullName = _employeeService.GetById(model.EmployeeId).FullName, PayDate = model.PayDate, PayMonth = model.PayMonth, TaxYearId = model.TaxYearId, TaxCode = model.TaxCode, HourlyRate = model.HourlyRate, HoursWorked = model.HoursWorked, ContractualHours = model.ContractualHours, OverTimeHours = overtimeHrs = _paymentRecordService.OvertimeHours(model.HoursWorked, model.ContractualHours), ContractualEarning = contractualEarnings = _paymentRecordService.ContractualEarnings(model.ContractualHours, model.HourlyRate, model.HoursWorked), OverTimeEarning = overTimeEarnings = _paymentRecordService.OvertimeEarnings(_paymentRecordService.OvertimeRate(model.HourlyRate), overtimeHrs), TotalEarnings = totalEarnings = _paymentRecordService.TotalEarnings(overTimeEarnings, contractualEarnings), Tax = tax = _taxService.TaxAmount(totalEarnings), UnionFee = unionFee = _employeeService.UnionFee(model.EmployeeId), SLC = studentLoan = _employeeService.StudentLoanRepaymentAmount(model.EmployeeId, totalEarnings), I_No = insurance = _insuranceService.Insurance(totalEarnings), TotalDeductions = totalDeductions = _paymentRecordService.TotalDeduction(tax, insurance, unionFee, studentLoan), NetPayment = _paymentRecordService.NetPay(totalEarnings, totalDeductions) }; await _paymentRecordService.CreateAsync(payroll); return(RedirectToAction(nameof(Index))); } var employees = _employeeService.GetAllEmployeesForPayController(); var allTaxYears = _paymentRecordService.GetAllTaxYear(); return(View()); }