public void On_Convert_Payroll_MultipleShift_FixesTips()
        {
            IPayrollConverterUtils payrollConverterUtils = new PayrollConverterUtils(logger);
            var employeeRepository    = new EmployeeRepositoryService(logger);
            IPayrollConverter subject = new PayrollConverter(logger, payrollConverterUtils, employeeRepository);
            var data         = new AlohaDataset();
            var empRow       = AlohaDataUtils.CreateEmpRow(data, 1, "123456789", "Test", "Employee", 123456789);
            var adjtimeRow   = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 14, 30, 0.5m, 10m, 10m);
            var adjtimeRow2  = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 15, 0, 16, 30, 0.5m, 10m, 10m);
            var gndbroeakRow = AlohaDataUtils.CreateBreakRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 30, 13, 00, 0.5m);

            data.emp.AddempRow(empRow);
            data.adjtime.AddadjtimeRow(adjtimeRow);
            data.adjtime.AddadjtimeRow(adjtimeRow2);
            data.gndbreak.AddgndbreakRow(gndbroeakRow);
            var tipStrategy = TipCalculation.Auto;

            var result = subject.ConvertPayroll(data, tipStrategy);

            var resultTips = result[0].Transactions.Where(t => t.Type == TransactionType.PayCode).ToList();

            resultTips.Count.Should().Be(2);
            resultTips[0].ClockIn.Hour.Should().Be(12);
            resultTips[0].ClockIn.Minute.Should().Be(0);
            resultTips[1].ClockIn.Hour.Should().Be(12);
            resultTips[1].ClockIn.Minute.Should().Be(5);
        }
示例#2
0
        public void On_ConvertEmployeeRow_GetRightEmployee()
        {
            var data   = new AlohaDataset();
            var empRow = AlohaDataUtils.CreateEmpRow(data, 1, "123456789", "Test", "Employee", 123456789);
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);

            var result = subject.ConverEmployeeRow(empRow);

            result.ID.Should().Be(empRow.id);
            result.SocialSecurity.Should().Be(empRow.ssn);
            result.FirstName.Should().Be(empRow.firstname);
            result.LastName.Should().Be(empRow.lastname);
            result.Transactions.Should().BeEmpty();
        }
示例#3
0
        public void On_GetEmployees_Gets_EmployeeEnumerable()
        {
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var data   = new AlohaDataset();
            var empRow = AlohaDataUtils.CreateEmpRow(data, 1, "123456789", "Test", "Employee", 123456789);

            data.emp.AddempRow(empRow);

            List <Employee> result = subject.GetEmployees(data);

            result.Should().NotBeNull();
            result.Should().NotBeEmpty();
            result.Should().Contain(c => c.ID == 1);
        }
示例#4
0
        public void On_GetBreaks_Ingores_From_IgnoreList()
        {
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var data       = new AlohaDataset();
            var adjtimeRow = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m, 10m, 10m);

            data.adjtime.AddadjtimeRow(adjtimeRow);
            var ignoreList = new List <int> {
                1
            };

            List <Transaction> result = subject.GetBreaks(data, ignoreList);

            result.Should().BeEmpty();
        }
示例#5
0
        public void On_GetEmployees_Gets_All_Employees()
        {
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var data    = new AlohaDataset();
            var empRow  = AlohaDataUtils.CreateEmpRow(data, 1, "123456789", "Test", "Employee1", 123456789);
            var empRow2 = AlohaDataUtils.CreateEmpRow(data, 2, "987654321", "Test", "Employee2", 987654321);

            data.emp.AddempRow(empRow);
            data.emp.AddempRow(empRow2);

            var result = subject.GetEmployees(data);

            result.Count().Should().Be(data.emp.Count());
            result.Should().Contain(e => e.ID == 1);
            result.Should().Contain(e => e.ID == 2);
        }
示例#6
0
        public void On_GetBreaks_Get_TransactionEnumerable()
        {
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var data        = new AlohaDataset();
            var gndbreakRow = AlohaDataUtils.CreateBreakRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m);

            data.gndbreak.AddgndbreakRow(gndbreakRow);
            var ignoreList = new List <int> {
                10
            };

            List <Transaction> result = subject.GetBreaks(data, ignoreList);

            result.Should().NotBeNull();
            result.Should().NotBeEmpty();
            result.Should().Contain(c => c.EmpId == 1);
        }
        public void On_Convert_Payroll_OnlyEmployees_ReturnsListWith_EmptyTransactions()
        {
            IPayrollConverterUtils payrollConverterUtils = new PayrollConverterUtils(logger);
            var employeeRepository    = new EmployeeRepositoryService(logger);
            IPayrollConverter subject = new PayrollConverter(logger, payrollConverterUtils, employeeRepository);
            var data   = new AlohaDataset();
            var empRow = AlohaDataUtils.CreateEmpRow(data, 1, "123456789", "Test", "Employee", 123456789);

            data.emp.AddempRow(empRow);
            var tipStrategy = TipCalculation.Auto;

            var result = subject.ConvertPayroll(data, tipStrategy);

            result.Should().NotBeNull();
            result.Count.Should().Be(1);
            result[0].Transactions.Count.Should().Be(0);
        }
