Example #1
0
 public void ChangePaymentFrequency(Employee employee, Models.HumanResources.PaymentFrequency paymentFrequency)
 {
     using (var context = new CERPContext())
     {
         var payHistory = new Models.HumanResources.EmployeePayHistory
         {
             EmployeeID = employee.EmployeeID,
         };
     }
 }
Example #2
0
 public Payroll CreateNew(string periodName, DateTime startDate, DateTime endDate, Models.HumanResources.PaymentFrequency paymentFrequency)
 {
     using (var context = new CERPContext())
     {
         var payFrequency = (byte)paymentFrequency;
         var payment      = context.WagePayments.ToList().Any(m => (m.StartDate.Date == startDate.Date && m.EndDate.Date == endDate.Date) || (m.StartDate.Date == startDate.Date && m.PayFrequency == payFrequency) || (m.EndDate.Date == endDate.Date && m.PayFrequency == payFrequency));
         if (payment)
         {
             throw new ArgumentException("A payment with the supplied parameters already exists");
         }
         var payroll = new Payroll
         {
             Period           = periodName,
             StartDate        = startDate.Date,
             EndDate          = endDate.Date,
             PaymentFrequency = paymentFrequency
         };
         var employees = context.ExtendedEmployees.Where(e => e.PayFrequency == payFrequency && e.IsCurrent).ToList();
         payroll.PayrollDetails = employees.Select(e => new PayrollDetail
         {
             Employee    = _employeeService.GetEmployee(e.EmployeeID),
             GrossSalary = e.Rate,
             IncomeTax   = CalculateIncomeTax(e.Rate),
             Pension     = CalculatePension(e.Rate)
         }).ToList();
         return(payroll);
     }
 }