public DepartmentPayrollUpdateCommand(Employee employee, EmployeePayroll employeePayroll, DepartmentPayroll departmentPayroll)
        {
            Guard.Against.Null(employee, nameof(employee));
            Guard.Against.Null(employeePayroll, nameof(employeePayroll));
            Guard.Against.Null(departmentPayroll, nameof(departmentPayroll));

            EmployeePayroll   = employeePayroll;
            DepartmentPayroll = departmentPayroll;
            Employee          = employee;
        }
Exemplo n.º 2
0
        public DepartmentPayrollCreateCommand(Employee employee, Guid recordId, EmployeePayroll employeePayroll)
        {
            Guard.Against.Default(recordId, nameof(recordId));
            Guard.Against.Null(employee, nameof(employee));
            Guard.Against.Null(employeePayroll, nameof(employeePayroll));

            RecordId        = recordId;
            EmployeePayroll = employeePayroll;
            Employee        = employee;
        }
        public void GetPayrollNextStartDate3()
        {
            Initialize();
            DeleteInfo();

            //Test Data
            var employee = new Employee
            {
                EmployeeCode = "11001",
                FirstName    = "Jona",
                LastName     = "Pereira",
                MiddleName   = "Aprecio",
                BirthDate    = DateTime.Parse("02/02/1991"),
                Gender       = 1,
                IsActive     = true
            };

            var employeePayroll = new EmployeePayroll()
            {
                CutOffEndDate        = DateTime.Parse("05/17/2016"),
                CutOffStartDate      = DateTime.Parse("05/11/2016"),
                PayrollDate          = DateTime.Parse("05/18/2016"),
                PayrollGeneratedDate = DateTime.Parse("05/18/2016"),
                Employee             = employee
            };

            var employeePayroll2 = new EmployeePayroll()
            {
                CutOffEndDate        = DateTime.Parse("05/10/2016"),
                CutOffStartDate      = DateTime.Parse("05/04/2016"),
                PayrollDate          = DateTime.Parse("05/11/2016"),
                PayrollGeneratedDate = DateTime.Parse("05/11/2016"),
                Employee             = employee
            };

            _employeePayrollRepository.Add(employeePayroll);
            _employeePayrollRepository.Add(employeePayroll2);

            _unitOfWork.Commit();

            DateTime payrollStartDate = _employeePayrollService
                                        .GetNextPayrollStartDate();

            Assert.AreEqual(DateTime.Parse("05/18/2016"), payrollStartDate);

            DateTime payrollEndDate = _employeePayrollService
                                      .GetNextPayrollEndDate(payrollStartDate);

            Assert.AreEqual(DateTime.Parse("05/24/2016"), payrollEndDate);

            DateTime payrollReleaseDate = _employeePayrollService
                                          .GetNextPayrollReleaseDate(payrollEndDate);

            Assert.AreEqual(DateTime.Parse("05/25/2016"), payrollReleaseDate);
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,PayrollDate,EmployeeNumber,EmployeeName,Gender,Attendance,OverTime,Salary,AttendanceDataSources,ComPosition,ComRank,EnrollMentDate,ResignationDate,Deadline,SchoolName,FeeType,ReleaseType")] EmployeePayroll employeePayroll)
        {
            if (ModelState.IsValid)
            {
                db.Entry(employeePayroll).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(employeePayroll));
        }
Exemplo n.º 5
0
        // GET: api/EmployeePayrolls/5
        //  [ResponseType(typeof(EmployeePayroll))]
        public async Task <EmployeePayrollDto> GetEmployeePayroll(int id)
        {
            EmployeePayroll employeePayroll = await db.EmployeePayrolls.FindAsync(id);

            if (employeePayroll == null)
            {
                throw new  HttpResponseException(HttpStatusCode.NotFound);
            }

            return(Mapper.Map <EmployeePayroll, EmployeePayrollDto>(employeePayroll));
        }
Exemplo n.º 6
0
        public void GivenListANdDB_WhenInsert_ShouldRecordExecutionTime()
        {
            List <EmployeePayrollModel> employeeList = new List <EmployeePayrollModel>();

            employeeList.Add(new EmployeePayrollModel(employee_id: 101, employee_name: "Simran", job_description: "Tech", salary: 300000.00, new DateTime(2019 - 10 - 11), geneder: "F", companyId: 1, departmentId: 2, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 102, employee_name: "Adesh", job_description: "Support", salary: 400000.00, new DateTime(2019 - 11 - 11), geneder: "M", companyId: 3, departmentId: 3, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 103, employee_name: "Sandesh", job_description: "Production", salary: 300000.00, new DateTime(2019 - 10 - 11), geneder: "M", companyId: 3, departmentId: 1, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 104, employee_name: "Ruchita", job_description: "Management", salary: 400000.00, new DateTime(2019 - 10 - 11), geneder: "F", companyId: 2, departmentId: 3, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 105, employee_name: "Suchita", job_description: "Management", salary: 400000.00, new DateTime(2019 - 10 - 11), geneder: "F", companyId: 1, departmentId: 2, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 106, employee_name: "Shital", job_description: "Tech", salary: 300000.00, new DateTime(2019 - 10 - 11), geneder: "F", companyId: 1, departmentId: 2, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 107, employee_name: "Akash", job_description: "Support", salary: 400000.00, new DateTime(2019 - 11 - 11), geneder: "M", companyId: 3, departmentId: 3, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 108, employee_name: "Lalit", job_description: "Production", salary: 300000.00, new DateTime(2019 - 10 - 11), geneder: "M", companyId: 3, departmentId: 1, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 109, employee_name: "Rekha", job_description: "Management", salary: 400000.00, new DateTime(2019 - 10 - 11), geneder: "F", companyId: 2, departmentId: 3, is_employee_active: true));
            employeeList.Add(new EmployeePayrollModel(employee_id: 110, employee_name: "Rani", job_description: "Finance", salary: 400000.00, new DateTime(2019 - 10 - 11), geneder: "F", companyId: 1, departmentId: 1, is_employee_active: true));
            EmployeePayrollOperations employeePayrollOperations = new EmployeePayrollOperations();
            DateTime startDataTime = DateTime.Now;

            employeePayrollOperations.addEmplyeeToPayroll(employeeList);
            DateTime stopDateTime             = DateTime.Now;
            var      DurationWithoutThreading = stopDateTime - startDataTime;

            Console.WriteLine("Duration of Insertion without threading for List " + DurationWithoutThreading);

            EmployeePayroll      employeePayroll = new EmployeePayroll();
            EmployeePayrollModel model           = new EmployeePayrollModel()
            {
                employee_id        = 21,
                employee_name      = "Mahishwari",
                job_description    = "Finance",
                joining_date       = new DateTime(2019, 02, 22),
                salary             = 450000.00,
                geneder            = "F",
                companyId          = 2,
                departmentId       = 1,
                is_employee_active = true
            };

            DateTime startDataTimeforDB = DateTime.Now;

            employeePayroll.AddNewEmployee(model);
            DateTime stopDateTimeforDB             = DateTime.Now;
            var      DurationWithoutThreadingForDB = stopDateTimeforDB - startDataTimeforDB;

            Console.WriteLine("Duration of Insertion without threading for DB " + DurationWithoutThreadingForDB);

            DateTime startDataTimeThread = DateTime.Now;

            employeePayrollOperations.addEmplyeeToPayrollWithThread(employeeList);
            DateTime stopDateTimeThread  = DateTime.Now;
            var      DurationInThreading = stopDateTimeThread - startDataTimeThread;

            Console.WriteLine("Duration of Insertion with threading for List " + DurationInThreading);
        }
Exemplo n.º 7
0
        public void GivenQuery_WhenEmpIdSetToFalse_ReturnOnlyActiveEmployee()
        {
            int                  expectedResult  = 16;
            EmployeePayroll      employeePayroll = new EmployeePayroll();
            EmployeePayrollModel model           = new EmployeePayrollModel()
            {
                employee_id = 8
            };
            int result = employeePayroll.CheckEmployeeISActive(model);

            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 8
0
            public static DepartmentPayrollRecord Merge(Employee employee, EmployeePayroll employeePayroll, DepartmentPayroll departmentPayroll)
            {
                var recordToUpdate = From(departmentPayroll);

                recordToUpdate.CheckDate         = employeePayroll.CheckDate;
                recordToUpdate.EmployeeFirstName = employee.FirstName;
                recordToUpdate.EmployeeLastName  = employee.LastName;
                recordToUpdate.GrossPayroll      = employeePayroll.GrossPayroll;
                recordToUpdate.PayrollPeriod     = employeePayroll.PayrollPeriod;

                return(recordToUpdate);
            }
        public static List <EmployeePayroll> GetEmployeePayrollList()
        {
            List <EmployeePayroll> EmployeePayrollList = new List <EmployeePayroll>();
            DataTable EmployeeComponentTable           = EmployeePayrollDataAccess.GetInstance.GetEmployeePayrollList();

            foreach (DataRow dr in EmployeeComponentTable.Rows)
            {
                EmployeePayroll ThePayroll = EmpPayRollToObject(dr);
                EmployeePayrollList.Add(ThePayroll);
            }
            return(EmployeePayrollList);
        }
Exemplo n.º 10
0
        public void GivenQuery_ShouldUpdateSalary()
        {
            double               expectedResult  = 400000.00;
            EmployeePayroll      employeePayroll = new EmployeePayroll();
            EmployeePayrollModel model           = new EmployeePayrollModel()
            {
                employee_name = "Samir",
                salary        = 400000.00
            };
            double salary = employeePayroll.UpdateEmployeeSalary(model);

            Assert.AreEqual(expectedResult, salary);
        }
        // GET: EmployeePayrolls/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmployeePayroll employeePayroll = await db.EmployeePayrolls.FindAsync(id);

            if (employeePayroll == null)
            {
                return(HttpNotFound());
            }
            return(View(employeePayroll));
        }
Exemplo n.º 12
0
        public async Task <IHttpActionResult> DeleteEmployeePayroll(int id)
        {
            EmployeePayroll employeePayroll = await db.EmployeePayrolls.FindAsync(id);

            if (employeePayroll == null)
            {
                return(NotFound());
            }

            db.EmployeePayrolls.Remove(employeePayroll);
            await db.SaveChangesAsync();

            return(Ok(employeePayroll));
        }
Exemplo n.º 13
0
        public async Task <ApiResponse> Handle(EditEmployeeSalaryDetailCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                var existrecord = await _dbContext.EmployeePayroll.Where(x => x.EmployeeID == request.EmployeePayroll[0].EmployeeId).ToListAsync();

                _dbContext.EmployeePayroll.RemoveRange(existrecord);
                await _dbContext.SaveChangesAsync();

                List <EmployeePayroll> employeepayrolllist = new List <EmployeePayroll>();

                foreach (var list in request.EmployeePayroll)
                {
                    EmployeePayroll obj = new EmployeePayroll();

                    if (list.HeadTypeId == (int)SalaryHeadType.GENERAL && list.MonthlyAmount == 0)
                    {
                        throw new Exception("Basic Pay cannot be Zero");
                    }

                    obj.EmployeeID        = list.EmployeeId;
                    obj.CurrencyId        = list.CurrencyId;
                    obj.HeadTypeId        = list.HeadTypeId;
                    obj.SalaryHeadId      = list.SalaryHeadId;
                    obj.MonthlyAmount     = list.MonthlyAmount;
                    obj.PaymentType       = list.PaymentType;
                    obj.PensionRate       = list.PensionRate;
                    obj.AccountNo         = list.AccountNo;
                    obj.TransactionTypeId = list.TransactionTypeId;
                    obj.IsDeleted         = false;

                    employeepayrolllist.Add(obj);
                }
                await _dbContext.EmployeePayroll.AddRangeAsync(employeepayrolllist);

                await _dbContext.SaveChangesAsync();


                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }
        public async Task <ApiResponse> Handle(AddSalaryHeadCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                SalaryHeadDetails obj = _mapper.Map <SalaryHeadDetails>(request);
                obj.IsDeleted = false;
                await _dbContext.SalaryHeadDetails.AddAsync(obj);

                await _dbContext.SaveChangesAsync();

                List <int> employeeIds = await _dbContext.EmployeeDetail.Where(x => x.IsDeleted == false &&
                                                                               x.EmployeeTypeId == (int)EmployeeTypeStatus.Active)
                                         .Select(x => x.EmployeeID)
                                         .ToListAsync();

                if (employeeIds.Any())
                {
                    List <EmployeePayroll> employeePayrollList = new List <EmployeePayroll>();

                    foreach (int employeeid in employeeIds)
                    {
                        EmployeePayroll employeePayroll = new EmployeePayroll();
                        employeePayroll.IsDeleted         = false;
                        employeePayroll.AccountNo         = request.AccountNo;
                        employeePayroll.SalaryHeadId      = obj.SalaryHeadId;
                        employeePayroll.HeadTypeId        = request.HeadTypeId;
                        employeePayroll.AccountNo         = request.AccountNo;
                        employeePayroll.TransactionTypeId = request.TransactionTypeId;
                        employeePayroll.MonthlyAmount     = (double)request.MonthlyAmount;
                        employeePayrollList.Add(employeePayroll);
                    }

                    await _dbContext.EmployeePayroll.AddRangeAsync(employeePayrollList);

                    await _dbContext.SaveChangesAsync();
                }

                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = "Success";
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = ex.Message;
            }
            return(response);
        }
