コード例 #1
0
        public IActionResult Create()
        {
            ViewBag.employees = _employeeService.GetAllEmployeesForPayroll();
            ViewBag.taxYears  = _payComputationService.GetAllTaxYear();
            var model = new PaymetRecordCreateViewModel();

            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> Create(PaymetRecordCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var payrecord = new PaymentRecord()
                {
                    ID                  = model.ID,
                    EmployeeID          = model.EmployeeID,
                    FullName            = _employeeService.GetByID(model.EmployeeID).FullName,
                    NiNo                = _employeeService.GetByID(model.EmployeeID).NationalInsurenceNo,
                    PayDate             = model.PayDate,
                    PayMonth            = model.PayMonth,
                    TaxYearID           = model.TaxYearID,
                    TaxCode             = model.TaxCode,
                    HourlyRate          = model.HourlyRate,
                    HoursWorked         = model.HoursWorked,
                    ContractualHours    = model.ContractualHours,
                    OvertimeHours       = overtimeHrs = _payComputationService.OvertimeHours(model.HoursWorked, model.ContractualHours),
                    ContractualEarnings = contractualEarnings = _payComputationService.ContractualEarnings(model.ContractualEarnings, model.HoursWorked, model.HourlyRate),
                    OvertimeEarnings    = overtimeEarnings = _payComputationService.OvertimeEarnings(_payComputationService.OvertimeRate(model.HourlyRate), overtimeHrs),
                    TotalEarnings       = totalEarnings = _payComputationService.TotalEarnings(overtimeEarnings, contractualEarnings),
                    Tax                 = tax = _taxService.TaxAmount(totalEarnings),
                    UnionFee            = unionFee = _employeeService.UnionFees(model.EmployeeID),
                    SLC                 = studentLoan = _employeeService.StudentLoanRepaymentAmount(model.EmployeeID, totalEarnings),
                    NIC                 = nationalInsurance = _nationalInsuranceContributionService.NIContribution(totalEarnings),
                    TotalDeduction      = totalDeduction = _payComputationService.TotalDeduction(tax, nationalInsurance, studentLoan, unionFee),
                    NetPayment          = _payComputationService.NetPay(totalEarnings, totalDeduction)
                };
                await _payComputationService.CreateAsync(payrecord);

                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.employee = _employeeService.GetAllEmployeesForPayroll();
            ViewBag.taxYears = _payComputationService.GetAllTaxYear();
            return(View());
        }