示例#8
0
        public void On_ConvertBreakRow_GetRightShift()
        {
            var data         = new AlohaDataset();
            var gndbroeakRow = AlohaDataUtils.CreateBreakRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m);
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);

            var result = subject.ConvertBreakRow(gndbroeakRow);

            result.Type.Should().Be(TransactionType.ClockInOut);
            result.PeriodType.Should().Be(PeriodType.Break);
            result.PayCode.Should().Be(string.Empty);
            result.EmpId.Should().Be(gndbroeakRow.employee);
            result.SSN.Should().Be(gndbroeakRow.ssn);
            result.JobCode.Should().Be(gndbroeakRow.jobcode);
            result.ClockIn.Should().Be(DateTime.Today.AddHours(12));
            result.ClockOut.Should().Be(DateTime.Today.AddHours(12).AddMinutes(30));
            result.Hours.Should().BeApproximately(0.5m, 0.001m);
        }
示例#9
0
        public void On_GetTips_Get_TransactionEnumerable()
        {
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var data       = new AlohaDataset();
            var adjtimeRow = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m, 10m, 10m);

            data.adjtime.AddadjtimeRow(adjtimeRow);
            var ignoreList = new List <int> {
                10
            };
            var tipstrategy = TipCalculation.Auto;

            List <Transaction> result = subject.GetTips(data, ignoreList, tipstrategy);

            result.Should().NotBeNull();
            result.Should().NotBeEmpty();
            result.Should().Contain(c => c.EmpId == 1);
        }
示例#10
0
        public void On_GetBreaks_Gets_All_Transactions()
        {
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var data         = new AlohaDataset();
            var gndbreakRow  = AlohaDataUtils.CreateBreakRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m);
            var gndbreakRow2 = AlohaDataUtils.CreateBreakRow(data, 2, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 1, 0, 1, 30, 0.5m);

            data.gndbreak.AddgndbreakRow(gndbreakRow);
            data.gndbreak.AddgndbreakRow(gndbreakRow2);
            var ignoreList = new List <int> {
                10
            };

            var result = subject.GetBreaks(data, ignoreList);

            result.Count().Should().Be(data.gndbreak.Count());
            result.Should().Contain(t => t.EmpId == 1);
            result.Should().Contain(t => t.EmpId == 2);
        }
示例#11
0
        public void On_GetTips_Gets_All_Transactions()
        {
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var data        = new AlohaDataset();
            var adjtimeRow  = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m, 10m, 10m);
            var adjtimeRow2 = AlohaDataUtils.CreateAdjTimeRow(data, 2, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 1, 0, 1, 30, 0.5m, 10m, 10m);

            data.adjtime.AddadjtimeRow(adjtimeRow);
            data.adjtime.AddadjtimeRow(adjtimeRow2);
            var ignoreList = new List <int> {
                10
            };
            var tipstrategy = TipCalculation.Auto;

            var result = subject.GetTips(data, ignoreList, tipstrategy);

            result.Count().Should().Be(data.adjtime.Count());
            result.Should().Contain(t => t.EmpId == 1);
            result.Should().Contain(t => t.EmpId == 2);
        }
        public void On_Convert_Payroll_EmpFullData_ReturnsListWith_Transactions()
        {
            IPayrollConverterUtils payrollConverterUtils = new PayrollConverterUtils(logger);
            var employeeRepository    = new EmployeeRepositoryService(logger);
            IPayrollConverter subject = new PayrollConverter(logger, payrollConverterUtils, employeeRepository);
            var data         = new AlohaDataset();
            var empRow       = AlohaDataUtils.CreateEmpRow(data, 1, "123456789", "Test", "Employee", 123456789);
            var adjtimeRow   = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 14, 30, 0.5m, 10m, 10m);
            var gndbroeakRow = AlohaDataUtils.CreateBreakRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 30, 13, 00, 0.5m);

            data.emp.AddempRow(empRow);
            data.adjtime.AddadjtimeRow(adjtimeRow);
            data.gndbreak.AddgndbreakRow(gndbroeakRow);
            var tipStrategy = TipCalculation.Auto;

            var result = subject.ConvertPayroll(data, tipStrategy);

            result[0].Transactions.Count.Should().Be(3);
            result[0].Transactions.Should().Contain(t => t.Type == TransactionType.ClockInOut && t.PeriodType == PeriodType.Shift);
            result[0].Transactions.Should().Contain(t => t.Type == TransactionType.ClockInOut && t.PeriodType == PeriodType.Break);
            result[0].Transactions.Should().ContainSingle(t => t.Type == TransactionType.PayCode);
        }
示例#13
0
        public void On_ConvertTipRow_GetRightTip_Using_Strategy_Auto()
        {
            var data        = new AlohaDataset();
            var adjtimeRow  = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m, 1m, 2m);
            var adjtimeRow2 = AlohaDataUtils.CreateAdjTimeRow(data, 1, "", DateTime.Today, DateTime.Today, DateTime.Today, 1, 12, 0, 12, 30, 0.5m, 2m, 1m);
            IPayrollConverterUtils subject = new PayrollConverterUtils(logger);
            var tipstrategy = TipCalculation.Auto;

            var result  = subject.ConvertTipRow(adjtimeRow, tipstrategy);
            var result2 = subject.ConvertTipRow(adjtimeRow2, tipstrategy);

            result.Type.Should().Be(TransactionType.PayCode);
            result.PeriodType.Should().Be(PeriodType.Unknown);
            result.PayCode.Should().Be("T");
            result.EmpId.Should().Be(adjtimeRow.employee);
            result.SSN.Should().Be(adjtimeRow.ssn);
            result.JobCode.Should().Be(adjtimeRow.jobcode);
            result.ClockIn.Should().Be(DateTime.Today.AddHours(12));
            result.ClockOut.Should().Be(DateTime.MinValue);
            result.Hours.Should().BeApproximately(0m, 0.001m);
            result.Tips.Should().BeApproximately(2m, 0.001m);
            result2.Tips.Should().BeApproximately(2m, 0.001m);
        }