Exemplo n.º 15
0
        public void GivenQuery_WhenAggregateFunction_ShouldReturnResultAndMatchExpected()
        {
            List <string> expected = new List <string>();
            List <string> result   = new List <string>();

            expected.Add("650000");
            expected.Add("100000");
            expected.Add("200000");
            expected.Add("890000");
            expected.Add("296666.6666");
            EmployeePayroll employeePayroll = new EmployeePayroll();

            result = employeePayroll.GetAggregateFunctionResult();
            CollectionAssert.AreEqual(expected, result);
        }
Exemplo n.º 16
0
        public void GivenQuery_ShouldUpdateSalary()
        {
            EmployeePayroll      employeePayroll = new EmployeePayroll();
            EmployeePayrollModel model           = new EmployeePayrollModel()
            {
                employee_name = "Saket",
                salary        = 450000.00
            };
            DateTime startDataTimeforDB = DateTime.Now;

            employeePayroll.UpdateEmployeeSalary(model);
            DateTime stopDateTimeforDB = DateTime.Now;

            Console.WriteLine("Duration for Updatation in DB : " + (stopDateTimeforDB - startDataTimeforDB));
        }
        public Decimal GenerateDeductionsByPayroll(EmployeePayroll employeePayroll)
        {
            double totalHours = 0;
            //Get total number of hours

            /* if (isSemiMonthly)
             * {
             *   totalHours = Double.Parse(_settingService.GetByKey(SEMIMONTHLY_TOTAL_HOURS));
             * }
             * else
             * {
             *   totalHours = Double.Parse(_settingService.GetByKey(MONTHLY_TOTAL_HOURS));
             * }*/

            //Get employees
            //var employeeList = _employeeInfoService.GetAllActive();

            var employee      = _employeeInfoService.GetByEmployeeId(employeePayroll.EmployeeId);
            var deductionList = _deductionService.GetAllCustomizable();

            decimal totalDeductions = 0;

            //Every deductions check for available deduction for employee
            foreach (Deduction deduction in deductionList)
            {
                var employeeDeduction = _employeeDeductionService
                                        .GetByDeductionAndEmployee(deduction.DeductionId, employee.EmployeeId);

                if (employeeDeduction != null)
                {
                    //Create a deduction entry
                    EmployeePayrollDeduction employeePayrollDeduction =
                        new EmployeePayrollDeduction
                    {
                        EmployeeId        = employee.EmployeeId,
                        DeductionId       = deduction.DeductionId,
                        Amount            = employeeDeduction.Amount,
                        DeductionDate     = DateTime.Now,
                        EmployeePayrollId = employeePayroll.PayrollId
                    };

                    _employeePayrollDeductionRepository.Add(employeePayrollDeduction);
                    totalDeductions += employeeDeduction.Amount;
                }
            }

            return(totalDeductions);
        }
