<% ' MyPAYE ' Module: ImportLiquidAcctData.asp ' ' This software is the copyright of Mr T J Sheppard and may not be copied, duplicated or ' modified other than as permitted in the licence agreement. ' ' © 2015 - 2021 Mr T J Sheppard ' Lyndale House ' Church Street ' Bradwell ' Hope Valley ' S33 9HJ ' ' Tel 0845 643 5191 ' Email Support@MyPAYE.co.uk ' ' MyPAYE is a Registered Trademark of MyPAYE Ltd '------------------------------------------------------------------- ' ' Updated 11 September 2021 ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Description - This module import Employee data etc from Liquid Accounts ' ' Amendment Log '------------------------------------------------------------------------------------------ ' Date | Name | Vers. | Description '------------------------------------------------------------------------------------------ ' 18/03/15 | TJS | 4.0.12 | Page added ' 21/03/15 | TJS | 4.0.12a | Modified to set Normal Hours Worked and Secondment Status on ' | importeed Employees and to accept NI Letter C without Marital Status ' | Also modified to display warning if validation is needed due other NI Letters ' 26/03/15 | TJS | 4.0.12b | Added additional diagnostic logging and modified BuildPayItemsXML to ignore case when ' | matching pay amount items and only add pay amounts with a time value greater than zero ' 08/04/15 | TJS | 4.0.13 | Modified to ensure Pay Types are imported correctly when description is duplicated with different Nominal Codes ' 14/04/15 | TJS | 4.0.13a | Added code to handle Liquid Accounts Annual, Bi-Weekly and Four Weekly payrolls ' 14/04/15 | DC/TJS | 4.0.13b | Corrected syntax errors. ' 14/04/15 | TJS | 4.0.13c | Added missing to Employee XML, added additional debug statements ' | and modified to cater for sort codes without hyphens ' 22/04/15 | TJS | 4.0.13d | Added max length on pay type new description ' 26/04/15 | TJS | 4.0.14 | Added additional logging and check if payroll created properly and modified to cater ' | for cost centres. Also corrected mapping XML when new pay type created ' 16/05/15 | TJS | 4.0.15 | Modified to cater for long mapped Liquid Accounts Cost Centres ' 26/11/15 | TJS | 5.0.00 | Modified to cater for separate User_Permissions table ' 18/12/15 | TJS | 5.0.02 | Modified to cater for Deleted column on Pay_Types table ' 27/10/17 | TJS | 5.1.11 | Modified SendErrorEmail to be consistent with LiquidAccountsAPIFunctions.asp ' 15/01/18 | TJS | 5.1.15 | Added checks for liquid accounts recordset EOF as LoadData function no longer returning error if recordset empty ' 19/05/18 | TJS | 5.2.07 | Modified to cater for Deleted field on Liquid_Accounts_Integration table ' 27/06/18 | TJS | 5.3.01 | Modified to use WinHTTP.WinHTTPRequest.5.1 instead of Msxml2.ServerXMLHTTP ' 20/10/19 | TJS | 5.7.00 | Modified to use GetMainMenuParam to save having to read lots of parameters for each page build ' 30/05/20 | TJS | 5.8.00 | Modified for new styling - added centered class on body and modified to replace stylesheet.css, mainmenu.css and buttons-css.asp with BodyAndMenu-css.asp ' 09/04/21 | TJS | 5.9.09 | Modified to use ASPDOTNET/LogOut.aspx and ASPDOTNET/AgencyCancel.aspx pages ' 25/08/21 | TJS | 5.9.11 | Corrected spelling of Liquid Accounts ' 11/09/21 | TJS | 5.9.11 | Modified to replace alert and confirm dialogues to cater for browser blocks on cross site dialogs ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' PageID = 82061 ' since form is loaded using Post when displayed after Pay Type Mapping is set, need to check for this if Request.ServerVariables("request_method") = "GET" then SessionID = request.querystring("ID") SessionVarsID = RemoveHTML(request.querystring("SV")) SourceFrame = RemoveHTML(request.querystring("S")) DestFrame = RemoveHTML(request.querystring("D")) EmployerID = CheckURLDBIDField(RemoveHTML(request.querystring("ER")), "EmployerID") else SessionID = request.form("ID") SessionVarsID = RemoveHTML(request.form("SV")) SourceFrame = RemoveHTML(request.form("S")) DestFrame = RemoveHTML(request.form("D")) EmployerID = CheckURLDBIDField(RemoveHTML(request.form("ER")), "EmployerID") end if %> <%GetSessionVarsIDRecord(SessionVarsID)%> <%if Request.ServerVariables("request_method") = "GET" then MappingConfirmed = RemoveHTML(request.querystring("MapConf")) else MappingConfirmed = RemoveHTML(request.form("MapConf")) end if function ConvertForXML(StringToConvert) strTemp = Replace(StringToConvert, "&", "&") strTemp = Replace(strTemp, "<", "<") strTemp = Replace(strTemp, ">", ">") strTemp = Replace(strTemp, """", """) strTemp = Replace(strTemp, "'", "'") ConvertForXML = strTemp end function function ConvertDateForXML(DateToConvert) if "" & DateToConvert <> "" then dteDate = cDate(DateToConvert) ConvertDateForXML = Year(dteDate) & "-" & right("0" & Month(dteDate), 2) & "-" & right("0" & Day(dteDate), 2) else ConvertDateForXML = "" end if end function function GetMappingValue(XDoc, IsMatched, ElementName) if IsMatched then GetMappingValue = GetElementText(XDoc, "PayAmount/" & ElementName) else GetMappingValue = "" end if end function function GetLogPath() dim WshShell Set WshShell = server.CreateObject("WScript.Shell") ' are we on the test site ? if UCase(request.servervariables("SERVER_NAME")) = "WWW.MYPAYETEST.CO.UK" or UCase(request.servervariables("SERVER_NAME")) = "WWW.MYPAYETEST.COM" or _ UCase(request.servervariables("SERVER_NAME")) = "MYPAYETEST.CO.UK" or UCase(request.servervariables("SERVER_NAME")) = "MYPAYETEST.COM" then ' yes, set registry key to get test Log File path GetLogPath = WshShell.RegRead("HKLM\Software\MyPAYE\Test\LogFiles") else ' no, set registry key to get live Log File path GetLogPath = WshShell.RegRead("HKLM\Software\MyPAYE\Live\LogFiles") end if if right(GetLogPath, 1) <> "\" then GetLogPath = GetLogPath & "\" end if Set WshShell = nothing end function function BuildEmployeeXML(ByVal XMLFunction, ByVal PayrollLinkID, ByRef MarkAsValidated) ' TJS 21/03/15 MarkAsValidated = "Yes" BuildEmployeeXML = "" & ConvertForXML(rsAccountsLink("Account_Link_ID")) & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(DecryptData(rsAccountsLink("Account_Link_Pwd"))) & "" BuildEmployeeXML = BuildEmployeeXML & "" & XMLFunction & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(PayrollLinkID) & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_Code")) & "" if "" & rsEmployee.Field("Ee_Sex") = "F" then BuildEmployeeXML = BuildEmployeeXML & "Ms" else BuildEmployeeXML = BuildEmployeeXML & "Mr" end if if "" & rsEmployee.Field("Ee_FirstName") <> "" then sForeNames = Split("" & rsEmployee.Field("Ee_FirstName"), " ") iNameCount = UBound(sForeNames) if iNameCount = 0 or iNameCount = 1 then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(sForeNames(0)) & "" elseif iNameCount = 2 then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(sForeNames(0)) & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(sForeNames(1)) & "" else BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(sForeNames(0)) & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(sForeNames(1)) & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(sForeNames(2)) & "" end if end if BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_Surname")) & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_Add1")) & "" if "" & rsEmployee.Field("Ee_Add3") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_Add2")) & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_Add3")) & "" else BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_Add2")) & "" end if BuildEmployeeXML = BuildEmployeeXML & "" BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_PostCode")) & "" BuildEmployeeXML = BuildEmployeeXML & "No" BuildEmployeeXML = BuildEmployeeXML & "" & rsEmployee.Field("Ee_Phone") & "" if "" & rsEmployee.Field("Ee_Sex") = "M" then BuildEmployeeXML = BuildEmployeeXML & "Male" elseif "" & rsEmployee.Field("Ee_Sex") = "F" then BuildEmployeeXML = BuildEmployeeXML & "Female" end if if "" & rsEmployee.Field("Ee_NI_Table") <> "A" and "" & rsEmployee.Field("Ee_NI_Table") <> "C" then MarkAsValidated = "No" end if BuildEmployeeXML = BuildEmployeeXML & "?" BuildEmployeeXML = BuildEmployeeXML & "" & left("" & rsEmployee.Field("Ee_DOB"), 10) & "" BuildEmployeeXML = BuildEmployeeXML & "" & left("" & rsEmployee.Field("Ee_Date_Start"), 10) & "" if "" & rsEmployee.Field("Ee_Date_Left") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & left("" & rsEmployee.Field("Ee_Date_Left"), 10) & "" end if if "" & rsEmployee.Field("Ee_NI_No") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_NI_No")) & "" end if if "" & rsEmployee.Field("Ee_Tax_Code") <> "" then if UCase(right(rsEmployee.Field("Ee_Tax_Code"), 2)) = "W1" or UCase(right(rsEmployee.Field("Ee_Tax_Code"), 2)) = "M1" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(left(rsEmployee.Field("Ee_Tax_Code"), len(rsEmployee.Field("Ee_Tax_Code"))- 2)) & "" else BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_Tax_Code")) & "" end if end if if "" & rsEmployee.Field("Ee_NI_Table") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_NI_Table")) & "" end if if "" & rsEmployee.Field("Ee_Email") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_Email")) & "" end if if "" & rsEmployee.Field("PassportNo") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("PassportNo")) & "" end if BuildEmployeeXML = BuildEmployeeXML & "Other/Irregular" ' TJS 21/03/15 BuildEmployeeXML = BuildEmployeeXML & "UK Resident" ' TJS 21/03/15 if "" & rsEmployee.Field("Ee_Pay_Type") <> "" then if rsEmployee.Field("Ee_Pay_Type") = "BACS" then BuildEmployeeXML = BuildEmployeeXML & "Bank Transfer" else BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_Pay_Type")) & "" end if end if if "" & rsEmployee.Field("Ee_Bank_Name") <> "" or "" & rsEmployee.Field("Ee_Sort_Code") <> "" or _ "" & rsEmployee.Field("Ee_Acct_No") <> "" or "" & rsEmployee.Field("Ee_Account") <> "" then ' TJS 14/04/15 BuildEmployeeXML = BuildEmployeeXML & "" ' TJS 14/04/15 end if if "" & rsEmployee.Field("Ee_Bank_Name") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_Bank_Name")) & "" end if if "" & rsEmployee.Field("Ee_Sort_Code") <> "" then if len(rsEmployee.Field("Ee_Sort_Code")) = 6 then ' TJS 14/04/15 BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(left(rsEmployee.Field("Ee_Sort_Code"), 2) & "-" & _ mid(rsEmployee.Field("Ee_Sort_Code"), 3, 2) & "-" & mid(rsEmployee.Field("Ee_Sort_Code"), 5, 2)) & "" ' TJS 14/04/15 else BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_Sort_Code")) & "" end if end if if "" & rsEmployee.Field("Ee_Acct_No") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_Acct_No")) & "" end if if "" & rsEmployee.Field("Ee_Account") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & ConvertForXML(rsEmployee.Field("Ee_Account")) & "" end if if "" & rsEmployee.Field("Ee_Bank_Name") <> "" or "" & rsEmployee.Field("Ee_Sort_Code") <> "" or _ "" & rsEmployee.Field("Ee_Acct_No") <> "" or "" & rsEmployee.Field("Ee_Account") <> "" then ' TJS 14/04/15 BuildEmployeeXML = BuildEmployeeXML & "" ' TJS 14/04/15 end if BuildEmployeeXML = BuildEmployeeXML & "Payroll" if cBool(rsEmployee.Field("Ee_Student_Loan")) then BuildEmployeeXML = BuildEmployeeXML & "Yes" BuildEmployeeXML = BuildEmployeeXML & "" & left("" & rsEmployee.Field("Ee_Date_Start"), 10) & "" end if if cBool(rsEmployee.Field("Ee_Director")) then BuildEmployeeXML = BuildEmployeeXML & "YesPeriodic" if "" & rsEmployee.Field("Ee_Appoint_Dir") <> "" then BuildEmployeeXML = BuildEmployeeXML & "" & left(rsEmployee.Field("Ee_Appoint_Dir"), 10) & "" else BuildEmployeeXML = BuildEmployeeXML & "" & left("" & rsEmployee.Field("Ee_Date_Start"), 10) & "" end if else BuildEmployeeXML = BuildEmployeeXML & "No" end if if cBool(rsEmployer("Use_Cost_Centres")) then ' TJS 26/04/15 BuildEmployeeXML = BuildEmployeeXML & "" ' TJS 26/04/15 TJS 16/05/15 end if BuildEmployeeXML = BuildEmployeeXML & "" & MarkAsValidated & "" BuildEmployeeXML = BuildEmployeeXML & "" end function function BuildEmployeeYTDXML(ByVal XMLFunction, ByVal PayrollLinkID, ByVal EmployeeLinkID) BuildEmployeeYTDXML = "" & ConvertForXML(rsAccountsLink("Account_Link_ID")) & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & ConvertForXML(DecryptData(rsAccountsLink("Account_Link_Pwd"))) & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & XMLFunction & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & ConvertForXML(PayrollLinkID) & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & ConvertForXML(EmployeeLinkID) & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("GrossTaxableEarnings") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("TaxDeducted") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("StudentLoan") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("SSP") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("SMPPaid") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("SMPRecov") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("SMPNIComp") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("OSPPPaid") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("OSPPRecov") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("OSPPNIComp") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("ASPPPaid") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("ASPPRecov") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("ASPPNIComp") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("SAPPaid") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("SAPRecov") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11Values.Field("SAPNIComp") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("NICLetter") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("AtLEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("LELToPT") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("PTToUAP") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("UAPToUEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("NICEmployee") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues.Field("NICEmployer") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" if bIncludeNICChange1 then BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("NICLetter") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("AtLEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("LELToPT") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("PTToUAP") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("UAPToUEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("NICEmployee") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues2.Field("NICEmployer") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" end if if bIncludeNICChange2 then BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("NICLetter") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("AtLEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("LELToPT") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("PTToUAP") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("UAPToUEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("NICEmployee") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues3.Field("NICEmployer") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" end if if bIncludeNICChange3 then BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("NICLetter") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("EarningsForNI") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("AtLEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("LELToPT") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("PTToUAP") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("UAPToUEL") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("NICEmployee") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" & rsP11NIValues4.Field("NICEmployer") & "" BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" end if BuildEmployeeYTDXML = BuildEmployeeYTDXML & "" end function function BuildPayItemsXML(ByVal PayrollLinkID, ByVal EmployeeLinkID, ByRef PayItemCount) BuildPayItemsXML = "" & ConvertForXML(rsAccountsLink("Account_Link_ID")) & "" BuildPayItemsXML = BuildPayItemsXML & "" & ConvertForXML(DecryptData(rsAccountsLink("Account_Link_Pwd"))) & "" BuildPayItemsXML = BuildPayItemsXML & "AddEmployeePayItems" PayItemCount = 0 do while not rsCheckPay.EOF ' ignore all SMP, SPP etc records if "" & rsCheckPay.Field("Ee_Pay_Line") <> "1001" and "" & rsCheckPay.Field("Ee_Pay_Line") <> "1002" and _ "" & rsCheckPay.Field("Ee_Pay_Line") <> "1005" and "" & rsCheckPay.Field("Ee_Pay_Line") <> "1006" and _ "" & rsCheckPay.Field("Ee_Pay_Line") <> "10001" and "" & rsCheckPay.Field("Ee_Pay_Line") <> "10010" then bItemMatched = false for each XMLPayAmount in XMLPayTypeMappings XMLTemp.loadXML(XMLPayAmount.xml) if GetElementText(XMLTemp, "PayAmount/PayFrequency") = rsEmployee.Field("Ee_Pay_frequency") and _ UCase(GetElementText(XMLTemp, "PayAmount/Description")) = UCase(rsCheckPay.Field("Ee_Pay_Desc")) and _ UCase(GetElementText(XMLTemp, "PayAmount/NominalCode")) = UCase(rsCheckPay.Field("Ee_Nom_Code")) then ' TJS 26/03/15 bItemMatched = true if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Pay Type mapping entry found - " & XMLTemp.xml end if exit for end if next if bItemMatched then if GetElementText(XMLTemp, "PayAmount/Ignore") <> "Yes" then BuildPayItemsXML = BuildPayItemsXML & "" & ConvertForXML(PayrollLinkID) & "" BuildPayItemsXML = BuildPayItemsXML & "" & ConvertForXML(EmployeeLinkID) & "" BuildPayItemsXML = BuildPayItemsXML & "" & ConvertForXML("" & rsEmployee.Field("Ee_Code")) BuildPayItemsXML = BuildPayItemsXML & "" & EncryptData(GetElementText(XMLTemp, "PayAmount/PayTypeIDToUse")) BuildPayItemsXML = BuildPayItemsXML & "Earning" if "" & rsCheckPay.Field("Ee_Pay_Time") <> "" then BuildPayItemsXML = BuildPayItemsXML & "" & rsCheckPay.Field("Ee_Pay_Time") & "" else BuildPayItemsXML = BuildPayItemsXML & "0" end if if "" & rsCheckPay.Field("Ee_Pay_Rate") <> "" then BuildPayItemsXML = BuildPayItemsXML & "" & rsCheckPay.Field("Ee_Pay_Rate") & "" else BuildPayItemsXML = BuildPayItemsXML & "0" end if BuildPayItemsXML = BuildPayItemsXML & "Yes" if "" & rsCheckPay.Field("Ee_Costing") <> "" then ' TJS 26/04/15 BuildPayItemsXML = BuildPayItemsXML & "" & ConvertForXML(rsCheckPay.Field("Ee_Costing")) & "" ' TJS 26/04/15 TJS 16/05/15 end if PayItemCount = PayItemCount + 1 end if else ' start of code added TJS 26/03/15 if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "No " & rsEmployee.Field("Ee_Pay_frequency") & " Pay Type mapping found for " & rsCheckPay.Field("Ee_Pay_Desc") & " - " & rsCheckPay.Field("Ee_Nom_Code") end if ' end of code added TJS 26/03/15 end if end if rsCheckPay.movenext loop BuildPayItemsXML = BuildPayItemsXML & "" & PayItemCount & "" ' start of code added TJS 26/03/15 if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Pay Item Count " & PayItemCount end if ' end of code added TJS 26/03/15 end function sub SendErrorEmail(ByVal SystemIntegration, ByVal ErrorMessage, ByVal AlertText) ' TJS 27/10/17 if left(UCase(request.servervariables("SERVER_NAME")), 9) <> "MYPAYE-LT" then ' Read registry for IIS Version & mail server params Set WshShell = server.CreateObject("WScript.Shell") RegKey = "HKLM\Software\MyPAYE\IIS\" IISVersion = WshShell.RegRead(RegKey & "Version") SMTPSendUsing = WshShell.RegRead(RegKey & "SendUsing") SMTPPickupDirectory = WshShell.RegRead(RegKey & "PickupDirectory") SMTPServer = WshShell.RegRead(RegKey & "SMTPServer") SMTPServerPort = WshShell.RegRead(RegKey & "ServerPort") Set WshShell = nothing Set myMail = CreateObject("CDO.Message") ' ##################### CODE ADDED TO WORK ON IIS 7 ################################# if IISVersion = 7 then myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = SMTPSendUsing if SMTPSendUsing = 1 then myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = SMTPPickupDirectory else myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPServerPort end if myMail.Configuration.Fields.Update end if ' ################################################################################### myMail.Subject = "MyPAYE " & AccountIntegration & " Import Error" ' TJS 27/10/17 myMail.From = "AutoSequence@MyPAYE.co.uk" myMail.To = "Support@mypaye.co.uk" myMail.TextBody = request.servervariables("SERVER_NAME") & ", ImportLiquidAcctData.asp - " & ErrorMessage myMail.Send Set myMail = nothing if cBool(GetSessionVar("AllowDebug")) then ' TJS 14/04/15 objLogFile.WriteLine ErrorMessage ' TJS 14/04/15 end if else response.write vbcrlf & "
" & ErrorMessage if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine ErrorMessage end if SaveSessionVarsRecord SessionVarsID ' TJS 26/04/15 response.end end if end sub Server.ScriptTimeOut = 300 bImportComplete = false sql = "SELECT " & EmployerTableMenuOptionFields & ", Use_Cost_Centres, Inhibit_Generic_Pay_Types, Default_Nominal_Codes, " ' TJS 26/04/15 sql = sql & "Default_Net_Pay_Due_Nominal FROM " & DBSchema & "Employers WHERE Employer_ID = " & EmployerID set rsEmployer = OpenRecordset(objConn, sql) InhibitGenericPayTypes = cBool(rsEmployer("Inhibit_Generic_Pay_Types")) DefaultCodes = cBool(rsEmployer("Default_Nominal_Codes")) PayDueNomCodeID = rsEmployer("Default_Net_Pay_Due_Nominal") sql = "SELECT " & UserTableMenuPermissionFields & " FROM " & DBSchema & "Users INNER JOIN " & DBSchema & "User_Permissions " ' TJS 26/11/15 sql = sql & "ON Users.User_ID = User_Permissions.User_ID AND (Employee_Employer_ID = '' OR Employee_Employer_ID = '" ' TJS 26/11/15 sql = sql & EncodeEmployerID(UserPermissionsTable, EmployerID) & "') WHERE Users.User_ID = " & GetSessionVar("UserID") ' TJS 26/11/15 sql = sql & " AND User_Permissions.Deleted = 0 ORDER BY Employee_Employer_ID DESC" ' TJS 26/11/15 set rsUser = OpenRecordset(objConn, sql) ReadMainMenuParams SessionVarsID, cBool(rsUser("User_Admin")), (cBool(rsUser("Run_Payroll")) or cBool(rsUser("Payroll_EOY")) or cBool(rsUser("CIS_Returns"))), _ cBool(rsUser("Run_Payroll")), rsUser("Support_User_ID") ' TJS 20/10/19 sql = "SELECT Link_ID, Account_Link_ID, Account_Link_Pwd FROM " & DBSchema & "Accounts_Link " sql = sql & "WHERE Employer_ID = '" & EncodeEmployerID(AccountsLinkTable, EmployerID) & "'" set rsAccountsLink = OpenRecordset(objConn, sql) %> Liquid Accounts Data Import <%if CheckBrowserVersion("MSIE", 8, true, false, false) then ' [if LT IE 8]%> <%end if if CheckBrowserVersion("MSIE", 7, true, true, false) then ' [if lte IE 7]%> <%end if if "" & GetSessionVar("PathModifier") <> "" then%> Partner-CSS.asp" /> <%end if%> <%MenuShowHome = true MenuShowEmployer = false MenuShowFindEmployee = false MenuShowUsers = false MenuShowCreate = false MenuShowCreatePayroll = false MenuShowCreateEmployer = false MenuShowCreateUser = false MenuShowHMRC = false MenuShowReports = false MenuShowPayrollData = false MenuShowTools = false MenuShowSupport = true MenuSelected = "" MenuEmployerExists = true MenuShowAccount = false%>
<%response.Expires = -1500 response.Expiresabsolute = Now() - 2 response.AddHeader "pragma", "no-cache" response.AddHeader "cache-control", "no-store" response.CacheControl = "no-cache" sql = "SELECT COUNT(*) FROM " & DBSchema & "Nominal_Codes WHERE Employer_ID = " & EmployerID & " AND IFNULL(Nominal_Code, '') = ''" set rsCheckNomCodes = OpenRecordset(objConn, sql) if cLng(rsCheckNomCodes(0)) = 0 then if cBool(GetSessionVar("AllowDebug")) then set objFSO = CreateObject("Scripting.FileSystemObject") sXMLFileName = GetLogPath & "MyPAYE_Liquid_Accts_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & ".log" if objFSO.FileExists(sXMLFileName ) then Set objLogFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objLogFile = objFSO.CreateTextFile(sXMLFileName) end if end if InitialiseLiquidAcctsAPI ' TJS 25/08/21 ' first import Pay Items sql = "SELECT Ee_Nom_Code, RTRIM(LTRIM(ISNull(Ee_Pay_Desc, ''))) AS Ee_Pay_Desc, Ee_Pay_frequency, Ee_Taxable, Ee_NIable FROM payamount INNER JOIN " sql = sql & "employee ON payamount.Ee_Code = employee.Ee_Code AND Ee_Pay_frequency IS NOT NULL WHERE Ee_Pay_Line NOT IN ('1001', '1002', '1005', '1006', '10001', '10010') " sql = sql & "AND payamount.Ee_Code IN (SELECT Ee_Code FROM employee WHERE ISNULL(Ee_Old_Code,'') = '' AND Ee_Pay_frequency IS NOT NULL) AND " sql = sql & "Ee_Pay_Time >= 0 AND payamount.Ee_Pay_Desc IS NOT NULL GROUP BY Ee_Nom_Code, RTRIM(LTRIM(ISNull(Ee_Pay_Desc, ''))), Ee_Pay_frequency, " sql = sql & "Ee_Taxable, Ee_NIable " set rsPayAmount = new LiquidAcctsRecordset if rsPayAmount.LoadData(sql) then if not rsBSGroup.EOF then ' TJS 15/01/18 set XMLTemp = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0") XMLTemp.validateOnParse = True XMLTemp.preserveWhiteSpace = True set XMLPayTypeMappings = LiquidAcctsPayTypeMapping.selectNodes("LiquidAccts/PayAmount") if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Existing Pay Type Mapping " & LiquidAcctsPayTypeMapping.xml end if if "" & MappingConfirmed <> "Yes" then sql = "SELECT Pay_Type_ID, Pay_Types.Employer_ID, Pay_Types.Display_Name, Exclude_Payroll_Freq, Nominal_Code FROM " sql = sql & DBSchema & "Pay_Types INNER JOIN " & DBSchema & "Nominal_Codes ON (Pay_Types.Payroll_Cost_Nominal = " if DefaultCodes then sql = sql & "Nominal_Codes.Nominal_Code_ID " else sql = sql & "Nominal_Codes.Orig_Nom_Code_ID " end if sql = sql & "AND Pay_Types.Employer_ID = -1 AND Nominal_Codes.Employer_ID = " & EmployerID & ") OR " sql = sql & "(Pay_Types.Payroll_Cost_Nominal = Nominal_Codes.Nominal_Code_ID AND Pay_Types.Employer_ID = " sql = sql & EmployerID & " AND Nominal_Codes.Employer_ID = " & EmployerID & ") WHERE (Pay_Types.Employer_ID = -1 " sql = sql & "OR Pay_Types.Employer_ID = " & EmployerID & ") AND Earning_or_Deduction = 'E' AND Pay_Types.Deleted = 0 " ' TJS 18/12/15 sql = sql & "ORDER BY Calculated_Pay_Item DESC, Sort_Order" if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Pay Types SQL " & sql end if set rsPayItems = OpenRecordset(objConn, sql)%>

<%=GetSessionVar("SystemName")%> uses a structured approach to creating the Pay Items on an Employees pay slip based on pre-defined Pay Types
which are then applied as Pay Items on the payslip.

<%=GetSessionVar("SystemName")%> provides a series of standard Generic Pay Types, but these can be supplemented with Employer specific Pay Types as required.

In order to import your Employees, <%=GetSessionVar("SystemName")%> needs to map the existing pay amounts records from Liquid Accounts to suitable Pay Types in the table below.

Where a Liquid Accounts pay amount description matches an existing Pay Type in <%=GetSessionVar("SystemName")%>, this has been pre-selected.

For the remaining records, please either select a suitable existing Pay Type or tick the Create or Ignore checkboxes.
You can amend the Description for Pay Types to be created if you wish.

If you have several records with similar descriptions due to typing errors, you can select the Create option for each and enter the same (corrected) description for each
in the New Pay Type Description box - <%=GetSessionVar("SystemName")%> will create a single new Pay Type with the new description.

NOTE Statutory Payments such as SSP, SMP, SPP, SAP and deductions such as Attachments of Earnings are handled in <%=GetSessionVar("SystemName")%> as specific functions
and any related Pay Amount records have been excluded from this list.

You can also create additional Pay Types at any time in <%=GetSessionVar("SystemName")%> and apply them to Employees,
this list simply deals with the Pay Types required for the initial Employee import.

/Secure/ImportLiquidAcctData.asp"> <%iLoop = 0 do while not rsPayAmount.EOF bItemMatched = false for each XMLPayAmount in XMLPayTypeMappings XMLTemp.loadXML(XMLPayAmount.xml) if GetElementText(XMLTemp, "PayAmount/PayFrequency") = rsPayAmount.Field("Ee_Pay_frequency") and _ GetElementText(XMLTemp, "PayAmount/Description") = rsPayAmount.Field("Ee_Pay_Desc") and _ GetElementText(XMLTemp, "PayAmount/NominalCode") = rsPayAmount.Field("Ee_Nom_Code") then bItemMatched = true if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Pay Type mapping entry found - " & XMLTemp.xml end if exit for end if next%> <%rsPayAmount.movenext iLoop = iLoop + 1 loop%>
Pay
Frequency
Description Nominal Code Existing Pay Type
to use
Create new
Pay Type
New Pay Type
Description
Ignore - do
not import
<%=rsPayAmount.Field("Ee_Pay_frequency")%> "> "> <%=rsPayAmount.Field("Ee_Pay_Desc")%> "> "> <%=rsPayAmount.Field("Ee_Nom_Code")%> ">
checked<%end if%> onclick="SetRowOptions('N', <%=iLoop%>)">
visible<%else%>hidden<%end if%>;" id="ShowNewDesc<%=iLoop%>">" maxlength="30">
checked<%end if%> onclick="SetRowOptions('I', <%=iLoop%>)">

Continue /Secure/EmployerIntegration.asp?ID=<%=SetPageSessionID(93840, DestFrame)%>&SV=<%=SessionVarsID%>&S=<%=DestFrame%>&D=<%=PopupWindow1%>&ER=<%=EmployerID%>','_self','',true);" >Cancel

<%else%> <%sql = "SELECT CO_BSStartNo FROM company" set rsBSGroup = new LiquidAcctsRecordset if rsBSGroup.LoadData(sql) then if not rsBSGroup.EOF then ' TJS 15/01/18 iBalShtGrp = cInt(rsBSGroup.Field("CO_BSStartNo")) if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Liquid Accouts Balance Sheet start " & rsBSGroup.Field("CO_BSStartNo") end if rsBSGroup.close set rsBSGroup = nothing sql = "SELECT NL_Code, NL_Description, NL_Acct_Order FROM nominal ORDER BY NL_Code" set rsNominal = new LiquidAcctsRecordset if rsNominal.LoadData(sql) then if not rsNominal.EOF then ' TJS 15/01/18 if Request.ServerVariables("request_method") = "GET" then PayTypeCount = RemoveHTML(request.querystring("PayTypeCount")) else PayTypeCount = RemoveHTML(request.form("PayTypeCount")) end if if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "PayTypeCount " & PayTypeCount end if set LiquidAcctsPayTypeMapping = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0") LiquidAcctsPayTypeMapping.validateOnParse = True LiquidAcctsPayTypeMapping.preserveWhiteSpace = True objConnTransact.BeginTrans set xmlLiquidAccts = LiquidAcctsPayTypeMapping.CreateElement("LiquidAccts") for iLoop = 0 to PayTypeCount - 1 if Request.ServerVariables("request_method") = "GET" then PayFreq = RemoveHTML(request.querystring("PayFreq" & iLoop)) PayDesc = RemoveHTML(request.querystring("PayDesc" & iLoop)) NomCode = RemoveHTML(request.querystring("NomCode" & iLoop)) IsTaxable = RemoveHTML(request.querystring("IsTaxable" & iLoop)) IsNIable = RemoveHTML(request.querystring("IsNIable" & iLoop)) UsePayTypeID = RemoveHTML(request.querystring("UsePayTypeID" & iLoop)) Create = RemoveHTML(request.querystring("Create" & iLoop)) NewDesc = RemoveHTML(request.querystring("NewDesc" & iLoop)) Ignore = RemoveHTML(request.querystring("Ignore" & iLoop)) else PayFreq = RemoveHTML(request.form("PayFreq" & iLoop)) PayDesc = RemoveHTML(request.form("PayDesc" & iLoop)) NomCode = RemoveHTML(request.form("NomCode" & iLoop)) IsTaxable = RemoveHTML(request.form("IsTaxable" & iLoop)) IsNIable = RemoveHTML(request.form("IsNIable" & iLoop)) UsePayTypeID = RemoveHTML(request.form("UsePayTypeID" & iLoop)) Create = RemoveHTML(request.form("Create" & iLoop)) NewDesc = RemoveHTML(request.form("NewDesc" & iLoop)) Ignore = RemoveHTML(request.form("Ignore" & iLoop)) end if if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "PayDesc " & PayDesc & ", NomCode " & NomCode & ", UsePayTypeID " & UsePayTypeID & ", Create " & Create & ", Ignore " & Ignore end if if Ignore <> "ON" and Create = "ON" then sql = "SELECT Nominal_Code_ID FROM " & DBSchema & "Nominal_Codes WHERE Employer_ID = " & EmployerID sql = sql & " AND Nominal_Code = '" & NomCode &"'" set rsNomCodeID = OpenRecordset(objConn, sql) if rsNomCodeID.EOF then if not rsNominal.BOF then rsNominal.movefirst end if DisplayName = NomCode do while not rsNominal.EOF if rsNominal.Field("NL_Code") = NomCode and "" & rsNominal.Field("NL_Description") <> "" then DisplayName = rsNominal.Field("NL_Description") exit do end if rsNominal.movenext loop sql = "INSERT INTO " & DBSchema & "Nominal_Codes (Employer_ID, Nominal_Code, Display_Name, Entry_per_Employee, " sql = sql & "Balance_Sheet_Item, Bank_Account, Orig_Nom_Code_ID, EnteredBy) VALUES (" & EmployerID & ", '" sql = sql & ConvertQuoteChars(NomCode) & "', '" & ConvertQuoteChars(DisplayName) & "', 0, " if cInt(rsNominal.Field("NL_Acct_Order")) >= iBalShtGrp then sql = sql & "-1, " else sql = sql & "0, " end if sql = sql & "0, -1, " & GetSessionVar("UserID") & ")" ExecuteSQL objConnTransact, sql rsNomCodeID.close sql = "SELECT Nominal_Code_ID FROM " & DBSchema & "Nominal_Codes WHERE Employer_ID = " & EmployerID sql = sql & " AND Nominal_Code = '" & NomCode &"'" set rsNomCodeID = OpenRecordset(objConnTransact, sql) NomCodeID = rsNomCodeID("Nominal_Code_ID") else NomCodeID = rsNomCodeID("Nominal_Code_ID") end if rsNomCodeID.close sql = "SELECT Pay_Type_ID FROM " & DBSchema & "Pay_Types WHERE Employer_ID = " & EmployerID sql = sql & " AND Earning_or_Deduction = 'E' AND Display_Name = '" & ConvertQuoteChars(NewDesc) ' TJS 08/04/15 sql = sql & "' AND Payroll_Cost_Nominal = " & NomCodeID & " AND Pay_Due_Nominal = " & PayDueNomCodeID ' TJS 08/04/15 sql = sql & " AND EnteredBy = " & GetSessionVar("UserID") & " AND Deleted = 0" ' TJS 18/12/15 set rsCheckPayType = OpenRecordset(objConnTransact, sql) if rsCheckPayType.EOF then sql = "INSERT INTO " & DBSchema & "Pay_Types (Employer_ID, Earning_or_Deduction, Display_Name, Sort_Order, " sql = sql & "Exclude_Payroll_Freq, Include_NIC_Letter, Quantity, Rate, Calculated_Pay_Item, Subject_to_PAYE, " sql = sql & "Subject_to_NIC_Emplee, Subject_to_NIC_Empler, Subject_to_Pension, Counts_for_Auto_Enrolment, " sql = sql & "Attachable, Adjust_for_Sickness, Accrue_For_Holiday_Pay, Holiday_Accrual_Rate, Include_In_Analysis, " sql = sql & "Analysis_Group, Payroll_Cost_Nominal, Pay_Due_Nominal, EnteredBy) VALUES (" & EmployerID & ", 'E', " sql = sql & "'" & ConvertQuoteChars(NewDesc) & "', 1, '::', '::', 0, 0, 0, " ' TJS 08/04/15 if cBool(IsTaxable) then sql = sql & "-1, " else sql = sql & "0, " end if if cBool(IsNIable) then sql = sql & "-1, -1, " else sql = sql & "0, 0, " end if sql = sql & "-1, -1, -1, 0, 0, 0, 0, ''" & ", " & NomCodeID & ", " & PayDueNomCodeID & ", " & GetSessionVar("UserID") & ")" ExecuteSQL objConnTransact, sql sql = "SELECT Pay_Type_ID FROM " & DBSchema & "Pay_Types WHERE Employer_ID = " & EmployerID sql = sql & " AND Earning_or_Deduction = 'E' AND Display_Name = '" & ConvertQuoteChars(NewDesc) ' TJS 14/04/15 sql = sql & "' AND EnteredBy = " & GetSessionVar("UserID") & " AND Deleted = 0" ' TJS 18/12/15 set rsPayTypeID = OpenRecordset(objConnTransact, sql) UsePayTypeID = rsPayTypeID("Pay_Type_ID") rsPayTypeID.close set rsPayTypeID = nothing else UsePayTypeID = rsCheckPayType("Pay_Type_ID") rsCheckPayType.close set rsCheckPayType = nothing end if Create = "" end if set xmlAmount = LiquidAcctsPayTypeMapping.CreateElement("PayAmount") xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "PayFrequency", ConvertForXML(PayFreq)) xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "Description", ConvertForXML(PayDesc)) xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "NominalCode", ConvertForXML(NomCode)) if cBool(IsTaxable) then xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "IsTaxable", "Yes") else xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "IsTaxable", "No") end if if cBool(IsNIable) then xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "IsNIable", "Yes") else xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "IsNIable", "No") end if xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "PayTypeIDToUse", ConvertForXML(UsePayTypeID)) if Create = "ON" then xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "CreateNew", "Yes") xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "NewDescription", ConvertForXML(NewDesc)) else xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "CreateNew", "No") end if if Ignore = "ON" then xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "Ignore", "Yes") else xmlAmount.AppendChild Add_Node(LiquidAcctsPayTypeMapping, "Ignore", "No") end if xmlLiquidAccts.AppendChild xmlAmount next LiquidAcctsPayTypeMapping.AppendChild xmlLiquidAccts if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Updated Pay Type Mapping " & LiquidAcctsPayTypeMapping.xml end if sql = "UPDATE " & DBSchema & "Liquid_Accounts_Integration SET Liquid_Accts_Pay_Type_Mapping = COMPRESS(?) " sql = sql & "WHERE Employer_ID = " & EmployerID & " AND Deleted = 0" ' TJS 19/05/18 ExecuteSQLWithParam objConnTransact, sql, LiquidAcctsPayTypeMapping.xml objConnTransact.CommitTrans objConnTransact.close set objConnTransact = nothing ' refresh pay type mapping XML set XMLPayTypeMappings = LiquidAcctsPayTypeMapping.selectNodes("LiquidAccts/PayAmount") ' TJS 26/04/15 set xmlAmount = nothing set rsNomCode = nothing else SendErrorEmail "LiquidAccts", "Liquid Accounts API did not return any data - " & sql, "" ' TJS 15/01/18 TJS 25/08/21 end if else SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 end if else SendErrorEmail "LiquidAccts", "Liquid Accounts API did not return any data - " & sql, "" ' TJS 15/01/18 TJS 25/08/21 end if else SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 end if end if else SendErrorEmail "LiquidAccts", "Liquid Accounts API did not return any data - " & sql, "" ' TJS 15/01/18 TJS 25/08/21 end if else SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 end if if "" & MappingConfirmed = "Yes" then set rsPayFreq = new LiquidAcctsRecordset sql = "SELECT Ee_Pay_frequency FROM employee GROUP BY Ee_Pay_frequency" if rsPayFreq.LoadData(sql) then bValidationErrors = false iValidatedCount = 0 response.write "Validating employees
" response.flush if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Validating employees" end if do while not rsPayFreq.EOF if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Processing Pay Frequency " & rsPayFreq.Field("Ee_Pay_frequency") ' TJS 26/04/15 end if sql = "SELECT * FROM employee WHERE Ee_Pay_frequency = '" & rsPayFreq.Field("Ee_Pay_frequency") sql = sql & "' AND ISNULL(Ee_Old_Code,'') = '' ORDER BY Ee_Code" set rsEmployee = new LiquidAcctsRecordset if not rsEmployee.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if sql = "SELECT Payroll_ID, Tax_Year FROM " & DBSchema & "Payrolls WHERE Employer_ID = " & EmployerID select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & " AND Payroll_Type = 'W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & " AND Payroll_Type = 'B'" ' DC 14/04/15 case "Four Weekly" sql = sql & " AND Payroll_Type = 'F'" ' DC 14/04/15 ' end of code added TJS 14/04/15 case "Monthly" sql = sql & " AND Payroll_Type = 'M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & " AND Payroll_Type = 'A'" ' DC 14/04/15 ' end of code added TJS 14/04/15 end select set rsPayroll = OpenRecordset(objConn, sql) ' start of code added TJS 26/04/15 if rsPayroll.EOF then SendErrorEmail "LiquidAccts", "No payroll found for Pay Frequency " & rsPayFreq.Field("Ee_Pay_frequency") & sql, "" ' TJS 27/10/17 exit do end if ' end of code added TJS 26/04/15 do while not rsEmployee.EOF if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Processing Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " - Pay Ref " & rsEmployee.Field("Ee_Code") ' TJS 26/04/15 end if sql = "SELECT * FROM payamount WHERE Ee_Code = '" & rsEmployee.Field("Ee_Code") & "' AND Ee_Pay_Time >= 0" ' TJS 26/03/15 set rsCheckPay = new LiquidAcctsRecordset if not rsCheckPay.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsCheckPay.EOF then if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Checking not already imported" ' TJS 26/04/15 end if sql = "SELECT Employee_ID FROM " & DBSchema & "Employees WHERE Employer_ID = " & EmployerID sql = sql & " AND Payroll_Ref = '" & EncryptDataForDB("" & rsEmployee.Field("Ee_Code")) & "' AND Deleted = 0" set rsCheckEmployee = OpenRecordset(objConn, sql) if rsCheckEmployee.EOF then if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Building validation XML" ' TJS 26/04/15 end if strXML = BuildEmployeeXML("ValidateEmployee", EncryptData(rsPayroll("Payroll_ID")), strMarkAsValidated) ' TJS 21/03/15 set XMLSubmit = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") ' TJS 27/06/18 XMLSubmit.open "POST", "https://" & request.servervariables("SERVER_NAME") & "/Secure/AcctLink/ValidateEmployee.asp", False, "", "" XMLSubmit.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" XMLSubmit.setRequestHeader "Content-Length", len(strXML) on error resume next XMLSubmit.Send strXML ' did the post work ? if err.number = 0 then ' yes, did we get any response ? on error goto 0 if "" & XMLSubmit.ResponseText <> "" then set XMLResponse = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0") XMLResponse.PreserveWhitespace = True XMLResponse.validateOnParse = True XMLResponse.LoadXML XMLSubmit.ResponseText ' was response a success message ? if not XMLResponse.selectSingleNode("MyPAYELink/Status") is nothing then sStatus = XMLResponse.selectSingleNode("MyPAYELink/Status").Text if sStatus = "OK" then bIncludeNICChange1 = false bIncludeNICChange2 = false ' TJS 14/04/15 bIncludeNICChange3 = false if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Getting YTD values" ' TJS 26/04/15 end if sql = "SELECT ISNULL(SUM(ISNULL(P11_TaxableGross, 0)), 0) AS GrossTaxableEarnings, ISNULL(SUM(ISNULL(P11_Tax, 0)), 0) " sql = sql & "AS TaxDeducted, ISNULL(SUM(ISNULL(P11_SLD, 0)), 0) AS StudentLoan, ISNULL(SUM(ISNULL(P11_SSP, 0)), 0) AS SSP, " sql = sql & "ISNULL(SUM(ISNULL(P11_SMP, 0)), 0) AS SMPPaid, CAST(0 AS money) AS SMPRecov, CAST(0 AS money) AS SMPNIComp, " sql = sql & "ISNULL(SUM(ISNULL(P11_SPP, 0)), 0) AS OSPPPaid, CAST(0 AS money) AS OSPPRecov, CAST(0 AS money) AS OSPPNIComp, " sql = sql & "CAST(0 AS money) AS ASPPPaid, CAST(0 AS money) AS ASPPRecov, CAST(0 AS money) AS ASPPNIComp, " sql = sql & "ISNULL(SUM(ISNULL(P11_SPP, 0)), 0) AS SAPPaid, CAST(0 AS money) AS SAPRecov, CAST(0 AS money) AS SAPNIComp " sql = sql & "FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") & "' AND P11_Year = '" sql = sql & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select set rsP11Values = new LiquidAcctsRecordset if not rsP11Values.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11Values.EOF then sql = "SELECT '" & rsEmployee.Field("Ee_NI_Table") & "' AS NICLetter, ISNULL(SUM(ISNULL(P11_Std_NI, 0)), 0) AS EarningsForNI, " sql = sql & "ISNULL(SUM(ISNULL(LEL, 0)), 0) AS AtLEL, ISNULL(SUM(ISNULL(ET, 0)), 0) AS LELToPT, ISNULL(SUM(ISNULL(UAP, 0)), 0) " sql = sql & "AS PTToUAP, ISNULL(SUM(ISNULL(UEL, 0)), 0) AS UAPToUEL, ISNULL(SUM(ISNULL(P11_Ee_NI, 0)), 0) AS NICEmployee, " sql = sql & "ISNULL(SUM(ISNULL(P11_Er_NI, 0)), 0) AS NICEmployer FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") sql = sql & "' AND P11_Year = '" & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select sql = sql & " AND P11_NI_Code = '" & rsEmployee.Field("Ee_NI_Table") & "'" set rsP11NIValues = new LiquidAcctsRecordset if not rsP11NIValues.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues.EOF then sql = "SELECT P11_NI_Code FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") & "' AND P11_Year = '" sql = sql & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select sql = sql & " AND P11_NI_Code <> '" & rsEmployee.Field("Ee_NI_Table") & "'" set rsNISecLetters = new LiquidAcctsRecordset if not rsNISecLetters.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if do while not rsNISecLetters.EOF sql = "SELECT '" & rsNISecLetters.Field("P11_NI_Code") & "' AS NICLetter, ISNULL(SUM(ISNULL(P11_Std_NI, 0)), 0) AS EarningsForNI, " sql = sql & "ISNULL(SUM(ISNULL(LEL, 0)), 0) AS AtLEL, ISNULL(SUM(ISNULL(ET, 0)), 0) AS LELToPT, ISNULL(SUM(ISNULL(UAP, 0)), 0) " sql = sql & "AS PTToUAP, ISNULL(SUM(ISNULL(UEL, 0)), 0) AS UAPToUEL, ISNULL(SUM(ISNULL(P11_Ee_NI, 0)), 0) AS NICEmployee, " sql = sql & "ISNULL(SUM(ISNULL(P11_Er_NI, 0)), 0) AS NICEmployer FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") sql = sql & "' AND P11_Year = '" & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select sql = sql & " AND P11_NI_Code = '" & rsNISecLetters.Field("P11_NI_Code") & "'" if not bIncludeNICChange1 then set rsP11NIValues2 = new LiquidAcctsRecordset if not rsP11NIValues2.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues2.EOF then bIncludeNICChange1 = true end if elseif not bIncludeNICChanges2 then set rsP11NIValues3 = new LiquidAcctsRecordset if not rsP11NIValues3.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues3.EOF then bIncludeNICChange2 = true end if elseif not bIncludeNICChanges3 then set rsP11NIValues4 = new LiquidAcctsRecordset if not rsP11NIValues4.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues4.EOF then bIncludeNICChange3 = true end if else SendErrorEmail "LiquidAccts", "More than 4 NI Letters for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname"), "" ' TJS 27/10/17 exit do end if rsNISecLetters.movenext loop if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Building YTD validation XML" ' TJS 26/04/15 end if ' need dummy EmployeeID so use PayrollID for validation strXML = BuildEmployeeYTDXML("ValidateEmployeeYTD", EncryptData(rsPayroll("Payroll_ID")), EncryptData(rsPayroll("Payroll_ID"))) set XMLSubmit = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") ' TJS 27/06/18 XMLSubmit.open "POST", "https://" & request.servervariables("SERVER_NAME") & "/Secure/AcctLink/ValidateEmployeeYTD.asp", False, "", "" XMLSubmit.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" XMLSubmit.setRequestHeader "Content-Length", len(strXML) on error resume next XMLSubmit.Send strXML ' did the post work ? if err.number = 0 then ' yes, did we get any response ? on error goto 0 if "" & XMLSubmit.ResponseText <> "" then set XMLResponse = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0") XMLResponse.PreserveWhitespace = True XMLResponse.validateOnParse = True XMLResponse.LoadXML XMLSubmit.ResponseText ' was response a success message ? if not XMLResponse.selectSingleNode("MyPAYELink/Status") is nothing then sStatus = XMLResponse.selectSingleNode("MyPAYELink/Status").Text if sStatus = "OK" then iValidatedCount = iValidatedCount + 1 elseif sStatus = "Error" then Set XMLErrors = XMLResponse.selectNodes("MyPAYELink/Error") ' was list of XML Error nodes found ? if not XMLErrors is nothing then ' extract each Error in turn and use to populate arrays strErrorMessage = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " Year to Date figures - " for each XMLError in XMLErrors if strErrorMessage <> "" then strErrorMessage = strErrorMessage & ", " end if strErrorMessage = strErrorMessage & XMLError.selectSingleNode("Field").Text & " - " & XMLError.selectSingleNode("Details").Text next response.write strErrorMessage & "
" response.flush if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine strErrorMessage end if bValidationErrors = true else strErrorMessage = "Unknown error whilst validating YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected status (" & sStatus & ") returned whilst validating YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected response received whilst validating YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." if cBool(GetSessionVar("AllowDebug")) then set objFSO = CreateObject("Scripting.FileSystemObject") sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_Sent.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write strXML objXMLFile.close sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_SentResponse.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write XMLSubmit.ResponseText objXMLFile.close Set objXMLFile = nothing set objFSO = nothing end if SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "No response receiving whilst validating YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Error occured whilst validating YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Error " & err.number & "- " & err.description, "" ' TJS 27/10/17 exit do end if else iValidatedCount = iValidatedCount + 1 end if end if elseif sStatus = "Error" then Set XMLErrors = XMLResponse.selectNodes("MyPAYELink/Error") ' was list of XML Error nodes found ? if not XMLErrors is nothing then ' extract each Error in turn and use to populate arrays strErrorMessage = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " :- " for each XMLError in XMLErrors if strErrorMessage <> "" then strErrorMessage = strErrorMessage & ", " end if strErrorMessage = strErrorMessage & XMLError.selectSingleNode("Field").Text & " - " & XMLError.selectSingleNode("Details").Text next response.write strErrorMessage & "
" response.flush if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine strErrorMessage end if bValidationErrors = true else strErrorMessage = "Unknown error whilst validating Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected status (" & sStatus & ") returned whilst validating Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected response received whilst validating Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." if cBool(GetSessionVar("AllowDebug")) then set objFSO = CreateObject("Scripting.FileSystemObject") sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_Sent.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write strXML objXMLFile.close sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_SentResponse.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write XMLSubmit.ResponseText objXMLFile.close Set objXMLFile = nothing set objFSO = nothing end if SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "No response receiving whilst validating Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Error occured whilst validating Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Error " & err.number & "- " & err.description, "" ' TJS 27/10/17 exit do end if else sTemp = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " skipped as Payroll Ref already exists" response.write sTemp & "
" response.flush if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine sTemp end if end if rsCheckEmployee.close end if rsCheckPay.close rsEmployee.movenext loop rsPayroll.close rsEmployee.close rsPayFreq.movenext loop if not bValidationErrors then response.write "Importing employees
" response.flush if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Importing employees" end if if not rsPayFreq.BOF then rsPayFreq.movefirst if cBool(GetSessionVar("AllowDebug")) then ' TJS 14/04/15 objLogFile.WriteLine "rsPayFreq.BOF = " & rsPayFreq.BOF & ", rsPayFreq.EOF = " & rsPayFreq.EOF & " after movefirst" ' TJS 14/04/15 objLogFile.WriteLine "Pay Frequency " & rsPayFreq.Field("Ee_Pay_frequency") end if end if iImportedCount = 0 do while not rsPayFreq.EOF if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Processing Pay Frequency " & rsPayFreq.Field("Ee_Pay_frequency") ' TJS 26/04/15 end if sql = "SELECT * FROM employee WHERE Ee_Pay_frequency = '" & rsPayFreq.Field("Ee_Pay_frequency") sql = sql & "' AND ISNULL(Ee_Old_Code,'') = '' ORDER BY Ee_Code" ' TJS 14/04/15 set rsEmployee = new LiquidAcctsRecordset if not rsEmployee.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if sql = "SELECT Payroll_ID, Tax_Year FROM " & DBSchema & "Payrolls WHERE Employer_ID = " & EmployerID select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & " AND Payroll_Type = 'W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & " AND Payroll_Type = 'B'" ' TJS 14/04/15 case "Four Weekly" sql = sql & " AND Payroll_Type = 'F'" ' TJS 14/04/15 ' end of code added TJS 14/04/15 case "Monthly" sql = sql & " AND Payroll_Type = 'M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & " AND Payroll_Type = 'A'" ' TJS 14/04/15 ' end of code added TJS 14/04/15 end select set rsPayroll = OpenRecordset(objConn, sql) if cBool(GetSessionVar("AllowDebug")) then ' TJS 14/04/15 objLogFile.WriteLine "rsEmployee.BOF = " & rsEmployee.BOF & ", rsEmployee.EOF = " & rsEmployee.EOF & " for pay frequency " & rsPayFreq.Field("Ee_Pay_frequency") ' TJS 14/04/15 end if do while not rsEmployee.EOF if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Processing Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " - Pay Ref " & rsEmployee.Field("Ee_Code") ' TJS 26/04/15 end if sql = "SELECT * FROM payamount WHERE Ee_Code = '" & rsEmployee.Field("Ee_Code") & "' AND Ee_Pay_Time >= 0" ' TJS 26/03/15 set rsCheckPay = new LiquidAcctsRecordset if not rsCheckPay.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsCheckPay.EOF then if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Checking not already imported" ' TJS 26/04/15 end if sql = "SELECT Employee_ID FROM " & DBSchema & "Employees WHERE Employer_ID = " & EmployerID sql = sql & " AND Payroll_Ref = '" & EncryptDataForDB("" & rsEmployee.Field("Ee_Code")) & "' AND Deleted = 0" set rsCheckEmployee = OpenRecordset(objConn, sql) if rsCheckEmployee.EOF then if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Building import XML" ' TJS 26/04/15 end if strXML = BuildEmployeeXML("AddPayrollEmployee", EncryptData(rsPayroll("Payroll_ID")), strMarkAsValidated) ' TJS 21/03/15 if strMarkAsValidated <> "Yes" then ' TJS 21/03/15 response.write "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " requires validating through the New Employee Wizard to resolve missing data.
" ' TJS 21/03/15 if cBool(GetSessionVar("AllowDebug")) then ' TJS 14/04/15 objLogFile.WriteLine "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " requires validating through the New Employee Wizard to resolve missing data.
" ' TJS 14/04/15 end if end if set XMLSubmit = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") ' TJS 27/06/18 XMLSubmit.open "POST", "https://" & request.servervariables("SERVER_NAME") & "/Secure/AcctLink/AddUpdateEmployee.asp", False, "", "" XMLSubmit.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" XMLSubmit.setRequestHeader "Content-Length", len(strXML) on error resume next XMLSubmit.Send strXML ' did the post work ? if err.number = 0 then ' yes, did we get any response ? on error goto 0 if "" & XMLSubmit.ResponseText <> "" then set XMLResponse = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0") XMLResponse.PreserveWhitespace = True XMLResponse.validateOnParse = True XMLResponse.LoadXML XMLSubmit.ResponseText ' was response a success message ? if not XMLResponse.selectSingleNode("MyPAYELink/Status") is nothing then sStatus = XMLResponse.selectSingleNode("MyPAYELink/Status").Text if sStatus = "OK" then EmployeeLinkID = XMLResponse.selectSingleNode("MyPAYELink/EmployeeID").Text if cBool(GetSessionVar("AllowDebug")) then ' TJS 14/04/15 objLogFile.WriteLine "Imported Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " as " & EmployeeLinkID ' TJS 14/04/15 end if bIncludeNICChange1 = false bIncludeNICChange2 = false bIncludeNICChange3 = false if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Getting YTD values" ' TJS 26/04/15 end if sql = "SELECT ISNULL(SUM(ISNULL(P11_TaxableGross, 0)), 0) AS GrossTaxableEarnings, ISNULL(SUM(ISNULL(P11_Tax, 0)), 0) " sql = sql & "AS TaxDeducted, ISNULL(SUM(ISNULL(P11_SLD, 0)), 0) AS StudentLoan, ISNULL(SUM(ISNULL(P11_SSP, 0)), 0) AS SSP, " sql = sql & "ISNULL(SUM(ISNULL(P11_SMP, 0)), 0) AS SMPPaid, CAST(0 AS money) AS SMPRecov, CAST(0 AS money) AS SMPNIComp, " sql = sql & "ISNULL(SUM(ISNULL(P11_SPP, 0)), 0) AS OSPPPaid, CAST(0 AS money) AS OSPPRecov, CAST(0 AS money) AS OSPPNIComp, " sql = sql & "CAST(0 AS money) AS ASPPPaid, CAST(0 AS money) AS ASPPRecov, CAST(0 AS money) AS ASPPNIComp, " sql = sql & "ISNULL(SUM(ISNULL(P11_SPP, 0)), 0) AS SAPPaid, CAST(0 AS money) AS SAPRecov, CAST(0 AS money) AS SAPNIComp " sql = sql & "FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") & "' AND P11_Year = '" sql = sql & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select set rsP11Values = new LiquidAcctsRecordset if not rsP11Values.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11Values.EOF then sql = "SELECT '" & rsEmployee.Field("Ee_NI_Table") & "' AS NICLetter, ISNULL(SUM(ISNULL(P11_Std_NI, 0)), 0) AS EarningsForNI, " sql = sql & "ISNULL(SUM(ISNULL(LEL, 0)), 0) AS AtLEL, ISNULL(SUM(ISNULL(ET, 0)), 0) AS LELToPT, ISNULL(SUM(ISNULL(UAP, 0)), 0) " sql = sql & "AS PTToUAP, ISNULL(SUM(ISNULL(UEL, 0)), 0) AS UAPToUEL, ISNULL(SUM(ISNULL(P11_Ee_NI, 0)), 0) AS NICEmployee, " sql = sql & "ISNULL(SUM(ISNULL(P11_Er_NI, 0)), 0) AS NICEmployer FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") sql = sql & "' AND P11_Year = '" & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select sql = sql & " AND P11_NI_Code = '" & rsEmployee.Field("Ee_NI_Table") & "'" set rsP11NIValues = new LiquidAcctsRecordset if not rsP11NIValues.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues.EOF then sql = "SELECT P11_NI_Code FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") & "' AND P11_Year = '" sql = sql & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select sql = sql & " AND P11_NI_Code <> '" & rsEmployee.Field("Ee_NI_Table") & "'" set rsNISecLetters = new LiquidAcctsRecordset if not rsNISecLetters.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if do while not rsNISecLetters.EOF sql = "SELECT '" & rsNISecLetters.Field("P11_NI_Code") & "' AS NICLetter, ISNULL(SUM(ISNULL(P11_Std_NI, 0)), 0) AS EarningsForNI, " sql = sql & "ISNULL(SUM(ISNULL(LEL, 0)), 0) AS AtLEL, ISNULL(SUM(ISNULL(ET, 0)), 0) AS LELToPT, ISNULL(SUM(ISNULL(UAP, 0)), 0) " sql = sql & "AS PTToUAP, ISNULL(SUM(ISNULL(UEL, 0)), 0) AS UAPToUEL, ISNULL(SUM(ISNULL(P11_Ee_NI, 0)), 0) AS NICEmployee, " sql = sql & "ISNULL(SUM(ISNULL(P11_Er_NI, 0)), 0) AS NICEmployer FROM p11 WHERE P11_Employee = '" & rsEmployee.Field("Ee_Code") sql = sql & "' AND P11_Year = '" & rsPayroll("Tax_Year") & "/" & right(rsPayroll("Tax_Year") + 1, 2) & "' AND P11_Month_Week = '" select case rsPayFreq.Field("Ee_Pay_frequency") case "Weekly" sql = sql & "W'" ' start of code added TJS 14/04/15 case "Two Weekly" sql = sql & "B'" case "Four Weekly" sql = sql & "F'" ' end of code added TJS 14/04/15 case "Monthly" sql = sql & "M'" ' start of code added TJS 14/04/15 case "Annual" sql = sql & "A'" ' end of code added TJS 14/04/15 end select sql = sql & " AND P11_NI_Code = '" & rsNISecLetters.Field("P11_NI_Code") & "'" if not bIncludeNICChange1 then set rsP11NIValues2 = new LiquidAcctsRecordset if not rsP11NIValues2.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues2.EOF then bIncludeNICChange1 = true end if elseif not bIncludeNICChanges2 then set rsP11NIValues3 = new LiquidAcctsRecordset if not rsP11NIValues3.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues3.EOF then bIncludeNICChange2 = true end if elseif not bIncludeNICChanges3 then set rsP11NIValues4 = new LiquidAcctsRecordset if not rsP11NIValues4.LoadData(sql) then SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 exit do end if if not rsP11NIValues4.EOF then bIncludeNICChange3 = true end if else SendErrorEmail "LiquidAccts", "More than 4 NI Letters for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname"), "" ' TJS 27/10/17 exit do end if rsNISecLetters.movenext loop if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Building YTD import XML" ' TJS 26/04/15 end if strXML = BuildEmployeeYTDXML("AddEmployeeInitialYTD", EncryptData(rsPayroll("Payroll_ID")), EmployeeLinkID) set XMLSubmit = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") ' TJS 27/06/18 XMLSubmit.open "POST", "https://" & request.servervariables("SERVER_NAME") & "/Secure/AcctLink/AddUpdateEmplInitialYTD.asp", False, "", "" XMLSubmit.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" XMLSubmit.setRequestHeader "Content-Length", len(strXML) on error resume next XMLSubmit.Send strXML ' did the post work ? if err.number = 0 then ' yes, did we get any response ? on error goto 0 if "" & XMLSubmit.ResponseText <> "" then set XMLResponse = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0") XMLResponse.PreserveWhitespace = True XMLResponse.validateOnParse = True XMLResponse.LoadXML XMLSubmit.ResponseText ' was response a success message ? if not XMLResponse.selectSingleNode("MyPAYELink/Status") is nothing then sStatus = XMLResponse.selectSingleNode("MyPAYELink/Status").Text if sStatus = "OK" then ' yes if cBool(GetSessionVar("AllowDebug")) then ' TJS 14/04/15 objLogFile.WriteLine "Imported Employee YTD " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " as " & EmployeeLinkID ' TJS 14/04/15 end if ' now add Pay Items iPayItemCount = 0 if cBool(GetSessionVar("AllowDebug")) then ' TJS 26/04/15 objLogFile.WriteLine "Building Pay Item XML" ' TJS 26/04/15 end if strXML = BuildPayItemsXML(EncryptData(rsPayroll("Payroll_ID")), EmployeeLinkID, iPayItemCount) if iPayItemCount > 0 then set XMLSubmit = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") ' TJS 27/06/18 XMLSubmit.open "POST", "https://" & request.servervariables("SERVER_NAME") & "/Secure/AcctLink/AddPayItems.asp", False, "", "" XMLSubmit.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" XMLSubmit.setRequestHeader "Content-Length", len(strXML) on error resume next XMLSubmit.Send strXML ' did the post work ? if err.number = 0 then ' yes, did we get any response ? on error goto 0 if "" & XMLSubmit.ResponseText <> "" then set XMLResponse = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0") XMLResponse.PreserveWhitespace = True XMLResponse.validateOnParse = True XMLResponse.LoadXML XMLSubmit.ResponseText ' was response a success message ? if not XMLResponse.selectSingleNode("MyPAYELink/Status") is nothing then sStatus = XMLResponse.selectSingleNode("MyPAYELink/Status").Text if sStatus = "OK" then iImportedCount = iImportedCount + 1 if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Imported Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " with Year to Date figures and Pay Items" end if elseif sStatus = "Error" then Set XMLErrors = XMLResponse.selectNodes("MyPAYELink/Error") ' was list of XML Error nodes found ? if not XMLErrors is nothing then ' extract each Error in turn and use to populate arrays strErrorMessage = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " Pay Items - " for each XMLError in XMLErrors if strErrorMessage <> "" then strErrorMessage = strErrorMessage & ", " end if strErrorMessage = strErrorMessage & XMLError.selectSingleNode("Field").Text & " - " & XMLError.selectSingleNode("Details").Text next response.write strErrorMessage & "
" response.flush if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine strErrorMessage end if bValidationErrors = true else strErrorMessage = "Unknown error whilst adding Pay Items for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected status (" & sStatus & ") returned whilst adding Pay Items for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected response received whilst adding Pay Items for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." if cBool(GetSessionVar("AllowDebug")) then set objFSO = CreateObject("Scripting.FileSystemObject") sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_Sent.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write strXML objXMLFile.close sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_SentResponse.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write XMLSubmit.ResponseText objXMLFile.close Set objXMLFile = nothing set objFSO = nothing end if SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "No response receiving whilst adding Pay Items for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Error occured whilst adding Pay Items for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Error " & err.number & "- " & err.description, "" ' TJS 27/10/17 exit do end if else iImportedCount = iImportedCount + 1 if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Imported Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " with Year to Date figures, but no Pay Items found." end if end if elseif sStatus = "Error" then Set XMLErrors = XMLResponse.selectNodes("MyPAYELink/Error") ' was list of XML Error nodes found ? if not XMLErrors is nothing then ' extract each Error in turn and use to populate arrays strErrorMessage = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " Year to Date figures - " for each XMLError in XMLErrors if strErrorMessage <> "" then strErrorMessage = strErrorMessage & ", " end if strErrorMessage = strErrorMessage & XMLError.selectSingleNode("Field").Text & " - " & XMLError.selectSingleNode("Details").Text next response.write strErrorMessage & "
" response.flush bValidationErrors = true else strErrorMessage = "Unknown error whilst importing YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected status (" & sStatus & ") returned whilst importing YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected response received whilst importing YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." if cBool(GetSessionVar("AllowDebug")) then set objFSO = CreateObject("Scripting.FileSystemObject") sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_Sent.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write strXML objXMLFile.close sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_SentResponse.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write XMLSubmit.ResponseText objXMLFile.close Set objXMLFile = nothing set objFSO = nothing end if SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "No response receiving whilst importing YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Error occured whilst importing YTD for Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Error " & err.number & "- " & err.description, "" ' TJS 27/10/17 exit do end if else iImportedCount = iImportedCount + 1 if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine "Imported Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & ", but no Year to Date figures found" end if end if end if elseif sStatus = "Error" then iIncorrectRows = iIncorrectRows + 1 Set XMLErrors = XMLResponse.selectNodes("MyPAYELink/Error") ' was list of XML Error nodes found ? if not XMLErrors is nothing then ' extract each Error in turn and use to populate arrays strErrorMessage = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " - " for each XMLError in XMLErrors if strErrorMessage <> "" then strErrorMessage = strErrorMessage & ", " end if strErrorMessage = strErrorMessage & XMLError.selectSingleNode("Field").Text & " - " & XMLError.selectSingleNode("Details").Text next response.write strErrorMessage & "
" response.flush if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine strErrorMessage end if bValidationErrors = true else strErrorMessage = "Unknown error whilst importing Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected status (" & sStatus & ") returned whilst importing Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Unexpected response received whilst importing Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." if cBool(GetSessionVar("AllowDebug")) then set objFSO = CreateObject("Scripting.FileSystemObject") sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_Sent.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write strXML objXMLFile.close sXMLFileName = GetLogPath & "MyPAYE_Import_E" & EmployerID & "_" & replace(Date(), "/", "-") & "_SentResponse.xml" if objFSO.FileExists(sXMLFileName ) then Set objXMLFile = objFSO.OpenTextFile(sXMLFileName, 2) else Set objXMLFile = objFSO.CreateTextFile(sXMLFileName) end if objXMLFile.Write XMLSubmit.ResponseText objXMLFile.close Set objXMLFile = nothing set objFSO = nothing end if SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Response " & XMLSubmit.ResponseText, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "No response receiving whilst importing Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML, "" ' TJS 27/10/17 exit do end if else strErrorMessage = "Error occured whilst importing Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & "." SendErrorEmail "LiquidAccts", strErrorMessage & vbcrlf & vbcrlf & "Sent " & strXML & vbcrlf & vbcrlf & "Error " & err.number & "- " & err.description, "" ' TJS 27/10/17 exit do end if else sTemp = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " skipped as Payroll Ref already exists" if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine sTemp end if end if rsCheckEmployee.close else ' start of code added TJS 14/04/15 sTemp = "Employee " & rsEmployee.Field("Ee_FirstName") & " " & rsEmployee.Field("Ee_Surname") & " skipped as there are no pay amount records with a Pay Time value > 0" response.write sTemp if cBool(GetSessionVar("AllowDebug")) then objLogFile.WriteLine sTemp end if ' end of code added TJS 14/04/15 end if rsCheckPay.close rsEmployee.movenext loop rsEmployee.close rsPayroll.close rsPayFreq.movenext loop end if if not bValidationErrors then bImportComplete = true end if rsEmployee.close set rsEmployee = nothing else SendErrorEmail "LiquidAccts", "Failed to read from Liquid Accounts API - " & sql, "" ' TJS 27/10/17 end if if bImportComplete then sql = "UPDATE " & DBSchema & "Liquid_Accounts_Integration SET Liquid_Accts_Migration_Complete = -1 WHERE Employer_ID = " & EmployerID & " AND Deleted = 0" ' TJS 19/05/18 ExecuteSQL objConn, sql%>

