Ejemplo n.º 1
0
        public async Task CreatePaycheck(Employee employee)
        {
            if (employee.LastPaycheckDate >= DateTime.Today)
            {
                return;
            }

            var grossAmount = employee.Salary / 26;

            var paycheck = new Paycheck()
            {
                Name        = $"{employee.FirstName} {employee.LastName}",
                EmployeeId  = employee.Id,
                GrossAmount = grossAmount,
                PayDate     = DateTime.Today
            };

            var deductions = await _deductionService.GetDeductions(employee.Id);

            await paycheck.AddDeductions(deductions);

            await _payrollRepository.CreatePaycheck(paycheck);

            employee.LastPaycheckDate = DateTime.Today;
            await _payrollRepository.UpdateEmployee(employee);
        }