Exemplo n.º 18
0
        public async Task <IEnumerable <EmployeePayroll> > CalculateAllEmployeesBenefitsCosts(IEnumerable <EmployeeDTO> employees)
        {
            return(await Task.Run(() =>
            {
                List <EmployeePayroll> employeePayrolls = new List <EmployeePayroll>();

                foreach (EmployeeDTO employee in employees)
                {
                    EmployeePayroll employeePayroll = new EmployeePayroll(employee);

                    employeePayrolls.Add(employeePayroll);
                }

                return employeePayrolls;
            }));
        }
Exemplo n.º 19
0
 public static EmployeePayrollModel MappPayrollFromServerToClient(this EmployeePayroll source)
 {
     return(new EmployeePayrollModel
     {
         Id = source.Id,
         EmployeeId = source.EmployeeId,
         Amount = source.Amount,
         AllowanceTypeId = source.AllowanceTypeId,
         AllowanceTypeTitle = source.AllowanceType.TypeTitle,
         AllowanceDate = source.AllowanceMonth.ToString("MMMM yyyy"),
         RecCreatedBy = source.RecCreatedBy,
         RecCreatedDate = source.RecCreatedDate,
         RecLastUpdatedBy = source.RecLastUpdatedBy,
         RecLastUpdatedDate = source.RecLastUpdatedDate,
         EmployeeName = source.Employee.FullName
     });
 }
