public void PayrollSetup_021_UpdateSpiff() { // Arrange SQLHelper.RunSetupScript("UnitTest_PayrollSetup", "A9"); int franchiseID = 39; ReportingService rs = ReportingService.Create <ReportingService>(Guid.NewGuid()); SiteBlue.Business.Reporting.PayrollSetup[] arrPayrollSetup = rs.GetPayrollSetupData(franchiseID); Assert.AreEqual <int>(1, arrPayrollSetup.Length); int payrollSetupID = arrPayrollSetup[0].PayrollSetupID; int payrollSpiffID = arrPayrollSetup[0].PayrollSpiffs.ToArray()[0].PayrollSpiffID; int serviceProID = 172; int jobCodeID = 65834; int payType = 1; decimal rate = 3.5M; DateTime?dateExpires = DateTime.Parse("5/2/2014"); string comments = "Test comments Update Spiff"; bool addOn = true; bool active = true; // Act // Save Spiff to existing PayrollSetup PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(Guid.NewGuid()); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSpiff> result = payrollSetupService.PayrollSpiff_Update(payrollSpiffID, serviceProID, jobCodeID, payType, rate, dateExpires, comments, addOn, active); // Assert SiteBlue.Business.PayrollSetup.PayrollSpiff newSpiff = result.ResultData; Assert.AreEqual <int>(payrollSetupID, newSpiff.PayrollSetupID); Assert.AreEqual <int>(serviceProID, newSpiff.ServiceProID); Assert.AreEqual <int>(jobCodeID, newSpiff.JobCodeID); Assert.AreEqual <int>(payType, newSpiff.PayType); Assert.AreEqual <decimal>(rate, newSpiff.Rate); Assert.AreEqual <DateTime?>(dateExpires, newSpiff.DateExpires); Assert.AreEqual <string>(comments, newSpiff.Comments); Assert.AreEqual <bool>(addOn, newSpiff.AddOn); Assert.AreEqual <bool>(active, newSpiff.Active); // Can also check the saved entity SiteBlue.Business.Reporting.PayrollSetup[] arrRptPayrollSetup = rs.GetPayrollSetupData(franchiseID); Assert.AreEqual <int>(1, arrRptPayrollSetup.Length); Assert.AreEqual <int>(1, arrRptPayrollSetup[0].PayrollSpiffs.Count()); SiteBlue.Business.Reporting.PayrollSpiff reportSpiff = arrRptPayrollSetup[0].PayrollSpiffs.ToArray()[0]; Assert.AreEqual <int>(payrollSetupID, reportSpiff.PayrollSetupID); Assert.AreEqual <int>(serviceProID, reportSpiff.ServiceProID); Assert.AreEqual <int>(jobCodeID, reportSpiff.JobCodeID); Assert.AreEqual <int>(payType, reportSpiff.PayTypeID); Assert.AreEqual <decimal>(rate, reportSpiff.Rate); Assert.AreEqual <DateTime?>(dateExpires, reportSpiff.DateExpires); Assert.AreEqual <string>(comments, reportSpiff.Comments); Assert.AreEqual <bool>(addOn, reportSpiff.AddOn); Assert.AreEqual <bool>(active, reportSpiff.Active); }
public void PayrollSetup_001_GetPayrollSetupNoFranchise() { // Arrange SQLHelper.RunSetupScript("UnitTest_PayrollSetup", "A1"); int?franchiseID = null; // Act // Query reporting service for PayrollSetup ReportingService rs = ReportingService.Create <ReportingService>(Guid.NewGuid()); SiteBlue.Business.Reporting.PayrollSetup[] arrPayrollSetup = rs.GetPayrollSetupData(franchiseID); // Assert // I should at least get a non-null array, may not have anything in it Assert.IsNotNull(arrPayrollSetup); }
public void PayrollSetup_003_GetPayrollSetupSpecifyFranchise() { // Arrange SQLHelper.RunSetupScript("UnitTest_PayrollSetup", "A3"); int?franchiseID = 39; // Act // Query reporting service for PayrollSetup ReportingService rs = ReportingService.Create <ReportingService>(Guid.NewGuid()); SiteBlue.Business.Reporting.PayrollSetup[] arrPayrollSetup = rs.GetPayrollSetupData(franchiseID); // Assert // I should at least get a non-null array, may not have anything in it Assert.IsNotNull(arrPayrollSetup); Assert.IsTrue(arrPayrollSetup.Length == 1, "Should have one and only one payroll setup"); }
public void PayrollSetup_005_SavePayrollSetup_ExistingPayrollSetup() { // Arrange SQLHelper.RunSetupScript("UnitTest_PayrollSetup", "A5"); int franchiseID = 39; decimal overtimeStarts = 100M; int overtimeMethod = 2; decimal overtimeMultiplier = 3.5M; string reportingOvertimeMethod = "Daily"; // Pre-validation, ensure one payrollsetup DOES alredy exist ReportingService rs = ReportingService.Create <ReportingService>(Guid.NewGuid()); SiteBlue.Business.Reporting.PayrollSetup[] arrPayrollSetup = rs.GetPayrollSetupData(franchiseID); Assert.AreEqual <int>(1, arrPayrollSetup.Length); // Act // call save payroll setup on business entity PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(Guid.NewGuid()); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSetup> result = payrollSetupService.SavePayrollSetup(franchiseID, overtimeStarts, overtimeMethod, overtimeMultiplier); // Assert // Check the POCO object returned Assert.IsTrue(result.Success); Assert.IsNotNull(result.ResultData); Assert.AreEqual <int>(franchiseID, result.ResultData.FranchiseID); Assert.AreEqual <decimal>(overtimeStarts, result.ResultData.OvertimeStarts); Assert.AreEqual <int>(overtimeMethod, result.ResultData.OvertimeMethodID); Assert.AreEqual <decimal>(overtimeMultiplier, result.ResultData.OTMultiplier); // Can also check the data saved arrPayrollSetup = rs.GetPayrollSetupData(franchiseID); Assert.AreEqual <int>(1, arrPayrollSetup.Length); SiteBlue.Business.Reporting.PayrollSetup reportingPayrollSetup = arrPayrollSetup[0]; Assert.AreEqual <int>(franchiseID, reportingPayrollSetup.FranchiseID); Assert.AreEqual <decimal>(overtimeStarts, (decimal)reportingPayrollSetup.OvertimeStarts); Assert.AreEqual <int>(overtimeMethod, reportingPayrollSetup.OvertimeMethodID); Assert.AreEqual <decimal>(overtimeMultiplier, (decimal)reportingPayrollSetup.OTMultiplier); Assert.AreEqual <string>(reportingOvertimeMethod, reportingPayrollSetup.OvertimeMethod); }
/// <summary> /// This is my "Repository Loader". Not sure where in the solution to put this - BPanjavan /// </summary> /// <returns></returns> private SiteBlue.Areas.OwnerPortal.Models.PayrollSetup GetViewModel() { SiteBlue.Areas.OwnerPortal.Models.PayrollSetup payrollSetupViewModel = null; // Going to need this to set on our view-model ReportingService reportingService = ReportingService.Create <ReportingService>(UserInfo.UserKey); var arrOvertimeMethod = (from overtimeMethod in reportingService.GetOvertimeMethods() select new SiteBlue.Areas.OwnerPortal.Models.OvertimeMethod() { OvertimeMethodName = overtimeMethod.OvertimeMethodName, OvertimeMethodID = overtimeMethod.OvertimeMethodID } ).ToArray(); var arrJobCode = (from jobCode in reportingService.GetJobCodes(UserInfo.CurrentFranchise.FranchiseID) select new SiteBlue.Areas.OwnerPortal.Models.JobCode() { JobCodeID = jobCode.JobCodeID, JobCodeDescription = jobCode.JobCodeDescription, JobCodeName = jobCode.JobCodeName, ActiveYN = jobCode.ActiveYN, FranchiseID = jobCode.FranchiseID, PriceBookActiveYN = jobCode.PriceBookActiveYN, PriceBookID = jobCode.PriceBookID, PriceBookName = jobCode.PriceBookName } ).ToArray(); var arrEmployee = (from employee in reportingService.GetEmployees(UserInfo.CurrentFranchise.FranchiseID) select new SiteBlue.Areas.OwnerPortal.Models.Employees() { EmployeeID = employee.EmployeeID, Employee = employee.EmployeeName, ActiveYN = employee.ActiveYN, FranchiseID = employee.FranchiseID, ServiceProYN = employee.ServiceProYN } ).ToArray(); var arrSpiffPayType = ( from spiffPayType in reportingService.GetSpiffPayTypes() select new SiteBlue.Areas.OwnerPortal.Models.SpiffPayType() { SpiffPayTypeID = spiffPayType.SpiffPayTypeID, SpiffPayTypeName = spiffPayType.SpiffPayTypeName } ).ToArray(); SiteBlue.Business.Reporting.PayrollSetup[] arrPayrollSetup = reportingService.GetPayrollSetupData(UserInfo.CurrentFranchise.FranchiseID); // If there is NO existing PayrollSetup, load an empty one if (arrPayrollSetup.Length == 0) { payrollSetupViewModel = new SiteBlue.Areas.OwnerPortal.Models.PayrollSetup(UserInfo.CurrentFranchise.FranchiseID, 0, 0, 0M, null, arrOvertimeMethod, arrJobCode, arrEmployee, arrSpiffPayType); } else { // Otherwise, load our PayrollSetup Data SiteBlue.Business.Reporting.PayrollSetup payrollSetupExisting = arrPayrollSetup[0]; payrollSetupViewModel = new SiteBlue.Areas.OwnerPortal.Models.PayrollSetup( UserInfo.CurrentFranchise.FranchiseID, (decimal)payrollSetupExisting.OvertimeStarts, payrollSetupExisting.OvertimeMethodID, (decimal)payrollSetupExisting.OTMultiplier, (from reportingSpiff in payrollSetupExisting.PayrollSpiffs select new SiteBlue.Areas.OwnerPortal.Models.PayrollSpiff() { Active = reportingSpiff.Active, AddOn = reportingSpiff.AddOn, Comments = reportingSpiff.Comments, DateExpires = reportingSpiff.DateExpires, DateExpiresFormatted = reportingSpiff.DateExpires.Value.ToShortDateString(), JobCode = reportingSpiff.JobCode, JobCodeDescription = reportingSpiff.JobCodeDescription, JobCodeID = reportingSpiff.JobCodeID, PayrollSetupID = reportingSpiff.PayrollSetupID, PayrollSpiffID = reportingSpiff.PayrollSpiffID, PayType = reportingSpiff.PayType, PayTypeID = reportingSpiff.PayTypeID, Rate = reportingSpiff.Rate, ServiceProID = reportingSpiff.ServiceProID, Employee = reportingSpiff.Employee }), arrOvertimeMethod, arrJobCode, arrEmployee, arrSpiffPayType) { PayrollSetupID = arrPayrollSetup[0].PayrollSetupID }; } return(payrollSetupViewModel); }