%
' MyPAYE
' Module: EmployerPensionSchemes.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.
'
' © 2012 - 2023 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 09 May 2023
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Description - This module display details of the Pension Schemes for an Employer
' and also allows them to be edited or a new Pension Schemes to be
' entered when called with the approriate value for AddNewEdit
' If AddNewEdit = "Edit", then the fields are unlocked, but populated
' with the existing data.
' If AddNewEdit = "Add", then the fields are unlocked and blank.
' If AddNewEdit is any other value, then the fields are locked.
' If AddNewEdit = "Edit" or "Add", an Update button is displayed.
'
' Amendment Log
'------------------------------------------------------------------------------------------
' Date | Name | Vers. | Description
'------------------------------------------------------------------------------------------
' 06/05/05 | TJS | 1.0 | Original
' 12/05/05 | TJS | 1.0.01 | Replaced onchange="datachanged()" with onkeydown="checkkeypress()"
' | on all Text fields to ensure Update/Cancel button change
' | occurs on first character changed rather than when the
' | onchange event fires on loss of focus
' | Changed tabs and Update/Close buttons from graphics to text panels
' | Replaced "Button" tabs with Classes and text
' | Also modified to make Close button show Cancel if update fails
' 16/05/05 | TJS | 1.0.04 | Modified to cater for different CSS files depending on the
' | Agency ID setting for the Employer via session variable PathModifier
' 18/05/05 | TJS | 1.0.05 | Added hidden fields PREE, IncPyTyp and UpdCoSch for compatibility
' | with EmployeePensionSchemes.asp
' 22/05/05 | TJS | 1.0.06 | Replaced numeric SessionID Frame references with
' | descriptive constant names for clarity
' 26/05/05 | IGW | 1.0.08 | Modified calls to Help pages to open window without address and tool bars
' 28/05/05 | TJS | 1.0.09 | Modified to prevent user clicking more than one button
' | at a time to prevent security violation errors
' 23/06/05 | TJS | 1.0.11 | Modified to initialise Help Topic ID, for Firefox compatibility
' | and modified record counts for MySQL
' 09/08/05 | TJS | 1.0.12 | Added response headers to prevent caching and
' | modified to use OpenRecordset and ExecuteSQL instead of
' | objConn.execute to enable trapping of SQL errors
' 19/10/05 | TJS | 1.0.15 | Corrected maximum length of Pension Scheme name
' 29/01/06 | TJS | 1.0.21 | Corrected error where Pension Scheme list box not shown once first pension scheme created
' 08/03/06 | TJS | 1.0.22 | Corrected Tab order and set focus to Scheme Name
' 28/05/06 | TJS | 1.0.28 | Modified to close DB connection on completion
' | and modified to include ICRA content rating link
' 25/07/06 | TJS | 1.0.33 | Modified name of PR checkbox to include a loop variable to
' | give unique names for WinRunner testing
' | Also changed frame name used for help window from PopupWindow1 to HelpWindow
' 22/10/06 | TJS | 1.0.35 | Changed parent.parent. to parent. and modified layout for compatibility with Frefox
' 19/06/07 | TJS | 1.2.00 | Modified to replace session variables with Session_Vars table
' 26/02/10 | TJS | 1.3.14 | Modified to excluded deleted Pension Schemes
' 08/10/10 | TJS | 1.4.03 | Modified to cater for separate Integration page
' 18/11/10 | TJS | 1.5.00 | Modified to use both root and agency CSS files when used to
' | eliminate duplicated settings in agency CSS files, plus
' | added label tags for field descriptions
' 13/12/10 | TJS | 1.5.01 | Modified to cater for Pay_Contrib_On_Parental_Pay
' 30/06/11 | TJS | 1.7.00 | Modified to use JS_Keys in session_vars table instead of session("GetEPSJS")
' 10/07/11 | TJS | 1.7.01 | REplaced JS_Keys with individual fields to stop occasional field overflow errors
' 17/01/12 | TJS ! 2.0.00 | Modified for CIS
' 24/04/12 | TJs | 2.0.03 | Modified for Commpany Salary Sacrifice Pensions
' 08/08/12 | TJS | 2.0.05 | Google Analytics added
' 01/06/14 | TJS | 4.0.00 | Modified for new styling and operation without framesets
' | plus pension Auto Enrolment
' 15/07/14 | TJS | 4.0.01 | Corrected closewindow checks on function in session vars and passed Employer Auto Enrol Format to AutoEnrolSet
' 06/08/14 | TJS | 4.0.01a | Modified to update Function in Session Vars if set to SelectEmpl or SelPayMthd
' | and remove onkeydown function if editing not allowed as it bypasses the
' | readonly property on default nominal codes
' 16/09/14 | TJS | 4.0.02 | Modified to use fieldset rather than nested tables for iPad compatibility
' | and to allow setting of Pension Code and Pension Due nominal codes for each scheme
' 25/09/14 | TJS | 4.0.03 | Corrected html validation errors and modified to tidy menu item disabling
' 05/10/14 | TJS | 4.0.04 | Modified for Encrypted Employer ID check
' 14/10/14 | TJS | 4.0.05 | Removed redundant script trying to set RowDetailArea on validation errors
' 30/10/14 | TJS | 4.0.05a | Modified to use POST when redisplaying from UpdatePensionScheme.asp and also
' | modified display of Alert Messages to cater for RemoveHTML changes
' 08/12/14 | TJS | 4.0.08 | Added Now and Generic AE to list of Auto Enrollment pensions and modified
' | to prevent changes to AE provider if set on Employer Options
' 28/01/15 | TJS | 4.0.10 | Prepared for Friendly Pensions and The Peoples Pension
' 18/02/15 | TJS | 4.0.11 | Added Standard Life Pensions and corrected help window name
' 13/03/15 | TJS | 4.0.12 | Modified for Liquid Accounts and Just Accounts
' 28/05/15 | TJS | 4.0.16 | Modified to hide Pension AE Import and Export options unless selected provider
' | supports function and to detect changes to default contributions on AE pensions
' 26/06/15 | TJS | 4.0.18a | Modified for Scottish Widows AE Pension
' 22/07/15 | TJS | 4.0.20a | Added missing parameters on call to CancelRegistration.asp needed to cater for Liquid Accounts registration
' 16/10/15 | TJS | 4.0.22 | Modified to send e-conomic app identifier
' 27/10/15 | DC | 4.0.22a| Added Legal & General and Aviva AE pension
' 03/11/15 | DC | 4.0.22a| Added NEST .csv AE option
' 26/11/15 | TJS | 5.0.00 | Modified to cater for separate User_Permissions table and added help icon for salary sacrifice NI contribution percentage
' 03/12/15 | TJS | 5.0.01 | Modified to cater for e-conomic now being Reviso in the UK
' 19/12/15 | TJS | 5.0.02 | Modified for Exact Online Integration
' 21/12/15 | DC | 5.0.02a| Added 'True Potential' pension.
' 05/01/15 | DC | 5.0.02b| Limited the width of Xero NL code data to not "break" the temp sort table.
' 06/02/16 | TJS | 5.0.03 | Ramaned ExtractAccountCodes as ExtractExactOnlineAcctCodes to avoid conflicts
' | with other integrationsand modified to cater for Smart Pension
' 14/03/16 | TJS | 5.0.04 | Modified to add NEST payment due after listbox, to cater for changed SmartPension global variable names,
' | to cater for NEST API interface and moved code to read Twinfield account code to TwinfieldAPIFunctions.asp as include file
' 04/04/16 | TJS | 5.0.06 | Modified to remove mandatory SCON logic
' 07/04/16 | TJS | 5.0.07 | Modified to cater for GetSmartPensionCompanies needing the Auto Enrolment Ref in order to
' | handle Smart Pension not allowing normal users to read the company list function
' 03/05/16 | TJS | 5.0.08 | Moved code to read KashFlow account code to KashFlowAPIFunctions.asp as include file
' 30/05/16 | TJS | 5.0.09 | Moved code to read Reviso and Xero account codes to RevisoAPIFunctions.asp and
' | XeroAPIFunctions.asp as include file with mod for Xero offline code
' 31/05/16 | TJS | 5.0.10 | Added Master Trust, Defined Contribution and Defined Benefit Scheme Types
' 12/06/16 | TJS | 5.0.10a | Corrected html validation errors
' 17/07/16 | TJS | 5.0.12 | Modified to prepare for PensionSync for Legal & General plus The Peoples Pension,
' | and to cater for multiple pensions on a payroll
' 28/07/16 | TJS | 5.0.13 | Modified to cater for IncludeMenu, SelectedMenuItem and JavascriptField parameters on GetXeroAccountCodes function
' 20/09/16 | DC | 5.0.13a| Allowed for slightly longer Liquid Accouts NL descriptions and truncated when inserting into temp sort.
' 17/10/16 | TJS | 5.0.14 | Modified to enable PensionSync for Legal & General plus The Peoples Pension
' | and enabled default employee salary sacrifice rate on salary sacrifice pensions
' 27/10/16 | TJS | 5.0.15 | Moved code to read Liquid account code to LiquidAccountsAPIFunctions.asp include file
' 08/11/16 | TJS | 5.0.16 | Modified to use AE Pension Provider ID constants
' 25/11/16 | TJS | 5.0.16a | Modified to display indicator whilst reading scheme details
' 24/01/17 | TJS | 5.0.17 | Modified for renaming of SmartPensionCompanySlugs array
' 08/04/17 | TJS | 5.0.19 | Added error handling for revised integrated accounts API functions
' 10/04/17 | TJS | 5.0.20 | Corrected Accounts Integration sent when API errors occur
' 12/04/17 | DC | 5.0.20a| Added Royal London pension provider.
' 08/08/17 | TJS | 5.1.06 | Modified to cater for employer AE options not being set when getting Smart Pension companies
' 13/08/17 | TJS | 5.1.06a | Modified to hide Pensin Sync SMT and Get Scheme Details button when creating new scheme
' 14/10/17 | TJS | 5.1.10 | Corrected conflict where PSID param was used for both PaySlipID and PenSchID on new employee wizard
' | and modified to cater for common pension API functions moving to CommonPensAPIFunctions.asp
' | Also modified for The Peoples Pension API
' 26/10/17 | TJS | 5.1.10a | Modified for Creative Pensions
' 15/11/17 | TJS | 5.1.11 | Modified for Zurich pensions
' 10/12/17 | TJS | 5.1.12 | Corrected enabling of Pension AE Ref 2 for multiple pensions
' 15/12/17 | TJS | 5.1.13 | Modified to cater for The Peoples Pension account selection
' 23/12/17 | TJS | 5.1.13 | Modified to cater for additional NEST payment due option and selection of NEST group for rates etc
' 05/01/18 | TJS | 5.1.14 | Modified to cater for Staging Date in Peoples Pension scheme details
' 23/01/18 | TJS | 5.1.16 | Modified to complete NEST Group selection, added SalvusPensionProviderID and modified to save AE Target Company when multi providers in use
' 21/02/18 | TJS | 5.1.19 | Added PayrollID to parameters for GetThePeoplesPensOAuthToken.asp
' 04/03/18 | TJS | 5.1.19a | Modified to cater for default rate changes from Get Scheme Details triggering DefaultChng() popup
' 13/03/18 | TJS | 5.1.19b | Added InclHdr to parameters for GetThePeoplesPensOAuthToken.asp
' 13.04/18 | TJs | 5.2.02 | Corrected enabling of AutoEnrolRef3 list box for NEST
' 17/04/18 | TJS | 5.2.03 | Modified to cater for MenuPayrollExists on MainMenu.asp
' 19/05/18 | TJS | 5.2.07 | Modified to cater for Deleted field on ExactOnline_Integration, JustAccounts_Integration, The_Peoples_Pension_Integration tables
' 10/06/18 | TJS | 5.3.00 | Modified call to GetXeroAccountCodes to cater for Xero Tracking Categories
' 15/06/18 | DC | 5.3.00a| Looked like some debug code had bee left in.
' 27/06/18 | TJS | 5.3.01 | Modified to use WinHTTP.WinHTTPRequest.5.1 instead of Msxml2.ServerXMLHTTP
' 27/07/18 | TJS | 5.3.04 | Peoples Pension API interface now fully enabled and CSV interface only available for existing users
' | Also changed Contributions paid Gross/Net from radio buttons to a list box to try and reduce user confusion
' 14/08/18 | TJS | 5.3.05 | Modified for Smart Pension OAuth2
' 05/09/18 | TJS | 5.4.00 | Modified to correct Smart Pension user authentication
' 20/09/18 | TJS | 5.4.02 | Modified to implement Smart_Pension_Login_Usage table for users with multiple Smart Pension Advisor logins
' 20/11/18 | TJS | 5.4.08 | Modified to cater for CIS_Paylists_In_Use field
' 21/01/19 | TJS | 5.4.14 | Modified to enable GetSchemeDetails to check scheme has been saved first
' 18/03/19 | TJS | 5.5.03 | Modified to only show Salary Related scheme type if already in use to prevent users selecting this type in future
' 03/04/19 | TJS | 5.5.06 | Corrected class setting on AutoEnrolRef2B
' 18/04/19 | TJS | 5.5.07 | Added note re multiple pensions linked to a payroll
' 11/07/19 | TJS | 5.5.12 | Modified to cater for EnterHoursHome.asp being renamed EmployeePortalHome.asp
' 27/12/19 | TJS | 5.7.03 | Corrected input to AEUndefinedOrMultiScheme when setting class on AutoEnrolRef and
' | modified to detect if Contributions Paid is set when adding new scheme and validation failure occurs
' 90/02/20 | TJS | 5.7.04 | Added SuperTrustPensionProviderID as pension provider but only if already set in database and modified to cater for Reviso REST API
' 07/04/20 | TJS | 5.7.08 | Modified to cater for Quickbooks Integration and corrected page titles etc for other integrations
' 23/04/20 | TJS | 5.7.09 | Modified to hide QuickBooks dummy codes and use AddNominalCodes function for listbox option generation
' 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
' 04/06/20 | TJS | 5.8.01 | Changed width of GroupRateSource and GetSchemeProgress spans to tiy layout
' 07/11/20 | TJS | 5.9.03 | Modified to enable reposting of unsupported Peoples Pension schemes
' 13/02/21 | TJS | 5.9.07 | Corrected missing space after GroupRateSource and setting of AETargetCo for users with access to Advisor logins
' 09/04/21 | TJS | 5.9.09 | Modified to use ASPDOTNET/LogOut.aspx and ASPDOTNET/AgencyCancel.aspx pages
' 13/06/21 | TJS | 5.9.10 | Modified to use ASPDOTNET/PayrollHome.aspx page
' 30/06/21 | TJS | 5.9.10a | Modified to cater for NextPage parameter on CheckAndRenewXeroAuth
' 31/08/21 | TJS | 5.9.11 | Corrected spelling of Liquid Accounts, plus modified to replace alert and confirm dialogues to cater for browser blocks on cross site dialogs
' 23/10/21 | TJS | 5.9.13 | Modified to cater for ASPDOTNET/EmployeePortalHome.aspx
' 04/01/22 | TJS | 5.9.15 | Modified to use ASPDotNet/CancelRegistration.aspx pages
' 16/02/22 | TJS | 5.9.16 | Modified to use ASPDotNet/UpdatePensionScheme.ashx page
' 26/01/23 | TJS | 5.9.21 | Added note re editing of global pension options where relevant
' 09/05/23 | TJS | 5.9.24 | Modified to use ASPDotNet/UpdateNominalCode.ashx page
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PageID = 83304
' since form is loaded using Post when displayed from UpdatePensionScheme.asp, need to check for this
if Request.ServerVariables("request_method") = "GET" then ' TJS 30/10/14
SessionID = request.querystring("ID")
SessionVarsID = RemoveHTML(request.querystring("SV")) ' TJS 19/06/07
SourceFrame = RemoveHTML(request.querystring("S"))
DestFrame = RemoveHTML(request.querystring("D"))
PensionSchemeID = CheckURLDBIDField(request.querystring("PenSchID"), "PensionSchemeID") ' TJS 14/10/17
EmployerID = CheckURLDBIDField(RemoveHTML(request.querystring("ER")), "EmployerID")
' start of code added TJS 30/10/14
else
SessionID = request.form("ID")
SessionVarsID = RemoveHTML(request.form("SV"))
SourceFrame = RemoveHTML(request.form("S"))
DestFrame = RemoveHTML(request.form("D"))
PensionSchemeID = CheckURLDBIDField(request.form("PenSchID"), "PensionSchemeID") ' TJS 14/10/17
EmployerID = CheckURLDBIDField(RemoveHTML(request.form("ER")), "EmployerID")
end if
' end of code added TJS 30/10/14
%>
<%GetSessionVarsIDRecord(SessionVarsID) ' TJS 19/06/07%>
<%' TJS 03/05/16%>
<%' TJS 14/03/16%>
<%' TJS 30/05/16%>
<%' TJS 07/04/20%>
<%' TJS 30/05/16%>
<%' TJS 06/02/16%>
<%' TJS 17/07/16%>
<%' TJS 08/11/16%>
<%' TJS 14/10/17%>
<%' since form is loaded using Post when displayed from UpdatePensionScheme.asp, need to check for this
if Request.ServerVariables("request_method") = "GET" then ' TJS 30/10/14
AddNewEdit = RemoveHTML(request.querystring("ANE"))
CancelPage = RemoveHTML(request.querystring("CPge"))
FailureFields = RemoveHTML(request.querystring("FFld"))
FailureMessage = RemoveHTML(request.querystring("FMsg"))
AlertMessage = RemoveHTML(request.querystring("AlMsg"))
' start of code added TJS 30/10/14
else
AddNewEdit = RemoveHTML(request.form("ANE"))
CancelPage = RemoveHTML(request.form("CPge"))
FailureFields = RemoveHTML(request.form("FFld"))
FailureMessage = RemoveHTML(request.form("FMsg"))
AlertMessage = RemoveHTML(request.form("AlMsg"))
AutoGetScheme = RemoveHTML(request.form("AGS")) ' TJS 27/07/18
end if
' end of code added TJS 30/10/14
Function GetDBField(FieldName, ControlName)
if FailureFields <> "" and (AddNewEdit = "Add" or AddNewEdit = "Edit") then
if ControlName = "ContractOut" or ControlName = "ContributionPaidGross" or _
ControlName = "LumpSumAVC" or ControlName = "PercentAVC" or _
ControlName = "ContribOnParentalPay" or ControlName = "AutoEnrolment" or _
ControlName = "AEExportBefore" or ControlName = "AEImportDedn" or _
ControlName = "AEPayBelowMin" or ControlName = "AEPayAboveMax" or _
ControlName = "UpdateDefaults" or ControlName = "AECertified" then ' TJS 13/12/10 TJS 01/06/14 TJS 28/05/15
if RemoveHTML(request.form(ControlName)) = "ON" then
GetDBField = -1
else
GetDBField = 0
end if
elseif FieldName = "Enable_CIS" then ' TJS 01/06/14
GetDBField = rsEmployer(FieldName) ' TJS 01/06/14
' start of code added TJS 26/10/17
elseif ControlName = "AutoEnrolProvider" then
sTemp = "" & RemoveHTML(request.form(ControlName))
if sTemp <> "" then
GetDBField = cLng(sTemp)
else
GetDBField = sTemp
end if
' end of code added TJS 26/10/17
' start of code added TJS 27/12/19
elseif ControlName = "ContPaidSet" then
if RemoveHTML(request.form("ContributionPaidGross")) = "ON" or RemoveHTML(request.form("ContributionPaidGross")) = "OFF" then
GetDBField = -1
else
GetDBField = 0
end if
' end of code added TJS 27/12/19
else
GetDBField = RemoveHTML(request.form(ControlName))
end if
elseif EmployerID < 0 then
if ControlName = "PensCostNom" or ControlName = "PensDueNom" then ' TJS 16/09/14
GetDBField = "-1" ' TJS 16/09/14
else
' return a null value
end if
elseif NoRecordsFound then
if ControlName = "PensCostNom" then ' TJS 16/09/14
GetDBField = rsEmployer("Pension_Cost_Nominal") ' TJS 16/09/14
elseif ControlName = "PensDueNom" then ' TJS 16/09/14
GetDBField = rsEmployer("Pension_Due_Nominal") ' TJS 16/09/14
' start of code added TJS 08/12/14
elseif (ControlName = "AutoEnrolProvider" or ControlName = "AutoEnrolRef" or ControlName = "AutoEnrolRef2" or _
ControlName = "AutoEnrolRef3" or ControlName = "AETargetCo" or ControlName = "GenAEProvName") and _
not AEUndefinedOrMultiScheme(rsEmployer("Auto_Enrolment_Format")) then ' TJS 14/03/16 TJS 07/04/16
select case ControlName
case "AutoEnrolProvider"
GetDBField = rsEmployer("Auto_Enrolment_Format")
case "AutoEnrolRef"
GetDBField = rsEmployer("Auto_Enrol_Ref")
case "AutoEnrolRef2"
GetDBField = rsEmployer("Auto_Enrol_Ref_2")
case "AutoEnrolRef3" ' TJS 14/03/16
GetDBField = rsEmployer("Auto_Enrol_Ref_3") ' TJS 14/03/16
case "AETargetCo" ' TJS 07/04/16
GetDBField = DecryptData("" & rsEmployer("Auto_Enrol_Target_Company")) ' TJS 07/04/16
case "GenAEProvName"
GetDBField = rsEmployer("Generic_AE_Provider_Name")
end select
' end of code added TJS 08/12/14
else
' return a null value
end if
elseif FieldName = "Enable_CIS" then ' TJS 01/06/14
GetDBField = rsEmployer(FieldName) ' TJS 01/06/14
' start of code added TJS 08/12/14
elseif (ControlName = "AutoEnrolProvider" or ControlName = "AutoEnrolRef" or ControlName = "AutoEnrolRef2" or _
ControlName = "AutoEnrolRef3" or ControlName = "AETargetCo" or ControlName = "GenAEProvName") and _
not AEUndefinedOrMultiScheme(rsEmployer("Auto_Enrolment_Format")) then ' TJS 14/03/16 TJS 07/04/16
select case ControlName
case "AutoEnrolProvider"
GetDBField = rsEmployer("Auto_Enrolment_Format")
case "AutoEnrolRef"
if GetDBField("Auto_Enrolment_Format", "AutoEnrolProvider") = PeoplesCSVPensionProviderID or _
GetDBField("Auto_Enrolment_Format", "AutoEnrolProvider") = PeoplesAPIPensionProviderID then ' TJS 26/10/17
GetDBField = rsPensDetails(FieldName)
else
GetDBField = rsEmployer("Auto_Enrol_Ref")
end if
case "AutoEnrolRef2"
GetDBField = rsEmployer("Auto_Enrol_Ref_2")
case "AutoEnrolRef3" ' TJS 14/03/16
GetDBField = rsEmployer("Auto_Enrol_Ref_3") ' TJS 14/03/16
case "AETargetCo" ' TJS 07/04/16
GetDBField = DecryptData("" & rsEmployer("Auto_Enrol_Target_Company")) ' TJS 07/04/16
case "GenAEProvName"
GetDBField = rsEmployer("Generic_AE_Provider_Name")
end select
elseif ControlName = "UpdateDefaults" then ' TJS 28/05/15
' return a null value
elseif ControlName = "AETargetCo" then ' TJS 23/01/18
GetDBField = DecryptData("" & rsPensDetails("Auto_Enrol_Target_Company")) ' TJS 23/01/18
' start of code added TJS 27/12/19
elseif ControlName = "ContPaidSet" then
GetDBField = -1
' end of code added TJS 27/12/19
else
' return recordset value
GetDBField = rsPensDetails(FieldName)
end if
end Function
'-------------------------------------------------------------------------------------------------------
Function CheckValidationFailure(FieldName)
if instr(1, FailureFields, ":" & FieldName & ":") = 0 then
' no failure - set control to normal
CheckValidationFailure = "" ' TJS 01/06/14
else
' validation failed - set control to red outline
CheckValidationFailure = "-error" ' TJS 01/06/14
end if
end Function
'-------------------------------------------------------------------------------------------------------
' start of code added TJS 16/09/14
function ConvertForXML(ByVal StringToConvert)
ConvertForXML = replace(StringToConvert,"&","&")
ConvertForXML = replace(ConvertForXML,"<","<")
ConvertForXML = replace(ConvertForXML,">",">")
ConvertForXML = replace(ConvertForXML,"""",""")
ConvertForXML = replace(ConvertForXML,"'","'")
end function
'-------------------------------------------------------------------------------------------------------
' start of code added TJS 03/05/16
function ConvertFromDB(ByVal StringToConvert)
ConvertFromDB = replace(StringToConvert,"&","&")
ConvertFromDB = replace(ConvertFromDB,"<","<")
ConvertFromDB = replace(ConvertFromDB,">",">")
ConvertFromDB = replace(ConvertFromDB,""","""")
ConvertFromDB = replace(ConvertFromDB,"'","'")
end function
' end of code added TJS 03/05/16
'-------------------------------------------------------------------------------------------------------
sub SendErrorEmail(ByVal SystemIntegration, ByVal EMailText, ByVal AlertText)
if left(UCase(request.servervariables("SERVER_NAME")), 9) <> "MYPAYE-LT" then ' TJS 03/12/15
' 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 - " & SystemIntegration & " integration (ER Pension) error on EmployerID " & EmployerID ' TJS 17/10/16
myMail.From = "AutoSequence@MyPAYE.co.uk"
myMail.To = "Support@MyPAYE.co.uk"
myMail.TextBody = EMailText
myMail.Send
Set myMail = nothing
if "" & AlertMessage <> "" then
AlertMessage = AlertMessage & "
"
end if
AlertMessage = AlertMessage & AlertText
else
response.write EMailText
end if
end sub
' end of code added TJS 16/09/14
' start of code moved TJS 19/12/15
'-------------------------------------------------------------------------------------------------------
function CheckLinkedAcctsOK(AcctsIntegration, AccountCount)
if (AcctsIntegration = "Xero" or AcctsIntegration = "KashFlow" or AcctsIntegration = "Reviso" or _
AcctsIntegration = "Twinfield" or AcctsIntegration = "JustAccts" or AcctsIntegration = "LiquidAccts" or _
AcctsIntegration = "ExactOnline" or AcctsIntegration = "QuickBooks") and AccountCount > 0 then ' TJS 07/04/20
CheckLinkedAcctsOK = true
else
CheckLinkedAcctsOK = false
end if
end function
'-------------------------------------------------------------------------------------------------------
function AccountCodeIsExpense(AcctsIntegration, AccountType)
if ((AccountType = "DIRECTCOSTS" or AccountType = "OVERHEADS" or AccountType = "EXPENSE" or AccountType = "SALES") and _
AcctsIntegration = "Xero") or _
((AccountType = "2" or AccountType = "3") and AcctsIntegration = "KashFlow") or _
(lCase(AccountType) = "profitandloss" and AcctsIntegration = "Reviso") or _
(AccountType = "P&L" and AcctsIntegration = "Twinfield") or _
(AccountType = "P&L" and AcctsIntegration = "JustAccts") or _
(AccountType = "P&L" and AcctsIntegration = "LiquidAccts") or _
(CompareNumericAccountType(AccountType, 110, 999, false, false, true) and AcctsIntegration = "ExactOnline") or _
(AccountType = "Expense" and AcctsIntegration = "QuickBooks") then ' TJS 26/02/20 TJS 07/04/20
AccountCodeIsExpense = true
else
AccountCodeIsExpense = false
end if
end function
'-------------------------------------------------------------------------------------------------------
function AccountCodeIsBalSheet(AcctsIntegration, AccountType)
if ((AccountType = "CURRENT" or AccountType = "FIXED" or AccountType = "CURRLIAB" or AccountType = "TERMLIAB" or _
AccountType = "EQUITY" or AccountType = "BANK" or AccountType = "DEPRECIATN" or AccountType = "LIABILITY" or _
AccountType = "NONCURRENT" or AccountType = "OTHERINCOME" or AccountType = "PREPAYMENT") and AcctsIntegration = "Xero") or _
(AccountType = "5" and AcctsIntegration = "KashFlow") or _
(lCase(AccountType) = "status" and AcctsIntegration = "Reviso") or _
(AccountType = "BS" and AcctsIntegration = "Twinfield") or _
(AccountType = "BAL" and AcctsIntegration = "JustAccts") or _
(AccountType = "BAL" and AcctsIntegration = "LiquidAccts") or _
(CompareNumericAccountType(AccountType, 110, 999, true, false, false) and AcctsIntegration = "ExactOnline") or _
((AccountType = "Asset" or AccountType = "Equity" or AccountType = "Liability" or AccountType = "Accounts Payable" or AccountType = "Bank") and AcctsIntegration = "QuickBooks") then ' TJS 25/02/20 TJS 07/04/20
AccountCodeIsBalSheet = true
else
AccountCodeIsBalSheet = false
end if
end function
'-------------------------------------------------------------------------------------------------------
function CompareNumericAccountType(AccountType, LowerLimit, UpperLimit, LT, EQ, GT)
CompareNumericAccountType = false
if IsNumeric(AccountType) then
if cLng(AccountType) < LowerLimit and LT then
CompareNumericAccountType = true
elseif cLng(AccountType) >= LowerLimit and cLng(AccountType) <= UpperLimit and EQ then
CompareNumericAccountType = true
elseif cLng(AccountType) > LowerLimit and GT then
CompareNumericAccountType = true
end if
end if
end function
'-------------------------------------------------------------------------------------------------------
' end of code moved TJS 19/12/15
' start of code added based on existing conditional statements TJS 08/11/16
function AEUndefinedOrMultiScheme(PensionProviderID)
AEUndefinedOrMultiScheme = false
if "" & PensionProviderID = "" or PensionProviderID = MultiSchemeProviderID then
AEUndefinedOrMultiScheme = true
end if
end function
'-------------------------------------------------------------------------------------------------------
' start of code added TJS 14/10/17
function AENoEmployerRef(PensionProviderID)
AENoEmployerRef = false
' note this function differs from the Employer Options one as Peoples Pension requires a scheme level employer ref
if PensionProviderID = CreativePensionProviderID or PensionProviderID = ZurichPensionProviderID or PensionProviderID = SalvusPensionProviderID then ' TJS 26/10/17 TJS 15/11/17 TJS 23/01/18
AENoEmployerRef = true
end if
end function
' end of code added TJS 14/10/17
'-------------------------------------------------------------------------------------------------------
function ShowAEExportBeforeCell(PensionProviderID)
ShowAEExportBeforeCell = false
if PensionProviderID = AegonPensionProviderID or PensionProviderID = StdLifePensionProviderID or _
PensionProviderID = GenericPensionProviderID then ' 01/06/14 TJS 08/12/14 TJS 28/05/15 TJS 14/03/16 TJS 08/11/16
ShowAEExportBeforeCell = true
end if
end function
'-------------------------------------------------------------------------------------------------------
function ShowAEImportDeductions(PensionProviderID)
ShowAEImportDeductions = false
if PensionProviderID = NOWPensionProviderID then ' TJS 28/05/15 TJS 08/11/16
ShowAEImportDeductions = true
end if
end function
'-------------------------------------------------------------------------------------------------------
function ShowPayrollAERef2Cell(PensionProviderID)
ShowPayrollAERef2Cell = false
if PensionProviderID = NESTPensionProviderID or PensionProviderID = NOWPensionProviderID or _
PensionProviderID = StdLifePensionProviderID then ' TJS 28/05/15 TJS 06/02/16
ShowPayrollAERef2Cell = true
end if
end function
'-------------------------------------------------------------------------------------------------------
function PayrollAERef2Name(PensionProviderID)
select case PensionProviderID
case NESTPensionProviderID ' TJS 06/02/16 TJS 14/03/16
PayrollAERef2Name = "Payment Due By * "
case NOWPensionProviderID ' TJS 19/02/15
PayrollAERef2Name = "Scheme Code * "
case StdLifePensionProviderID ' TJS 19/02/15
PayrollAERef2Name = "Multi-Site "
end select
end function
'-------------------------------------------------------------------------------------------------------
' end of code added TJS 08/11/16
' start of code added TJS 08/04/17
sub HandleErrors(ByVal AccountIntegration, EMailText, AlertText) ' TJS 10/04/17
if "" & EMailText <> "" then
SendErrorEmail AccountIntegration, EMailText, AlertText ' TJS 10/04/17
else
if "" & AlertMessage <> "" then
AlertMessage = AlertMessage & "
"
end if
AlertMessage = AlertMessage & AlertText
end if
end sub
'-------------------------------------------------------------------------------------------------------
' end of code added TJS 08/04/17
' start of function created using code from below TJS 23/04/20
sub AddNominalCodes(ByRef rsNominalCodes, ByVal AcctsIntegration, ByVal AccountCount, ByVal FieldName, ByVal ControlName)
if CheckLinkedAcctsOK(AcctsIntegration, AccountCount) then ' TJS 19/12/15%>
<%if not rsNominalCodes.BOF then
rsNominalCodes.movefirst
end if
do while not rsNominalCodes.EOF
' start of code added TJS 23/04/20
if AcctsIntegration = "QuickBooks" and left(rsNominalCodes("Nominal_Code"), 3) = "QB-" then%>
<%else
' end of code added TJS 23/04/20%>
<%end if
rsNominalCodes.movenext
loop%>
<%if not rsAccountList.BOF then
rsAccountList.movefirst
end if
do while not rsAccountList.EOF
if AccountCodeIsExpense(AcctsIntegration, rsAccountList("AcctType")) then ' TJS 19/12/15
bCodeInUse = false
if not rsNominalCodes.BOF then
rsNominalCodes.movefirst
end if
do while not rsNominalCodes.EOF
if rsNominalCodes("Nominal_Code") = rsAccountList("AcctCode") then
bCodeInUse = true
' has Account Name been changed in linked system ?
if rsNominalCodes("Display_Name") <> rsAccountList("AcctName") then
' yes, update our copy
sql = "UPDATE " & DBSchema & "Nominal_Codes SET Display_Name = '" & ConvertQuoteChars(Left(rsAccountList("AcctName"), 50)) & "' WHERE Nominal_Code_ID = " & rsNominalCodes("Nominal_Code_ID")
ExecuteSQL objConn, sql
end if
exit do
end if
rsNominalCodes.movenext
loop
if not bCodeInUse then
' start of code added TJS 23/04/20
if AcctsIntegration = "QuickBooks" and left(rsAccountList("AcctCode"), 3) = "QB-" then%>
<%if rsNominalCodes.EOF and not rsNominalCodes.BOF then
rsNominalCodes.movefirst
end if
do while not rsNominalCodes.EOF%>
<%rsNominalCodes.movenext
loop
end if
end sub
'-------------------------------------------------------------------------------------------------------
' end of function created using code from below TJS 23/04/20
NoRecordsFound = False
if EmployerID < 0 then
NoRecordsFound = True
CISPaylistCount = 0 ' TJS 17/01/12
else
sql = "SELECT " & EmployerTableMenuOptionFields & ", Accounts_Integration, Default_Nominal_Codes, Pension_Cost_Nominal, Pension_Due_Nominal, " ' TJS 17/01/12 TJS 01/06/14 TJS 16/9/14
sql = sql & "Auto_Enrol_Staging_Date, Auto_Enrol_Ref, Auto_Enrol_Ref_2, Auto_Enrol_Ref_3, Auto_Enrol_Target_Company, Generic_AE_Provider_Name, " ' TJS 16/9/14 TJS 08/12/14 TJS 22/07/15 TJS 14/03/16 TJS 07/04/16 TJS 05/01/18
sql = sql & "Trial_Period_Ends, Enable_MyDeck, Agency_ID, Tax_District_Code, Tax_Reference, CIS_Paylists_In_Use FROM " & DBSchema & "Employers " ' TJS 17/07/16 TJS 17/10/16 TJS 20/11/18
sql = sql & "WHERE Employer_ID = " & EmployerID
set rsEmployer = OpenRecordset(objConn, sql)
EmployerName = rsEmployer("Employer_Name")
bEnableCIS = cBool(rsEmployer("Enable_CIS")) ' TJS 17/01/12
sql = "SELECT Payroll_ID, Payroll_Name, Pension_Scheme_ID, Auto_Enrol_Pension_ID, Enable_Multiple_Pensions FROM " & DBSchema ' TJS 01/06/14 TJS 17/07/16
sql = sql & "Payrolls WHERE Employer_ID = " & EmployerID & " AND Deleted = 0 ORDER BY Payroll_Name" ' TJS 01/06/14
set rsPayrollList = OpenRecordset(objConn, sql)
' ignore Empolyee personal pension schemes
sql = "SELECT COUNT(*) FROM " & DBSchema & "Pension_Schemes WHERE Employer_ID = " & EmployerID
sql = sql & " AND Employee_ID < 0 AND Deleted = 0" ' TJS 26/02/10
set rsPensDetails = OpenRecordset(objConn, sql)
PensionSchemeCount = cLng(rsPensDetails(0))
rsPensDetails.close
' ignore Employee personal pension schemes
sql = "SELECT Pension_Scheme_ID, Scheme_Name, Contract_Out_Cert, Scheme_Type, Employee_Contrib_Rate, "
sql = sql & "Employer_Contrib_Rate, Lump_Sum_AVC_Allowed, Percentage_AVC_Allowed FROM " & DBSchema
sql = sql & "Pension_Schemes WHERE Employer_ID = " & EmployerID & " AND Employee_ID < 0 AND Deleted = 0" ' TJS 26/02/10
set rsPensList = OpenRecordset(objConn, sql)
if PensionSchemeCount = 1 and PensionSchemeID < 0 and AddNewEdit <> "Add" then
PensionSchemeID = rsPensList("Pension_Scheme_ID")
end if
sql = "SELECT Pension_Scheme_ID, Scheme_Name, Contract_Out_Cert, Scheme_Type, Contribution_paid_Gross, Employee_Contrib_Rate, "
sql = sql & "Employer_Contrib_Rate, Lump_Sum_AVC_Allowed, Percentage_AVC_Allowed, Pay_Contrib_On_Parental_Pay, Auto_Enrolment, " ' TJS 13/12/10 TJS 01/06/14
sql = sql & "Auto_Enrolment_Format, Generic_AE_Provider_Name, Auto_Enrol_Ref, Auto_Enrol_Ref_2, Auto_Enrol_Ref_3, Auto_Enrol_Target_Company, " ' TJS 01/06/14 TJS 08/12/14 TJS 07/04/16
sql = sql & "Auto_Enrol_Certified, Auto_Enrol_Export_Before, Auto_Enrol_Import_Deductions, Auto_Enrol_Pay_Contrib_Below_Threshold, " ' TJS 01/06/14 TJS 08/12/14 TJS 28/05/15
sql = sql & "Auto_Enrol_Pay_Contrib_Above_Max, Salary_Sacrifice_Employer_NI_Percent, Bank_Name, Bank_Sort_Code, Bank_Account, " ' TJS 24/04/12 TJS 01/06/14 TJS 16/09/14
sql = sql & "Bank_Account_Name, Pension_Cost_Nominal, Pension_Due_Nominal, Auto_Enrol_Ref_3, Auto_Enrol_Linked_Group, PensionSync_Scheme_ID FROM " ' TJS 26/02/10 TJS 14/03/16 TJs 23/12/17
sql = sql & DBSchema & "Pension_Schemes WHERE Employer_ID = " & EmployerID & " AND Pension_Scheme_ID = " & PensionSchemeID & " AND Deleted = 0"
set rsPensDetails = OpenRecordset(objConn, sql)
if rsPensDetails.EOF then
rsPensDetails.close
set rsPensDetails = nothing
NoRecordsFound = True
if AddNewEdit = "Edit" then
AddNewEdit = "Add"
end if
end if
' start of code added TJS 17/01/12
if bEnableCIS then
sql = "SELECT COUNT(*) FROM " & DBSchema & "CIS_PayLists WHERE Employer_ID = " & EmployerID & " AND Deleted = 0" ' TJS 20/11/18
set rsPaylists = OpenRecordset(objConn, sql)
CISPaylistCount = cLng(rsPaylists (0))
rsPaylists.close
set rsPaylists = nothing
else
CISPaylistCount = 0
end if
' end of code added TJS 17/01/12
CISPaylistsInUse = "" & rsEmployer("CIS_Paylists_In_Use") ' TJS 20/11/18
' start of code added TJS 01/06/14
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)
' end of code added TJS 01/06/14
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
' start of code added TJS 06/08/14
if GetSessionVar("Function") = "SelectEmpl" or GetSessionVar("Function") = "SelPayMthd" then
if cBool(rsUser("Run_Payroll")) then
AmendSessionVar "Function", "Payroll"
else
AmendSessionVar "Function", "ViewPayroll"
end if
end if
' end of code added TJS 06/08/14
' start of code added TJS 16/09/14
sql = "SELECT Nominal_Code_ID, Nominal_Code, Display_Name, Balance_Sheet_Item FROM " & DBSchema & "Nominal_Codes WHERE (Employer_ID = "
if cBool(rsEmployer("Default_Nominal_Codes")) then
sql = sql & "-1 OR Employer_ID = "
end if
sql = sql & EmployerID & ") ORDER BY Nominal_Code"
set rsNominalCodes = OpenRecordset(objConn, sql)
' end of code added TJS 16/09/14
end if
if AddNewEdit <> "Add" and AddNewEdit <> "Edit" then
ReadOnly=" readonly"
AllowChanges = false ' TJS 01/06/14
else
ReadOnly=""
AllowChanges = true ' TJS 01/06/14
end if%>
<%' start of code added TJS 16/09/14
' start of code moved and modified TJS 19/12/15
' initialise variables
dim AccountCount, rsAccountList ' TJS 03/05/16
AccountCount = 0
Set rsAccountList = CreateObject("ADODB.RECORDSET")
rsAccountList.Fields.append "AcctCode", adVarChar, 20
rsAccountList.Fields.append "AcctName", adVarChar, 70 ' DC 20/09/16
rsAccountList.Fields.append "AcctType", adVarChar, 20
rsAccountList.Fields.append "AcctClass", adVarChar, 20
rsAccountList.Fields.append "AcctGUID", adVarChar, 40
rsAccountList.CursorType = adOpenStatic
rsAccountList.Open
varFields = Array("AcctCode", "AcctName", "AcctType", "AcctClass", "AcctGUID")
' end of code moved and modified TJS 19/12/15
' Is system integrated with Xero Network ?
if "" & rsEmployer("Accounts_Integration") = "Xero" then
' yes, get link details
GetXeroAccountCodes XOAuthOK, "Employer Pension Schemes", "EmployerPensionSchemesJS.asp", true, "EmplPen", "GetEPSJS", EmployerID, "EPS", false, rsAccountList, AccountCount, _
AlertMessage, false, rsTrackingCategories, SelectedTrackingCategory, rsTrackingOptions, bExtCostCentreChng ' TJS 30/05/16 TJS 28/07/16 TJS 10/06/18 TJS 30/06/21
elseif "" & rsEmployer("Accounts_Integration") = "KashFlow" then
' yes, get link details
GetKashFlowAccountCodes EmployerID, false, rsAccountList, AccountCount, AlertMessage ' TJS 03/05/16
elseif "" & rsEmployer("Accounts_Integration") = "Reviso" then ' TJS 03/12/15
' yes, get link details
GetRevisoAccountCodes RevisoAuthOK, "Employer Pension Schemes", "EmployerPensionSchemesJS.asp", true, "EmplPen", "GetEPSJS", "EPS", "PayrollHome", _
EmployerID, rsAccountList, AccountCount, AlertMessage ' TJS 30/05/16 TJS 90/02/20
elseif "" & rsEmployer("Accounts_Integration") = "Twinfield" then
' yes, get link details
GetTwinfieldAccountCodes EmployerID, rsAccountList, AccountCount, AlertMessage ' TJS 14/03/16
' start of code added TJS 13/03/15
elseif "" & rsEmployer("Accounts_Integration") = "JustAccts" then
' yes, get link details
sql = "SELECT JustAcct_API_URL, Access_Token_Expires, Expiry_Check_Value FROM " & DBSchema
sql = sql & "JustAccounts_Integration WHERE Employer_ID = " & EmployerID & " AND Deleted = 0" ' TJS 19/05/18
set rsJustAcctLink = OpenRecordset(objConn, sql)
' is there a link record ?
bJustAcctAPIActive = false
if not rsJustAcctLink.EOF then
' yes, is JustAccounts URL set and Access Token up to date ?
if rsJustAcctLink("JustAcct_API_URL") <> "" and CompareDates(rsJustAcctLink("Access_Token_Expires"), dateadd(rsJustAcctLink("Expiry_Check_Value"), 1, Date()), false, false, true) then
bJustAcctAPIActive = true
end if
end if
if not bJustAcctAPIActive and JAOAuthOK <> "No" then
sql = "UPDATE " & DBSchema & "Session_Vars SET GetENCJS = 'Yes' WHERE Session_Var_ID = '" & left(SessionVarsID, 15) & "'"
ExecuteSQL objConn, sql
GetJustAcctsAuthToken "Employer Pension Details", "JavaScript/EmployerPensionSchemesJS.asp", "EPS", "EmplPen" ' TJS 19/12/15
rsEmployer.close
set rsEmployer = nothing
SaveSessionVarsRecord SessionVarsID
objConn.close
set objConn = nothing
response.end
end if
' is there a link record ?
if not rsJustAcctLink.EOF then
' yes, is JustAccounts API active ?
if bJustAcctAPIActive then
' yes, get accounts list from JustAccounts
set XMLSubmit = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") ' TJS 27/06/18
JustAcctGetAccountsAPI = "ID=" & SetPageSessionID(20290, DestFrame) & "&SV=" & SessionVarsID & "&S=" & DestFrame & "&D="
JustAcctGetAccountsAPI = JustAcctGetAccountsAPI & PopupWindow1 & "&ER=" & EmployerID
SaveSessionVarsRecord SessionVarsID
XMLSubmit.open "POST", "https://" & request.servervariables("SERVER_NAME") & "/Secure/OAuth/GetJustAcctsAccountsList.ashx", False, "", ""
XMLSubmit.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
on error resume next
XMLSubmit.Send JustAcctGetAccountsAPI
if err.number = 0 then
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
if not XMLResponse.selectSingleNode("s:Envelope/s:Body/GetNominalsForCompanyResponse/GetNominalsForCompanyResult") is nothing then
Set XMLAccounts = XMLResponse.selectNodes("s:Envelope/s:Body/GetNominalsForCompanyResponse/GetNominalsForCompanyResult/a:NominalSummary")
BlankCodeSuffix = 1
for each XMLAccount in XMLAccounts
AccountCount = AccountCount + 1
if cBool(XMLAccount.selectSingleNode("a:IsBank").Text) then
varValues = Array(XMLAccount.selectSingleNode("a:Code").Text, XMLAccount.selectSingleNode("a:Name").Text, _
"BANK", "", "") ' TJS 19/12/15
elseif cBool(XMLAccount.selectSingleNode("a:IsPnL").Text) then
varValues = Array(XMLAccount.selectSingleNode("a:Code").Text, XMLAccount.selectSingleNode("a:Name").Text, _
"P&L", "", "") ' TJS 19/12/15
else
varValues = Array(XMLAccount.selectSingleNode("a:Code").Text, XMLAccount.selectSingleNode("a:Name").Text, _
"BAL", "", "") ' TJS 19/12/15
end if
' add row to memory table
rsAccountList.AddNew varFields, varValues ' TJS 19/12/15
rsAccountList.Update ' TJS 19/12/15
next
else
SendErrorEmail "JustAccounts", JustAcctGetAccountsAPI & vbcrlf & vbcrlf & "Send to JustAccounts" & vbcrlf & vbcrlf & "Response was" & vbcrlf & vbcrlf & XMLSubmit.ResponseText, _
"Could not read your Account Codes from JustAccounts
Details of the problem have been sent to Support" end if else SendErrorEmail "JustAccounts", JustAcctGetAccountsAPI & vbcrlf & vbcrlf & "Send to JustAccounts" & vbcrlf & vbcrlf & "No response received", _ "Could not read your Account Codes from JustAccounts
Details of the problem have been sent to Support" end if else SendErrorEmail "JustAccounts", JustAcctGetAccountsAPI & vbcrlf & vbcrlf & "Send to JustAccounts" & vbcrlf & vbcrlf & "Error code was " & err.number & ", " & err.description, _ "Could not read your Account Codes from JustAccounts
Details of the problem have been sent to Support"
end if
end if
end if
elseif "" & rsEmployer("Accounts_Integration") = "LiquidAccts" then
' yes, get link details
InitialiseLiquidAcctsAPI ' TJS 31/08/21
' start of code moved to LiquidAccountsAPIFunctions.asp TJS 27/10/16
GetLiquidAccountCodes rsAccountList, AccountCount, AlertMessage
' end of code moved to LiquidAccountsAPIFunctions.asp TJS 27/10/16
' end of code added TJS 13/03/15
' start of code aded TJS 19/12/15
elseif "" & rsEmployer("Accounts_Integration") = "ExactOnline" then
' no, integrated with Exact Online - get link details
sql = "SELECT Integration_ID, Access_Token, Access_Token_Expires, Refresh_Token, Exact_Company_ID FROM "
sql = sql & DBSchema & "ExactOnline_Integration WHERE Employer_ID = " & EmployerID & " AND Deleted = 0" ' TJS 19/05/18
set rsExactOnlineLink = OpenRecordset(objConn, sql)
' is there a link record ?
bExactOnlineActive = false
if not rsExactOnlineLink.EOF then
' yes, is Xero API enabled and up to date ?
if "" & rsExactOnlineLink("Access_Token") <> "" then
bExactOnlineActive = true
end if
end if
if not bExactOnlineActive and EXOAuthOK <> "No" then
sql = "UPDATE " & DBSchema & "Session_Vars SET GetENCJS = 'Yes' WHERE Session_Var_ID = '" & left(SessionVarsID, 15) & "'"
ExecuteSQL objConn, sql
GetExactOnlineAuthToken "Employer Pension Schemes", "EmployerPensionSchemesJS.asp", "EPS", "EmplPen" ' TJS 26/07/16 07/04/20
rsEmployer.close
set rsEmployer = nothing
SaveSessionVarsRecord SessionVarsID
objConn.close
set objConn = nothing
response.end
end if
' is there a link record ?
if not rsExactOnlineLink.EOF then
' yes, do we have an access token ?
EMailText = "" ' TJS 07/04/17
AlertText = "" ' TJS 07/04/17
if "" & rsExactOnlineLink("Access_Token") <> "" and "" & rsExactOnlineLink("Access_Token_Expires") <> "" then
' yes, is it still valid for at least another minute ?
if cDate(rsExactOnlineLink("Access_Token_Expires")) < dateadd("s", 60, Now()) then
' no, need to renew it
if RenewExactToken(DecryptData(rsExactOnlineLink("Refresh_Token")), rsExactOnlineLink("Integration_ID"), EMailText, AlertText) then ' TJS 07/04/17
rsExactOnlineLink.close
' get refreshed value
sql = "SELECT Integration_ID, Access_Token, Access_Token_Expires, Refresh_Token, Exact_Company_ID FROM "
sql = sql & DBSchema & "ExactOnline_Integration WHERE Employer_ID = " & EmployerID & " AND Deleted = 0" ' TJS 19/05/18
set rsExactOnlineLink = OpenRecordset(objConn, sql)
' start of code added TJS 07/04/17
else
if EMailText <> "" then
SendErrorEmail "ExactOnline", EMailText, AlertText
else
if "" & AlertMessage <> "" then
AlertMessage = AlertMessage & "
"
end if
AlertMessage = AlertMessage & AlertText
end if
end if
' end of code added TJS 07/04/17
end if
end if
' yes, do we still have an access token ?
if "" & rsExactOnlineLink("Access_Token") <> "" and "" & rsExactOnlineLink("Access_Token_Expires") <> "" and AlertText = "" then ' TJS 07/04/17
' yes, is it valid for at least another minute ?
if cDate(rsExactOnlineLink("Access_Token_Expires")) > dateadd("s", 60, Now()) then
set XMLResponse = GetExactOnlineXMLData(DecryptData(rsExactOnlineLink("Access_Token")), "financial/GLAccounts", _
rsExactOnlineLink("Exact_Company_ID"), "?$select=ID,BalanceSide,Code,Description,Type")
' did we get an error ?
if err.number = 0 then
' no, did we get a response ?
if not XMLResponse is nothing then
' yes, extract Accounts list details
ExtractExactOnlineAcctCodes XMLResponse, rsAccountList, varFields ' TJS 06/02/16
else
SendErrorEmail "ExactOnline", "No response received", _
"Could not read your Account Codes from ExactOnline
Details of the problem have been sent to Support"
end if
else
SendErrorEmail "ExactOnline", XMLToSend & vbcrlf & vbcrlf & "Send to ExactOnline" & vbcrlf & vbcrlf & "Error code was " & err.number & ", " & err.description, _
"Could not read your Account Codes from ExactOnline
Details of the problem have been sent to Support" end if end if end if end if rsExactOnlineLink.close set rsExactOnlineLink = nothing ' end of code aded TJS 19/12/15 ' start of code added TJS 07/04/20 elseif "" & rsEmployer("Accounts_Integration") = "QuickBooks" then ' yes, get link details GetQBAccountCodes QuickBooksAuthOK, "Employer Pension Schemes", "EmployerPensionSchemesJS.asp", true, "EmplPen", "GetEPSJS", "EPS", "PayrollHome", _ EmployerID, rsAccountList, AccountCount, AlertMessage ' end of code added TJS 07/04/20 end if ' end of code added TJS 16/09/14 ' start of code added TJS 14/10/17 bPeoplesPensionAuthNeeded = false bSmartPensionAuthNeeded = false ' TJS 14/08/18 TargetCompanySet = "" ' TJS 05/09/18 if GetDBField("Auto_Enrolment_Format", "AutoEnrolProvider") = PeoplesAPIPensionProviderID then sql = "SELECT Integration_ID, Access_Token, Access_Token_Expires, Refresh_Token, Refresh_Token_Expires FROM " & DBSchema ' TJS 19/05/18 sql = sql & "The_Peoples_Pension_Integration WHERE Employer_ID = " & EmployerID & " AND Deleted = 0" ' TJS 19/05/18 set rsOAuth = OpenRecordset(objConn, sql) if rsOAuth.EOF then ' no integration record exists bPeoplesPensionAuthNeeded = true elseif "" & rsOAuth("Access_Token") = "" then ' Access code is empty so must have been disabled bPeoplesPensionAuthNeeded = true ' start of code added TJS 19/05/18 elseif "" & rsOAuth("Refresh_Token_Expires") <> "" then if rsOAuth("Refresh_Token_Expires") < dateadd("n", 1, Now()) then ' efresh Token has expired bPeoplesPensionAuthNeeded = true end if ' end of code added TJS 19/05/18 end if rsOAuth.close set rsOAuth = nothing ' start of code added TJS 14/08/18 elseif GetDBField("Auto_Enrolment_Format", "AutoEnrolProvider") = SmartPensionProviderID then sql = "SELECT SPI.Integration_ID, Employer_ID, Access_Token, Access_Token_Expires, Refresh_Token FROM " & DBSchema & "Smart_Pension_Integration SPI " ' TJS 05/09/18 TJS 20/09/18 sql = sql & "INNER JOIN " & DBSchema & "Smart_Pension_Login_Usage SPLU ON SPI.Integration_ID = SPLU.Integration_ID WHERE (Employer_ID = " & EmployerID ' TJS 20/09/18 sql = sql & " OR Employer_ID = -1) AND User_ID = " & GetSessionVar("UserID") & " AND SPLU.Deleted = 0 AND SPI.Deleted = 0 ORDER BY Employer_ID DESC" ' TJS 20/09/18 set rsOAuth = OpenRecordset(objConn, sql) if rsOAuth.EOF then ' no integration record exists bSmartPensionAuthNeeded = true elseif "" & rsOAuth("Access_Token") = "" then ' Access code is empty so must have been disabled bSmartPensionAuthNeeded = true end if if not rsOAuth.EOF then ' TJS 05/09/18 if rsOAuth("Employer_ID") >= 0 and "" & rsEmployer("Auto_Enrol_Target_Company") <> "" then ' TJS 05/09/18 TargetCompanySet = "Yes" ' TJS 05/09/18 end if end if rsOAuth.close set rsOAuth = nothing ' end of code added TJS 14/08/18 end if ' end of code added TJS 14/10/17 bAERefUpdate = false ' TJS 23/01/18 response.Expires = -1500 response.Expiresabsolute = Now() - 2 response.AddHeader "pragma", "no-cache" response.AddHeader "cache-control", "no-store" response.CacheControl = "no-cache" ' start of code added TJS 30/06/11 sql = "UPDATE " & DBSchema & "Session_Vars SET GetEPSJS = 'Yes' WHERE Session_Var_ID = '" & left(SessionVarsID, 15) & "'" ' TJS 10/07/11 ExecuteSQL objConn, sql ' end of code added TJS 30/06/11 %>