Exemplo n.º 20
0
        public void GivenQuery_WhenInsertInto_ShouldAbleToInsertIntoTwoTable()
        {
            bool                 expectedResult  = true;
            EmployeePayroll      employeePayroll = new EmployeePayroll();
            EmployeePayrollModel model           = new EmployeePayrollModel()
            {
                employee_id     = 12,
                employee_name   = "Prakhar",
                job_description = "DevOps",
                joining_date    = new DateTime(2019, 09, 17),
                salary          = 450000.00,
                geneder         = "M"
            };
            bool result = employeePayroll.AddNewEmployee(model);

            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 21
0
        public void GivenQuery_WhenInsertInto_ShouldAbleToInsertValue()
        {
            bool                 expectedResult  = true;
            EmployeePayroll      employeePayroll = new EmployeePayroll();
            EmployeePayrollModel model           = new EmployeePayrollModel()
            {
                employee_id     = 8,
                employee_name   = "Rohit",
                job_description = "Support",
                joining_date    = new DateTime(2018, 10, 22),
                salary          = 240000.00,
                geneder         = "M"
            };
            bool result = employeePayroll.AddNewEmployee(model);

            Assert.AreEqual(expectedResult, result);
        }
Exemplo n.º 22
0
        private void AddRow_Click(object sender, EventArgs e)
        {
            EmployeePayroll employeePayRoll = new EmployeePayroll();

            employeePayRoll.EmployeeFirstName = FirstNameInput.Text;

            employeePayRoll.EmployeeLastName = LastNameInput.Text;

            employeePayRoll.EmployeeEmail = EmailInput.Text;

            double PayRate = 0;

            double.TryParse(PayRateInput.Text, out PayRate);
            employeePayRoll.EmployeePayRate = PayRate;

            double Quantity = 0;

            double.TryParse(QtyInput.Text, out Quantity);
            employeePayRoll.TaskQty = Quantity;

            double ExtraPay = 0;

            double.TryParse(ExtraInput.Text, out ExtraPay);
            employeePayRoll.EmployeeExtraPay = ExtraPay;

            double TotalPay = 0;

            double.TryParse(TotalPayInput.Text, out TotalPay);
            employeePayRoll.EmployeeTotalPay = TotalPay;

            employeePayRoll.EmployeeComments = CommentsInput.Text;

            // Display the new information in the grid from the field.
            dataGridView1.Rows.Add(FirstNameInput.Text, LastNameInput.Text, EmailInput.Text, PayRate, Quantity, ExtraPay, TotalPay, CommentsInput.Text);
            dataGridView1.Columns[0].DisplayIndex = 0;

            // Clear out the input fields
            FirstNameInput.Clear();
            LastNameInput.Clear();
            EmailInput.Clear();
            PayRateInput.Clear();
            QtyInput.Clear();
            ExtraInput.Clear();
            TotalPayInput.Clear();
            CommentsInput.Clear();
        }
Exemplo n.º 23
0
    public void GetAllEmployee(string query)
    {
        try
        {
            EmployeePayroll employeePayroll = new EmployeePayroll();
            using (connection)
            {
                // string query= @"select* from Employee_payroll where start_Date between CAST('2019-01-01' as date) and GETDATE()";
                SqlCommand cnd = new SqlCommand(query, connection);
                connection.Open();

                SqlDataReader dr = cnd.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        employeePayroll.EmployeeID   = dr.GetInt32(0);
                        employeePayroll.EmployeeName = dr.GetString(1);
                        employeePayroll.StartDate    = dr.GetDateTime(2);
                        employeePayroll.Gender       = Convert.ToChar(dr.GetString(3));
                        employeePayroll.Address      = dr.GetString(4);
                        employeePayroll.PhoneNumber  = dr.GetString(5);

                        Console.WriteLine(employeePayroll.EmployeeID + "  " + employeePayroll.EmployeeName + "  " + employeePayroll.StartDate + "  " + employeePayroll.Gender + "  " + employeePayroll.Address + "  " + employeePayroll.PhoneNumber);
                        Console.WriteLine("");
                    }
                }
                else
                {
                    Console.WriteLine("No DAta found");
                }
                dr.Close();
                connection.Close();
            }
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        }
        finally
        {
            connection.Close();
        }
    }
        public async Task <ActionResult> getworkdays(string code, string attendenceSourse)
        {
            var start         = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-01");                                            //上个月第一天
            var startdatetime = Convert.ToDateTime(start);
            var end           = startdatetime.AddDays(1 - startdatetime.Day).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"); //上个月最后一天

            double[] result = await Getworkday(code, start, end, attendenceSourse);

            EmployeePayroll ep = new EmployeePayroll();

            if (result != null)
            {
                ep.Attendance = 25; //result[0];
                ep.OverTime   = 0;  // result[1];
            }

            return(Json(ep, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 25
0
        public void AddEmployee_ShouldMatchEmployeeEnries()
        {
            EmployeeRepo repo = new EmployeeRepo();

            EmployeePayroll employee = new EmployeePayroll();

            employee.EmployeeName = "ktrrr";
            employee.Department   = ".Net";
            employee.StartDate    = DateTime.Parse("10-24-2009");

            DateTime startTime = DateTime.Now;

            repo.AddEmployee(employee);
            repo.AddEmployee(employee);
            repo.AddEmployee(employee);
            DateTime stopTime = DateTime.Now;

            Console.WriteLine("Duration without thread: " + (stopTime - startTime));
        }
Exemplo n.º 26
0
        public void GiveQuery_WhenInsert_ShouldPerformInsertion()
        {
            bool                 expectedInsertResult = true;
            EmployeePayroll      employeePayroll      = new EmployeePayroll();
            EmployeePayrollModel model = new EmployeePayrollModel()
            {
                employee_id     = 17,
                employee_name   = "Juili",
                job_description = "Finance",
                joining_date    = new DateTime(2019, 11, 22),
                salary          = 240000.00,
                geneder         = "F",
                companyId       = 2,
                departmentId    = 3
            };
            bool insertResult = employeePayroll.AddNewEmployee(model);

            Assert.AreEqual(expectedInsertResult, insertResult);
        }
Exemplo n.º 27
0
        public void GiveQuery_WhenInsert_ShouldPerformInsertionASInNewDBStructure()
        {
            bool                 expectedInsertResult = true;
            EmployeePayroll      employeePayroll      = new EmployeePayroll();
            EmployeePayrollModel model = new EmployeePayrollModel()
            {
                employee_id     = 18,
                employee_name   = "Mohit",
                job_description = "Support",
                joining_date    = new DateTime(2019, 02, 22),
                salary          = 350000.00,
                geneder         = "M",
                companyId       = 1,
                departmentId    = 3
            };
            bool insertResult = employeePayroll.AddNewEmployee(model);

            Assert.AreEqual(expectedInsertResult, insertResult);
        }
Exemplo n.º 28
0
        public void ComputeAllowance(DateTime payrollStartDate, DateTime payrollEndDate,
                                     IList <EmployeePayroll> payrollList)
        {
            if (_employeePayrollAllowanceService.proceedAllowance(payrollStartDate, payrollEndDate))
            {
                // Get all active employees
                var employees = _employeeInfoService.GetAllWithAllowance();

                int totalWorkHoursPerDay = Convert.ToInt32(_settingService.GetByKey(PAYROLL_TOTAL_HOURS));
                var totalDays            = Convert.ToInt32(_settingService.GetByKey(ALLOWANCE_TOTAL_DAYS));

                foreach (EmployeeInfo employee in employees)
                {
                    decimal totalAllowance = _employeePayrollAllowanceService
                                             .ComputeEmployeeAllowance(totalDays, totalWorkHoursPerDay, employee, payrollStartDate, payrollEndDate);
                    //Update employee payroll
                    EmployeePayroll employeePayroll = payrollList.OfType <EmployeePayroll>()
                                                      .Where(p => p.EmployeeId == employee.EmployeeId).FirstOrDefault();
                    if (employeePayroll != null)
                    {
                        employeePayroll.TotalAllowance = totalAllowance;
                        employeePayroll.TaxableIncome  = decimal.Add(employeePayroll.TaxableIncome, totalAllowance);
                        employeePayroll.TotalGross     = decimal.Add(employeePayroll.TotalGross, totalAllowance);
                        employeePayroll.TotalNet       = employeePayroll.TotalGross;

                        //TODO change this if allowance is already a list
                        //Create allowance payroll item
                        EmployeePayrollItem allowanceItem = new EmployeePayrollItem();
                        allowanceItem.EmployeeId  = employeePayroll.EmployeeId;
                        allowanceItem.PayrollId   = employeePayroll.PayrollId;
                        allowanceItem.PayrollDate = employeePayroll.PayrollDate;
                        allowanceItem.Multiplier  = 1;
                        allowanceItem.RatePerHour = employee.Salary;
                        allowanceItem.RateType    = RateType.Allowance;
                        allowanceItem.TotalAmount = employeePayroll.TotalAllowance;

                        _employeePayrollItemService.Add(allowanceItem);
                        _unitOfWork.Commit();
                    }
                }
            }
        }
        public void Test_GetDeductionChargeDetailInfo()
        {
            EmployeePayroll _employeePayroll                       = new EmployeePayroll(40, 25, "Ireland");
            ILocationItemRatesProvider_Get _rateProvider           = new LocationItemRatesProvider();
            IDeductionChargeCalculator     _chargeCalculator       = new DeductionChargeCalculator();
            EmployeePayrollManager         _employeePayrollManager = new EmployeePayrollManager(_employeePayroll, _rateProvider, _chargeCalculator);
            string payrollDetailInfo = _employeePayrollManager.GetDeductionChargeDetailInfo();

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("Employee location: {0}\r\n", "Ireland"));
            sb.AppendLine(string.Format("Gross Amount:{0:C}\r\n", (decimal)1000.00));
            sb.AppendLine("Less deductions:\r\n");

            sb.AppendLine(string.Format("{0}:{1:C}", "Income Tax", (decimal)310.00));
            sb.AppendLine(string.Format("{0}:{1:C}", "Universal Social Charge", (decimal)75.00));
            sb.AppendLine(string.Format("{0}:{1:C}", "Pension", (decimal)40.00));

            sb.AppendLine(string.Format("Net Amount:{0:C}", (decimal)575.00));
            Assert.AreEqual(sb.ToString(), payrollDetailInfo);
        }
Exemplo n.º 30
0
        public void GivenEmployeeDetails_AddPayrollDetails()
        {
            EmployeeRepo    repo            = new EmployeeRepo();
            EmployeePayroll employeePayroll = new EmployeePayroll()
            {
                employeeName = "Terrisa",
                phoneNumber  = "7775568964",
                address      = "SA",
                Gender       = "F"
            };
            PayrollModel payrollModel = new PayrollModel()
            {
                BasicPay   = 5500,
                Deductions = 500,
                IncomeTax  = 300
            };

            int employeeId = repo.AddEmployeeToPayroll(payrollModel, employeePayroll);

            Assert.AreEqual(employeePayroll.employeeId, employeeId);
        }