public void PayrollSetup_021_UpdateSpiff_ThatDoesNotExist() { // Arrange int payrollSpiffID = -1; // not supposed to exist 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 Exception caughtException = null; try { 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); } catch (Exception ex) { caughtException = ex; } // Assert Assert.IsNotNull(caughtException); }
public void PayrollSetup_007_SavePayrollSetup_BusinessException_OvertimeMultiplier() { // Arrange SQLHelper.RunSetupScript("UnitTest_PayrollSetup", "A7"); int franchiseID = 39; decimal overtimeStarts = -10M; int overtimeMethod = 2; decimal overtimeMultiplier = -2.5M; // Expect this to cause an argument exception // Act // call save payroll setup on business entity Exception caughtException = null; try { PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(Guid.NewGuid()); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSetup> result = payrollSetupService.SavePayrollSetup(franchiseID, overtimeStarts, overtimeMethod, overtimeMultiplier); } catch (Exception ex) { caughtException = ex; } // Assert Assert.IsNotNull(caughtException); Assert.IsInstanceOfType(caughtException, typeof(ArgumentException)); }
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 ActionResult SavePayrollSetupData(int FranchiseeId, string method, string multiplier, string start) { int franchiseID = FranchiseeId; decimal overtimeStarts = decimal.Parse(start); int overtimeMethod = int.Parse(method); decimal overtimeMultiplier = decimal.Parse(multiplier); PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(UserInfo.UserKey); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSetup> result = payrollSetupService.SavePayrollSetup(franchiseID, overtimeStarts, overtimeMethod, overtimeMultiplier); var toReturn = (result.Success == true) ? new { Success = result.Success, Message = "Payroll Setup saved" } : new { Success = result.Success, Message = "Error: " + result.Message }; return(Json(toReturn)); }
public ActionResult PayrollSpiffAdd( string strCurrentPayrollSpiffID, string strPayrollSetupID, string strJobCodeID, string strServiceProID, string strPayTypeID, string strRate, string strAddOn, string strDateExpires, string strActive, string strComments) { try { int payrollSpiffID = int.Parse(strCurrentPayrollSpiffID); int payrollSetupID = int.Parse(strPayrollSetupID); int jobCodeID = int.Parse(strJobCodeID); int serviceProID = int.Parse(strServiceProID); int payTypeID = int.Parse(strPayTypeID); decimal rate = decimal.Parse(strRate); bool addOn = strAddOn != null; DateTime dateExpires = DateTime.Parse(strDateExpires); bool active = strActive != null; PayrollSetupService payrollSetupService = PayrollSetupService.Create <PayrollSetupService>(UserInfo.UserKey); OperationResult <SiteBlue.Business.PayrollSetup.PayrollSpiff> result = null; if (payrollSpiffID == -1) { result = payrollSetupService.PayrollSpiff_Add(payrollSetupID, serviceProID, jobCodeID, payTypeID, rate, dateExpires, strComments, addOn, active); } else { result = payrollSetupService.PayrollSpiff_Update(payrollSpiffID, serviceProID, jobCodeID, payTypeID, rate, dateExpires, strComments, addOn, active); } var toReturn = (result.Success == true) ? new { Success = result.Success, Message = "Payroll Spiff saved" } : new { Success = result.Success, Message = "Error: " + result.Message }; return(Json(toReturn)); } catch (Exception ex) { var toReturn = new { Success = false, Message = "Error: " + ex.Message }; return(Json(toReturn)); } }
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); }