<%=iImportedCount%> Employees have been imported successfully using the following assumptions :-

Please edit any Employees where the above assumptions are not valid.

Please also add any current SSP, SMP, SPP, SAP or Attachment of Earnings records to the relevant Employees as the data required to import these records is not available.

<%else%>

<%=iValidatedCount%> employees validated successfully, but the above errors need correcting and the import process repeated

<%end if%>

/Secure/EmployerIntegration.asp?ID=<%=SetPageSessionID(93840, DestFrame)%>&SV=<%=SessionVarsID%>&S=<%=DestFrame%>&D=<%=PopupWindow1%>&ER=<%=EmployerID%>','_self','',true);" >Close

<%end if else%>

You must set your Employer Nominal Codes before you can import your Employee data

/Secure/EmployerIntegration.asp?ID=<%=SetPageSessionID(93840, DestFrame)%>&SV=<%=SessionVarsID%>&S=<%=DestFrame%>&D=<%=PopupWindow1%>&ER=<%=EmployerID%>','_self','',true);" >Close

<%end if%>
<%if cBool(GetSessionVar("AllowDebug")) then objLogFile.close end if rsEmployer.close rsUser.close set rsEmployer = nothing set rsUser = nothing ReleaseASPEncrypt SaveSessionVarsRecord SessionVarsID rsAccountsLink.close set rsAccountsLink = nothing objConn.close set objConn = nothing %>