<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2024-07-02T02:41:47.0000000">
    <CreatedUserId>ADMIN</CreatedUserId>
    <CreatedUtcDate>2020-07-19T23:09:00.5630000</CreatedUtcDate>
    <UpdatedUserId>ADMIN</UpdatedUserId>
    <UpdatedUtcDate>2024-07-02T02:41:32.6130000</UpdatedUtcDate>
    <ScriptId>STANDARDTRANSACTION</ScriptId>
    <Description>Account Standard Transaction</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_AccountStandardTransaction
Option Explicit On
Option Strict On

' #################################################################
' Account Standard Transaction wizard HTML Widget
'
' Version: 1.17 (02/07/2024)
'
' Usage: System-defined HTML Widget
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.12  25/05/2021  ISS
'    1.13  06/01/2022  ISS      J027620   Add Basis for Credit Limit 2 and 3
'    1.14  30/08/2022  ISS      J028580   Added support for Restructure HTML Widget
'    1.15  11/01/2023  ISS      J030113   Deposit Element Types now support a Basis other than 'Set Value'
'    1.16  21/03/2024  ISS      J032928   Added support for Zepto PayTo (Australia)
'    1.17  02/07/2024  ISS      J033738   Payment Method defaults are applied when selected, e.g. Default Reference.
' #################################################################

' Constants
Private Const FORM_KEY As String = "AccountStandardTransaction"

' Common Parameters
Private mAccountId As String
Private mAccountStdTranPk As Integer ' For 'Quote' Accounts, this should be the 0-based index of the item in the collection
Private mEditJson As Boolean
Private mIsRestructure As Boolean
Private mOwnerClientIds As String
Private mReadOnly As Boolean
Private mStandardTransactionJson As String

' Objects
Private mCombinedParameters As ISKeyValueList
Private mParameters As ISKeyValueList
Private mStartupParameters As ISKeyValueList

Public Function Main(eventId As String,
                     parametersJson As String,
                     startUpParametersJson As String,
                     hostingContext As isefinHtmlWidgetHostingContext,
                     requestInfo As finScriptRequestInfo,
                     ByRef returnValue As String) As Boolean

  ' Assume Success
  Main = True

  ' Get Parameters
  mParameters = finBL.CreateKeyValueList()
  mParameters.FromSimpleJsonString(parametersJson)
  mStartupParameters = finBL.CreateKeyValueList()
  mStartupParameters.FromSimpleJsonString(startUpParametersJson)

  ' Get Combined Parameters (Startup Parameters updated with event Parameters)
  mCombinedParameters = mStartupParameters.Clone()
  mCombinedParameters.UpdateFromKeyValueList(mParameters, True)

  ' Get Common Parameters
  With mCombinedParameters
    mAccountId = .GetString("AccountId")
    mAccountStdTranPk = .GetInteger("AccountStdTranPk")
    mEditJson = .GetBoolean("EditJson")
    mIsRestructure = .GetBoolean("IsRestructure")
    mOwnerClientIds = .GetString("OwnerClientIds")
    mReadOnly = .GetBoolean("ReadOnly")
    mStandardTransactionJson = .GetString("StandardTransactionJson")
  End With

  ' Handle Events
  Select Case eventId
    Case ""
      ' Main event, i.e., return initial HTML content (excluding html and body tags)
      returnValue = ScriptInfo.TemplateText

    Case "Delete"
      ' Delete Standard Transaction
      Main = Delete(returnValue)

    Case "Finish"
      ' Finish wizard
      Main = Finish(parametersJson, requestInfo, returnValue)

    Case "GetInitialisationInfo"
      ' Get Initialisation Information required for this wizard
      Main = GetInitialisationInfo(returnValue)

    Case "WizardValidate"
      ' Validate wizard page
      Main = WizardValidate(parametersJson, returnValue)

    Case Else
      finBL.Error.ErrorBeginFormat("Unhandled event '{0}'.", eventId)
      Main = False
  End Select

End Function

''' &lt;summary&gt;
'''  Create a finAccount and finAccountStdTran object from Web Service properties.
''' &lt;/summary&gt;
''' &lt;returns&gt;
'''  A Boolean value indicating success.
''' &lt;/returns&gt;
Private Function CreateAccountStdTran(parameters As WizardFinishParameters,
                                      ByRef account As finAccount,
                                      ByRef accountStdTran As finAccountStdTran) As Boolean

  Dim JsonHtmlWidgetAccountStdTran As finAccountStdTran.jsonHtmlWidgetAccountStdTran
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise ByRef Parameters
  account = finBL.CreateAccount()
  accountStdTran = Nothing

  ' Load Account
  If Success Then
    If mEditJson AndAlso Not mIsRestructure Then
      ' From New Account wizard
    Else
      Success = account.Load(mAccountId)
    End If
  End If

  ' Get Standard Transaction
  If Success Then
    If mEditJson Then
      ' From New Account wizard
      accountStdTran = account.StandardTransactions.CreateAccountStdTran()

      If Len(mStandardTransactionJson) &lt;&gt; 0 Then
        ' Account Type and Branch are contained in the JSON representation to assist this wizard
        JsonHtmlWidgetAccountStdTran = accountstdTran.CreateJsonHtmlWidgetAccountStdTran(mStandardTransactionJson)
        account.AccountTypeId = JsonHtmlWidgetAccountStdTran.AccountTypeId
        account.BranchId = JsonHtmlWidgetAccountStdTran.BranchId

        accountStdTran.FromHtmlWidgetJsonString(mStandardTransactionJson)

        ' Other defaults (since JSON may only contain information about the Account Type and Branch)
        If Len(accountStdTran.Cycle) = 0 Then accountStdTran.Cycle = "e"
        If Len(accountStdTran.CycleFirstPeriod) = 0 Then accountStdTran.CycleFirstPeriod = "Standard"
      End If
    Else
      ' Find Standard Transaction
      If mAccountStdTranPk = -1 Then
        accountStdTran = account.StandardTransactions.CreateAccountStdTran()
      ElseIf account.Status = isefinAccountStatus.Quote Then
        If mAccountStdTranPk &gt;= 0 AndAlso mAccountStdTranPk &lt; account.StandardTransactions.Count Then
          accountStdTran = account.StandardTransactions.Item(mAccountStdTranPk)
        Else
          Success = False
          finBL.Error.ErrorBegin("Failed to retrieve Standard Transaction by index. This record may have been deleted by another User.")
        End If
      ElseIf account.StandardTransactions.ExistsPk(mAccountStdTranPk) Then
        accountStdTran = account.StandardTransactions.ItemByPk(mAccountStdTranPk)
      Else
        Success = False
        finBL.Error.ErrorBegin("Failed to retrieve Standard Transaction. This record may have been deleted by another User.")
      End If
    End If
  End If

  ' Update Standard Transaction
  If Success AndAlso parameters IsNot Nothing Then
    Success = accountStdTran.FromHtmlWidgetJsonString(parameters.StandardTransactionJson)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Delete Standard Transaction.
''' &lt;/summary&gt;
Private Function Delete(ByRef returnValue As String) As Boolean

  Dim Account As finAccount
  Dim AccountStdTran As finAccountStdTran
  Dim OriginalTimestamp As Integer
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Parameters
  With mCombinedParameters
    OriginalTimestamp = .GetInteger("OriginalTimestamp")
  End With

  ' Create Account and Standard Transaction objects
  If Success Then
    Success = CreateAccountStdTran(Nothing, Account, AccountStdTran)
  End If

  ' Delete and Save
  If Success Then
    ' Remove from collection
    Success = Account.StandardTransactions.Remove(AccountStdTran)

    ' Save
    If Success Then
      Success = Account.Save()
    End If
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Finish, i.e., Commit changes.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted WizardFinishParameters object.
''' &lt;/param&gt;
Private Function Finish(parametersJson As String,
                        requestInfo As finScriptRequestInfo,
                        ByRef returnValue As String) As Boolean

  Dim Account As finAccount
  Dim AccountStdTran As finAccountStdTran
  Dim Index As Integer
  Dim obj As Object
  Dim Success As Boolean
  Dim WizardFinishParameters As WizardFinishParameters

  ' Assume Success
  Success = True

  ' Parse Parameters
  If finBL.Runtime.WebUtilities.DeserialiseJsonStringToObject(parametersJson, GetType(WizardFinishParameters), obj) Then
    WizardFinishParameters = DirectCast(obj, WizardFinishParameters)
  Else
    Success = False
  End If

  ' Create Account and Standard Transaction objects
  If Success Then
    Success = CreateAccountStdTran(WizardFinishParameters, Account, AccountStdTran)
  End If

  ' If a new Standard Transaction add to collection
  If Success AndAlso mAccountStdTranPk = -1 AndAlso Not mEditJson Then
    Account.StandardTransactions.Add(AccountStdTran)
  End If

  ' Move?
  If Success AndAlso Not mEditJson Then
    Select Case WizardFinishParameters.MoveAction
      Case "MoveTop"
        Index = Account.StandardTransactions.IndexOf(AccountStdTran)
        If Index &gt; 0 Then Success = Account.StandardTransactions.Move(Index, 0)
    End Select
  End If

  ' Save
  If Success AndAlso Not mEditJson Then
    Success = Account.Save()
  End If

  ' Finalise
  If Success Then
    If mEditJson Then
      ' Tidy up invalid default properties
      AccountStdTran.FromHtmlWidgetJsonString(AccountStdTran.ToHtmlWidgetJsonString(Account.AccountTypeId))

      Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(New WizardFinishDetails(AccountStdTran.ToHtmlWidgetJsonString(Account.AccountTypeId)), returnValue)
    Else
      Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(New WizardFinishDetails(""), returnValue)
    End If
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Initialisation Information required for this wizard.
''' &lt;/summary&gt;
Public Function GetInitialisationInfo(ByRef response As String) As Boolean

  Dim Account As finAccount
  Dim AccountClient As finAccountClient
  Dim AccountStdTran As finAccountStdTran
  Dim CycleList As ISListReadOnly
  Dim CycleListOther As ISListReadOnly
  Dim Element As finElementRO
  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim OwnerClientIds As ISList
  Dim s As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate
  If mEditJson Then
    ' Editing from New Account wizard
  ElseIf Len(mAccountId) = 0 Then
    Success = False
    finBL.Error.ErrorBegin("Account Id not specified.")
  ElseIf finBL.CurrentUserInformation.IsAccountFilteredOut(mAccountId) Then
    Success = False
    finBL.Error.ErrorBegin("You do not have permission to view this Account.")
  End If

  ' Create Account and Standard Transaction objects
  If Success Then
    Success = CreateAccountStdTran(Nothing, Account, AccountStdTran)
  End If

  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Read Only?
      If finBL.Database.IsReadOnly OrElse mReadOnly Then
        .ReadOnly = True
      ElseIf mEditJson Then
        ' From New Account wizard - Account Status = Quote
        .ReadOnly = False
      Else
        ' Permission keys dictate open, otherwise read only
        Select Case Account.Status
          Case isefinAccountStatus.Open
            If AccountStdTran.IsNew Then
              .ReadOnly = Not finBL.CurrentUser.Permissions.Allow("Account.StandardTransactions.Add")
            Else
              .ReadOnly = Not finBL.CurrentUser.Permissions.Allow("Account.StandardTransactions.Update")
            End If
          Case Else
            .ReadOnly = True
        End Select
      End If

      ' Record
      .IsNew = AccountStdTran.IsNew
      .Timestamp = AccountStdTran.Timestamp

      ' Account Properties
      .AccountId = mAccountId
      .AccountName = account.Name
      .AccountClass = account.AccountClass.ToString()
      .IsQuoteOrClosedQuote = account.IsQuoteOrClosedQuote

      ' Standard Transaction
      .StandardTransaction = AccountStdTran.ToHtmlWidgetJsonObject(Account.AccountTypeId, Account.BranchId)

      ' Global Collections
      For Each Element In finBL.Elements
        If Element.Active Then
          .Elements.Add(New ElementInfo(Element, Account))
        End If
      Next

      ' Lists
      ' Default Cycle Lists
      finBL.AccountFunctions.GetAccountStdTranCycleList(Account, "", CycleList, CycleListOther)
      .CycleList = CycleList.ToCsvString()
      .CycleListOther = CycleListOther.ToCsvString()

      ' First Period
      If Account.IsQuoteOrClosedQuote Then
        Select Case account.AccountClass
          Case isefinAccountClass.Deposit
            .CycleFirstPeriodList = "Standard,Opening,On Date,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years"
            .CycleFirstPeriodListOther = "Standard,Opening,On Date"

          Case isefinAccountClass.Disbursement
            .CycleFirstPeriodList = "Standard,Opening,On Date,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years"
            .CycleFirstPeriodListOther = "Standard,Opening,On Date"

          Case isefinAccountClass.LoanFR, isefinAccountClass.LoanFT
            .CycleFirstPeriodList = "Standard,Opening,On Date,At Maturity,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years"
            .CycleFirstPeriodListOther = "Standard,Opening,On Date,At Maturity"

          Case isefinAccountClass.LoanRC
            .CycleFirstPeriodList = "Standard,Opening,On Date,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years"
            .CycleFirstPeriodListOther = "Standard,Opening,On Date"
        End Select
      Else
        .CycleFirstPeriodList = "On Date,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years"
        .CycleFirstPeriodListOther = "On Date"
      End If

      ' Basis
      .ValueBasisList = finBL.Enums.isefinAccountStdTransValueBasis_ToCodeDescriptionList(Account.AccountClass, Account.AccountType.CreditLimitCount).ToJsonObject()

      .OwnerClientIds = mOwnerClientIds
      If Account.AccountType.TransferCommonClient Then
        ' List of Owner Clients passed to widget so add these so getting related Accounts works
        If Account.Clients.Count = 0 AndAlso Len(mOwnerClientIds) &lt;&gt; 0 Then
          OwnerClientIds = New ISList(mOwnerClientIds)
          For Each s In OwnerClientIds
            If Len(s) &lt;&gt; 0 Then
              AccountClient = Account.Clients.CreateAccountClient()
              With AccountClient
                .ClientIdSet(s)
                If Account.AccountType IsNot Nothing Then
                  .AccountRoleIdSet(Account.AccountType.ProductType.DefaultAccountRoleId)
                End If
              End With

              Account.Clients.Add(AccountClient)
            End If
          Next
        End If

        .TransferToAccountsList = finBL.AccountFunctions.GetRelatedAccountsCodeDescriptionList(Account).ToJsonObject(False)
      End If

      ' Other
      .ElementFilter = Account.StandardTransactions.ElementDataViewFilter(Account.AccountClass, Account.Status)

      ' Configuration
      .AddOnBankingAdvanced = finBL.Settings.AddOns.BankingAdvanced
      .PromptOnSave = finBL.CloudConnectFunctions.CloudConnectSettings.PromptOnSave
      .ShowKey = mCombinedParameters.GetString("ShowKey"): If Len(.ShowKey) = 0 Then .ShowKey = "Advanced"

      ' Finalise Configuration
      If .ReadOnly Then
        .CanDelete = False
      ElseIf mEditJson Then
        ' From New Account wizard
        .CanDelete = False
      ElseIf .IsNew Then
        .CanDelete = True
      Else
        .CanDelete = (account.Status = isefinAccountStatus.Open)
      End If
      .EditJson = mEditJson
    End With
  End If

  ' Further Validations
  If Success Then
    If FormInitialisationInfo.ReadOnly AndAlso mAccountStdTranPk = -1 AndAlso Not mEditJson Then
      Success = False
      finBL.Error.ErrorBegin("Cannot add a new Standard Transaction whilst form is Read-Only.")
    End If
  End If

  ' Response
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(FormInitialisationInfo, response)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Validate a Wizard page.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted object containing information required to validate a Wizard page.
''' &lt;/param&gt;
''' &lt;param name="returnValue"&gt;
'''  A JSON object; "true" if validation passed, otherwise, information as to why validation failed.
''' &lt;/param&gt;
Private Function WizardValidate(parametersJson As String,
                                ByRef returnValue As String) As Boolean

  Dim ConfirmList As List(Of String)
  Dim Data As Object
  Dim FailedControlId As String
  Dim FailedMessage As String
  Dim PageId As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Parameters
  ' NOTE: Use the module mCombinedParameters since this contains Startup and event Parameters in a single Key/Value List
  With mCombinedParameters
    PageId = .GetString("PageId")
  End With

  ' Validate Page
  Select Case PageId
    Case "General"
      ' General
      If WizardValidate_General(parametersJson, ConfirmList, failedMessage) Then
        Data = ConfirmList
      Else
        Success = False
      End If
  End Select

  ' Finalise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(New WizardValidateResponse(Data, FailedMessage, FailedControlId), returnValue)
  End If

  Return Success

End Function

Private Function WizardValidate_General(parametersJson As String,
                                        ByRef confirmList As List(Of String),
                                        ByRef failedMessage As String) As Boolean

  Dim Account As finAccount
  Dim AccountStdTran As finAccountStdTran
  Dim DateTemp As Date
  Dim obj As Object
  Dim Success As Boolean
  Dim ValidationItem As ISValidationItem
  Dim ValidationItems As ISValidationItems
  Dim WizardFinishParameters As WizardFinishParameters

  ' Assume Success
  Success = True

  ' Initialise ByRef
  confirmList = New List(Of String)()

  ' Parse Parameters
  If finBL.Runtime.WebUtilities.DeserialiseJsonStringToObject(parametersJson, GetType(WizardFinishParameters), obj) Then
    WizardFinishParameters = DirectCast(obj, WizardFinishParameters)
  Else
    Success = False
  End If

  ' Create Account &amp; Standard Transaction objects
  If Success Then
    Success = CreateAccountStdTran(WizardFinishParameters, Account, AccountStdTran)
  End If

  ' Stop Date
  If Success AndAlso AccountStdTran.DateStop &lt;&gt; Nothing Then
    If Account.DateOpened &lt;&gt; Nothing Then
      If AccountStdTran.DateStop &lt; Account.DateOpened Then
        confirmList.Add("Stop Date is prior to the Account Opening Date.")
      Else
        Select Case AccountStdTran.CycleFirstPeriod
          Case ""
            dateTemp = Nothing
          Case "At Maturity"
            dateTemp = Nothing
          Case "On Date"
            dateTemp = AccountStdTran.CycleFirstDate
          Case "Opening"
            dateTemp = Account.DateOpened
          Case "Standard"
            dateTemp = finBL.Utilities.DateCycleGetTermEndDate(Account.Calculation.PaymentCycle, Account.DateOpened)
          Case Else
            dateTemp = finBL.Utilities.DateCycleGetTermEndDate(AccountStdTran.CycleFirstPeriod, Account.DateOpened)
        End Select

        If dateTemp &lt;&gt; Nothing AndAlso AccountStdTran.DateStop &lt; dateTemp Then
          confirmList.Add(String.Format("Stop Date is prior to the First Date of {0}.", finBL.FormatDateLong(dateTemp)))
        End If
      End If
    End If
  End If

  ' Banking Information
  If Success Then
    Select Case accountStdTran.ElementType
      Case isefinElementType.PaymentReceived, isefinElementType.Investment, isefinElementType.InvestmentAdditional, isefinElementType.Withdrawal
        If accountStdTran.BankingDetails.PaymentMethodPk &lt;&gt; 0 AndAlso Not accountStdTran.BankingDetails.IsValid(ValidationItems, False) Then
          For Each ValidationItem In ValidationItems
            confirmList.Add(ValidationItem.Message)
          Next
        End If
    End Select
  End If

  ' Timestamp
  If Success Then
    If Not accountStdTran.IsNew AndAlso Not mEditJson AndAlso accountStdTran.Timestamp &lt;&gt; WizardFinishParameters.TimeStamp Then
      failedMessage = "Cannot update Standard Transaction. This record may have been updated or deleted by another User."
    End If
  End If

  Return Success

End Function


''' &lt;summary&gt;
'''  Wizard Initialisation Information.
''' &lt;/summary&gt;
Public Class FormInitialisationInfo

  ' Record
  Public IsNew As Boolean
  Public Timestamp As Integer

  ' Account Properties
  Public AccountId As String
  Public AccountName As String
  Public AccountClass As String
  Public IsQuoteOrClosedQuote As Boolean

  ' Standard Transaction
  Public StandardTransaction As finAccountStdTran.jsonHtmlWidgetAccountStdTran

  ' Lists
  Public ValueBasisList As Object
  Public CycleFirstPeriodList As String
  Public CycleFirstPeriodListOther As String
  Public CycleList As String
  Public CycleListOther As String
  Public OwnerClientIds As String
  Public TransferToAccountsList As Object

  ' List Filters
  Public ElementFilter As String

  ' Global Collections
  Public Elements As New List(Of ElementInfo)

  ' Configuration
  Public AddOnBankingAdvanced As Boolean
  Public CanDelete As Boolean
  Public EditJson As Boolean
  Public PromptOnSave As Boolean
  Public [ReadOnly] As Boolean
  Public ShowKey As String

End Class

''' &lt;summary&gt;
'''  Validation details.
''' &lt;/summary&gt;
Public Class WizardValidateResponse

  Public Data As Object
  Public FailedControlId As String
  Public FailedMessage As String

  Public Sub New(data As Object,
                 failedMessage As String,
                 failedControlId As String)

    Me.Data = data
    Me.FailedMessage = failedMessage
    Me.FailedControlId = failedControlId

  End Sub

End Class

''' &lt;summary&gt;
'''  Finish Parameters.
''' &lt;/summary&gt;
''' &lt;summary&gt;
'''  Finish Parameters.
''' &lt;/summary&gt;
Public Class WizardFinishParameters

  Public MoveAction As String
  Public StandardTransactionJson As String
  Public Timestamp As Integer

End Class

''' &lt;summary&gt;
'''  Finish details.
''' &lt;/summary&gt;
Public Class WizardFinishDetails

  Public StandardTransactionJson As String
  Public Warning As String

  Public Sub New(standardTransactionJson As String)

    Me.StandardTransactionJson = standardTransactionJson

  End Sub

End Class


''' &lt;summary&gt;
'''  Simple information about an Element.
''' &lt;/summary&gt;
Public Class ElementInfo

  Public CycleList As String
  Public CycleListOther As String
  Public ElementId As String
  Public ElementType As String
  Public Description As String
  Public TransactionNotes As String
  Public TransactionReference As String
  Public TransactionValue As Decimal

  Public Sub New(element As finElementRO,
                 account As finAccount)

    Dim List As ISListReadOnly
    Dim ListOther As ISListReadOnly

    ' Get Cycles
    finBLShared.AccountFunctions.GetAccountStdTranCycleList(account, element.ElementId, List, ListOther)

    ' Populate
    With element
      Me.CycleList = List.ToCsvString()
      Me.CycleListOther = ListOther.ToCsvString()
      Me.ElementId = .ElementId
      Me.ElementType = .ElementType.ToString()
      Me.Description = .Description
      Me.TransactionNotes = .TransactionNotes
      Me.TransactionReference = .TransactionReference
      Me.TransactionValue = .TransactionValue
    End With

  End Sub

End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System defined HTML Widget.

Used as a finPOWER Connect Cloud compatible version of the form "AccountStandardTransaction".

NOTE: This has special functionality to enable it to edit a JSON item passed from a New Account wizard.</Notes>
    <PermissionKeyExecute />
    <ReferenceLinq>false</ReferenceLinq>
    <RunWithoutPrompts>false</RunWithoutPrompts>
    <TemplateText>&lt;div id="frmMain" class="is-widget-content" style="visibility:hidden"&gt;

  &lt;!-- Form Header --&gt;
  &lt;header&gt;
    &lt;div class="header"&gt;&lt;/div&gt;
    &lt;div class="summary"&gt;&lt;/div&gt;
    &lt;!-- Tabs --&gt;
    &lt;div id="tabWizard" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;li tabId="General"&gt;Account Standard Transaction&lt;/li&gt;
      &lt;ul&gt;
    &lt;/div&gt;
  &lt;/header&gt;

  &lt;!-- Pages --&gt;
  &lt;div class="is-widget-form-body"&gt;
    &lt;!-- General --&gt;
    &lt;div id="pageGeneral"&gt;
      &lt;table class="is-form"&gt;

        &lt;tr&gt;&lt;td&gt;
          &lt;!-- Chrome sizing issue (May-2018) requires use of a sub-table --&gt;
          &lt;table class="is-form"&gt;
            &lt;colgroup&gt;
              &lt;col style="width:7em" /&gt;
              &lt;col /&gt;
            &lt;/colgroup&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblElement"&gt;Select the Element to use&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboElement"&gt;Element:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="cboElement" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr id="trKey" class="advanced"&gt;
              &lt;th&gt;&lt;label for="txtKey"&gt;Key:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="txtKey"/&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblCycle"&gt;Specify the default Cycle Frequency for the Transaction&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboCycle"&gt;Frequency:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="cboCycle" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboCycleFirstPeriod"&gt;First:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;
                &lt;div style="display:flex; flex-directon:row"&gt;
                  &lt;div&gt;&lt;input id="cboCycleFirstPeriod" /&gt;&lt;/div&gt;
                  &lt;div&gt;&lt;input id="dateCycleFirstDate" /&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="dateDateNext"&gt;Next Date:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="dateDateNext" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="dateDateStop"&gt;Stop Date:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="dateDateStop" /&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblBasis"&gt;Select the default Basis and Rate&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboValueBasis"&gt;Basis:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="cboValueBasis"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="numValueCurrency"&gt;Value:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="numValueCurrency"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr style="display:none"&gt;
              &lt;th&gt;&lt;label for="numValuePercent"&gt;Percent:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="numValuePercent"/&gt;&amp;nbsp;&amp;nbsp;&lt;input id="chkValuePercentPerAnnum" type="checkbox" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr style="display:none"&gt;
              &lt;th&gt;&lt;label for="numMinValue"&gt;Minimum:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="numMinValue"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr style="display:none"&gt;
              &lt;th&gt;&lt;label for="numMaxValue"&gt;Maximum:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="numMaxValue"/&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblNotes"&gt;Enter the default Transaction Reference and Notes&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="txtReference"&gt;Reference:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="txtReference"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="txtNotes"&gt;Notes:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="txtNotes"/&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblPaymentMethod"&gt;Enter the Payment method and Banking details&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tbody id="pdaPaymentDetails"&gt;&lt;/tbody&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblWithdrawalMethod"&gt;Enter the Payment method and Banking details&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tbody id="pdaWithdrawalDetails"&gt;&lt;/tbody&gt;

            &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblTransfer"&gt;Enter the Account to Transfer to&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboTransferToAccount"&gt;Account:&lt;/label&gt;&lt;/th&gt;
              &lt;td colspan="2"&gt;&lt;input id="cboTransferToAccount"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

  &lt;/div&gt;

  &lt;!-- Form Footer --&gt;
  &lt;footer&gt;
    &lt;button id="cmdActions"/&gt;
    &lt;button id="cmdAdvanced" class="is-button" style="float:left" title="Show/hide advanced options"&gt;Advanced&lt;/button&gt;

    &lt;button id="cmdCancel" class="is-button"&gt;Cancel&lt;/button&gt;
    &lt;button id="cmdBack" class="is-button"&gt;&amp;lt; Back&lt;/button&gt;
    &lt;button id="cmdNext" class="is-button"&gt;Next &amp;gt;&lt;/button&gt;
    &lt;button id="cmdFinish" class="is-button ok"&gt;Finish&lt;/button&gt;
  &lt;/footer&gt;

&lt;/div&gt;

&lt;script&gt;
// Record
var mRecord;
var mRecord_StdTran;

// Global Collections
var mElements;

// Controls
var C = {
  // General
  lblElement: null,
  cboElement: null,
  trKey: null,
  txtKey: null,

  lblCycle: null,
  cboCycle: null,
  cboCycleFirstPeriod: null,
  dateCycleFirstDate: null,
  dateDateNext: null,
  dateDateStop: null,

  lblBasis: null,
  cboValueBasis: null,
  numValueCurrency: null,
  numValuePercent: null,
  chkValuePercentPerAnnum: null,
  numMinValue: null,
  numMaxValue: null,

  lblNotes: null,
  txtReference: null,
  txtNotes: null,

  lblPaymentMethod: null,
  pdaPaymentDetails: null,

  lblWithdrawalMethod: null,
  pdaWithdrawalDetails: null,

  lblTransfer: null,
  cboTransferToAccount: null,
}

// Form
var frmMain;
var tabWizard;

// Other
var mElement;
var mValueData;

// Wizard Buttons
var cmdCancel;
var cmdBack;
var cmdNext;
var cmdFinish;

var cmdAdvanced;

// Other
var mAdvancedVisible = false;
var mHasAdvancedOptions = false;

// ==========
// Initialise
// ==========
$(function () {
  // Mobile optimisations
  var currencyWidth = "20em";
  $(window).resize(Form_Resize);

  // --------
  // Controls
  // --------
  //   General
  C.lblElement = widget.UI.Label("lblElement", {});
  C.cboElement = widget.UI.DBCombo("cboElement", {
    allowBlank: false,
    maxLength: 20,
    width: widget.UI.FIELD_WIDTH_CODE_20,
    onChange: cboElement_Change,
  });
  C.trKey = $("#trKey");
  C.txtKey = widget.UI.TextBox("txtKey", {
    maxLength: 10,
  });

  C.lblCycle = widget.UI.Label("lblCycle", {});
  C.cboCycle = widget.UI.DateCycleComboBox("cboCycle", {
    allowBlank: false,
    isFrequency: true,
    onChange: cboCycle_Change,
  });
  C.cboCycleFirstPeriod = widget.UI.DateCycleComboBox("cboCycleFirstPeriod", {
    allowBlank: false,
    isFrequency: false,
    onChange: cboCycleFirstPeriod_Change,
  });
  C.dateCycleFirstDate = widget.UI.DateBox("dateCycleFirstDate", {
    allowBlank: false,
  });
  C.dateDateNext = widget.UI.DateBox("dateDateNext", {
    allowBlank: false,
  });
  C.dateDateStop = widget.UI.DateBox("dateDateStop", {
    allowBlank: true,
  });

  C.lblBasis = widget.UI.Label("lblBasis", {});
  C.cboValueBasis = widget.UI.ComboBox("cboValueBasis", {
    allowBlank: false,
    onChange: cboValueBasis_Change,
    width: "16em",
  });

  C.lblNotes = widget.UI.Label("lblNotes", {});
  C.txtReference = widget.UI.TextBox("txtReference", {
    maxLength: 20,
  });
  C.txtNotes = widget.UI.TextBox("txtNotes", {
    multiLine: true,
    rows: 3,
    maxLength: 255,
  });
  C.numValueCurrency = widget.UI.NumberBox("numValueCurrency", {
    readOnly: false,
    decimals: -1,
    minValue: -999999999999,
    maxValue: 999999999999,
  });
  C.numValuePercent = widget.UI.NumberBox("numValuePercent", {
    allowBlank: true,
    decimals: 4,
    minValue: 0,
    maxValue: 100,
    percentage: true,
  });
  C.chkValuePercentPerAnnum = widget.UI.CheckBox("chkValuePercentPerAnnum", {
    caption: "Per Annum?"
  });
  C.numMinValue = widget.UI.NumberBox("numMinValue", {
    readOnly: false,
    decimals: -1,
    minValue: -999999999999,
    maxValue: 999999999999,
  });
  C.numMaxValue = widget.UI.NumberBox("numMaxValue", {
    readOnly: false,
    decimals: -1,
    minValue: -999999999999,
    maxValue: 999999999999,
  });

  C.lblPaymentMethod = widget.UI.Label("lblPaymentMethod", {});
  C.pdaPaymentDetails = widget.UI.AccountIncomingPaymentDetails("pdaPaymentDetails", {
    allowBlank: true,
    paymentEntry: true,
  });

  C.lblWithdrawalMethod = widget.UI.Label("lblWithdrawalMethod", {});
  C.pdaWithdrawalDetails = widget.UI.AccountOutgoingPaymentDetails("pdaWithdrawalDetails", {
    allowBlank: true,
    paymentEntry: true,
  });

  C.lblTransfer = widget.UI.Label("lblTransfer", {});
  C.cboTransferToAccount = widget.UI.DBCombo("cboTransferToAccount", {
    allowBlank: false,
    limitToList: false,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });

  // Create Widget form
  // NOTE: Hide by default for a cleaner startup
  frmMain = new widget.UI.Form("frmMain", { captionWidth: "9em", textboxWidth: "20em", visible: false });

  // Create Tabs
  tabWizard = new widget.UI.Tabs("tabWizard", { style: "wizard" });

  // Handle Wizard Buttons
  cmdCancel = $("#cmdCancel");
  cmdBack = $("#cmdBack");
  cmdNext = $("#cmdNext");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabWizard_Cancel);
  cmdBack.click(function() { tabWizard_Move(-1); });
  cmdNext.click(function() { tabWizard_Move(1); });
  cmdFinish.click(function() { Form_ExecuteAction("Finish"); });

  cmdAdvanced = $("#cmdAdvanced");
  cmdAdvanced.click(function () {
    // Toggle Advanced
    mAdvancedVisible = !mAdvancedVisible;

    // Update Controls
    if (mAdvancedVisible) {
      // Showing
      $("body").addClass("advanced-visible");
      cmdAdvanced.attr("showing", true);
      C.lblElement.Text("Select the Element and optionally a Key to identify the Transaction");
    }
    else {
      // Not showing
      $("body").removeClass("advanced-visible");
      cmdAdvanced.attr("showing", false);
      C.lblElement.Text("Select the Element to identify the Transaction");
    }

    // Force resize
    tabWizard_Resize()
  });

  // Reset
  Form_Reset();
});

// ==========
// Reset Form
// ==========
function Form_Reset() {
  // Defaults

  // Set Tab
  tabWizard.SelectedTabId("General");

  // Resize
  Form_Resize();

  // Load Record (i.e., initialise wizard)
  Record_Load();
}

// ===========
// Load Record
// ===========
function Record_Load() {
  // Initialise
  mRecord = null;
  mRecord_StdTran = null;

  // Hide content
  frmMain.Visible(false);

  // Block UI
  widget.UI.Block("Initialising, please wait...");

  // Load Initialisation details
  widget.GetString("GetInitialisationInfo", {},
    // Success
    function (data) {
      mRecord = JSON.parse(data);
      mRecord_StdTran = mRecord.StandardTransaction;

      // Global Collections
      mElements = mRecord.Elements;

      // Give Collections ability to lookup by code
      widget.ArrayAllowLookupById(mElements, "ElementId");

      // Define Actions
      var actions = [];
      if (!mRecord.ReadOnly &amp;&amp; mRecord.CanDelete) actions.push({ groupId: "Record", actionId: "Delete", caption: "Delete", icon: "Delete" });
      if (!mRecord.ReadOnly &amp;&amp; !mRecord.IsNew &amp;&amp; !mRecord.EditJson) actions.push({ groupId: "Other", actionId: "MoveTop", caption: "Promote Standard Transaction to top of List", icon: "Move_Up" });
      frmMain.ActionsDefine(actions, "cmdActions", Form_ExecuteAction);

      // Load Fields
      Fields_Load();
    },

    // Fail
    function (message) {
      widget.UI.MsgBoxAlert("fail: " + message);
      Fields_Load();
    }
  );
}

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // Determine Element Type (required for Payment Details controls)
    // NOTE: mElement is generally set in cboElement_Change but we need it sooner than that
    var element = mElements.GetItem(mRecord_StdTran.ElementId);
    var elementType = element ? element.ElementType : "";

    // General
    C.cboElement.Text(mRecord_StdTran.ElementId);
    C.txtKey.Text(mRecord_StdTran.Key);

    C.cboCycle.Text(mRecord_StdTran.Cycle);
    C.cboCycleFirstPeriod.Text(mRecord_StdTran.CycleFirstPeriod);
    C.dateCycleFirstDate.Value(mRecord_StdTran.CycleFirstDate);
    C.dateDateNext.Value(mRecord_StdTran.DateNext);
    C.dateDateStop.Value(mRecord_StdTran.DateStop);

    C.cboValueBasis.Text(mRecord_StdTran.ValueBasisText);
    C.numValueCurrency.Value(mRecord_StdTran.ValueCurrency);
    C.numValuePercent.Value(mRecord_StdTran.ValuePercent);
    C.chkValuePercentPerAnnum.Value(mRecord_StdTran.ValuePercentPerAnnum);
    C.numMinValue.Value(mRecord_StdTran.MinValue);
    C.numMaxValue.Value(mRecord_StdTran.MaxValue);

    C.txtReference.Text(mRecord_StdTran.Reference);
    C.txtNotes.Text(mRecord_StdTran.Notes);

    // Payment Details
    // NOTE: Initialise both Payment and Withdrawal controls since the Element may be changed
    C.pdaPaymentDetails.ShowCashRegister(mRecord.ShowCashRegister);
    C.pdaPaymentDetails.Initialise(mRecord.AccountId, { branchId: mRecord_StdTran.BranchId, defaultValuesOnPaymentMethodChange: true, skipLoadAccountDetailsSmart: true, }, mRecord.OwnerClientIds);
    C.pdaPaymentDetails.FromBankingDetailsJson(mRecord_StdTran.BankingDetailsJson);
    C.pdaPaymentDetails.CashRegisterId(mRecord_StdTran.CashRegisterId);

    C.pdaWithdrawalDetails.ShowCashRegister(mRecord.ShowCashRegister);
    C.pdaWithdrawalDetails.Initialise(mRecord.AccountId, { branchId: mRecord_StdTran.BranchId, defaultValuesOnPaymentMethodChange: true, skipLoadAccountDetailsSmart: true, }, mRecord.OwnerClientIds);
    C.pdaWithdrawalDetails.FromBankingDetailsJson(mRecord_StdTran.BankingDetailsJson);
    C.pdaWithdrawalDetails.CashRegisterId(mRecord_StdTran.CashRegisterId);

    C.cboTransferToAccount.Text(mRecord_StdTran.TransferToAccountId);

    // Reverse Value; so this is a Transfer From (rather than to)
    if (mRecord_StdTran.ValueCurrency &amp;&amp; mRecord.AccountClass == "Deposit" &amp;&amp; elementType == "Transfer" &amp;&amp; mRecord.IsQuoteOrClosedQuote) {
      C.numValueCurrency.Value(mRecord_StdTran.ValueCurrency * -1);
    }
  }

  // Unblock UI
  widget.UI.Unblock();

  // Update Controls

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabWizard_Refresh();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  mRecord_StdTran.ElementId = C.cboElement.Text();
  mRecord_StdTran.Key = C.txtKey.Text();

  mRecord_StdTran.Cycle = C.cboCycle.Text();
  mRecord_StdTran.CycleFirstPeriod = C.cboCycleFirstPeriod.Text();
  mRecord_StdTran.CycleFirstDate = C.dateCycleFirstDate.Value();
  mRecord_StdTran.DateNext = C.dateDateNext.Value();
  mRecord_StdTran.DateStop = C.dateDateStop.Value();

  mRecord_StdTran.ValueBasisText = C.cboValueBasis.Text();
  mRecord_StdTran.ValueCurrency = C.numValueCurrency.Value();
  mRecord_StdTran.ValuePercent = C.numValuePercent.Value();
  mRecord_StdTran.ValuePercentPerAnnum = C.chkValuePercentPerAnnum.Value();
  mRecord_StdTran.MinValue = C.numMinValue.Value();
  mRecord_StdTran.MaxValue = C.numMaxValue.Value();

  mRecord_StdTran.Reference = C.txtReference.Text();
  mRecord_StdTran.Notes = C.txtNotes.Text();

  // Payment Details
  switch(mElement.ElementType) {
    case "Investment":
    case "InvestmentAdditional":
    case "PaymentReceived":
      // Payment
      mRecord_StdTran.BankingDetailsJson = C.pdaPaymentDetails.ToBankingDetailsJson();
      mRecord_StdTran.CashRegisterId = C.pdaPaymentDetails.CashRegisterId();
      break;

    case "Withdrawal":
      // Withdrawal
      mRecord_StdTran.BankingDetailsJson = C.pdaWithdrawalDetails.ToBankingDetailsJson();
      mRecord_StdTran.CashRegisterId = C.pdaWithdrawalDetails.CashRegisterId();
      break;
  }

  mRecord_StdTran.TransferToAccountId = C.cboTransferToAccount.Text();

  // Reverse Value; so this is a Transfer From (rather than to)
  if (mRecord_StdTran.ValueCurrency &amp;&amp; mRecord.AccountClass == "Deposit" &amp;&amp; mElement.ElementType == "Transfer" &amp;&amp; mRecord.IsQuoteOrClosedQuote) {
    mRecord_StdTran.ValueCurrency *= -1;
  }
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  var heading = "Standard Transaction";
  if (mRecord &amp;&amp; mRecord.IsNew) heading = "New " + heading;
  widget.SetHeading(heading);

  // Lists
  if (mRecord) {
    C.cboElement.RefreshFromStandardRange("Elements", mRecord.ElementFilter);

    C.cboCycle.ListFromCsvString(mRecord.CycleList);
    C.cboCycle.ListOtherFromCsvString(mRecord.CycleListOther);
    C.cboCycleFirstPeriod.ListFromCsvString(mRecord.CycleFirstPeriodList);
    C.cboCycleFirstPeriod.ListOtherFromCsvString(mRecord.CycleFirstPeriodListOther);

    C.cboValueBasis.ListFromCollection(mRecord.ValueBasisList, "Description");

    if (mRecord.TransferToAccountsList) {
      // Transfer list of Account restricted to common Clients
      C.cboTransferToAccount.RefreshFromCollection(mRecord.TransferToAccountsList, "Code", "Description");
    }
    else {
      // Unrestricted transfer list
      C.cboTransferToAccount.RefreshFromStandardRange("Accounts");
    }
  }

  // Check for Advanced options
  mHasAdvancedOptions = false;
  if (mRecord) {
    if (mRecord.ShowKey.toUpperCase() == "ADVANCED") mHasAdvancedOptions = true;

    switch(mRecord.ShowKey.toUpperCase()) {
      case "TRUE":
        C.lblElement.Text("Select the Element and optionally a Key to identify the Transaction");
        C.txtKey.VisibleRow(true);
        break;

      case "FALSE":
        C.lblElement.Text("Select the Element to identify the Transaction");
        C.txtKey.VisibleRow(false);
        break;

      case "ADVANCED":
        C.lblElement.Text("Select the Element to identify the Transaction");
        C.trKey.addClass("advanced");
        break;
    }
  }

  // Controls
  // NOTE: No need to call pageGeneral_Refresh since this is called at the end of cboElement_Change
  if (mRecord) {
    cboElement_Change();
    cboCycle_Change();
    if (mRecord.IsQuoteOrClosedQuote) cboCycleFirstPeriod_Change();
    cboValueBasis_Change();
  }

  // Update Buttons
  tabWizard_UpdateButtons();

  // Read-Only?
  if (mRecord &amp;&amp; mRecord.ReadOnly) frmMain.FormReadOnly(C, true);

  // Show content
  frmMain.Visible(mRecord != null);

  // Resize Tab
  tabWizard_Resize();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  // General

  // Tab
  tabWizard_Resize();
}

// ==============
// Wizard Buttons
// ==============
function tabWizard_Cancel() {
  if (widget.CanClose()) {
    widget.Close();
  }
  else {
    widget.Reset();
  }
}

function tabWizard_UpdateButtons() {
  // Back and Next Buttons?
  if (tabWizard.TabCount() == 1) {
    cmdBack.hide();
    cmdNext.hide();
  }
  else {
    var tabIndex = tabWizard.SelectedTabIndex();
    cmdBack.prop("disabled", tabIndex &lt;= 0);
    cmdNext.prop("disabled", tabIndex &gt;= tabWizard.TabCount() - 1);
  }

  // Cancel/ Finish Button
  if (mRecord &amp;&amp; mRecord.ReadOnly) {
    cmdCancel.hide();
    cmdFinish.text("Close");
  }
  else {
    if (tabWizard.TabCount() != 1) cmdFinish.prop("disabled", !cmdNext.prop("disabled"));
    cmdFinish.text("Save");
  }

  // Only show Advanced button on relevant pages
  cmdAdvanced.hide()
  if (mHasAdvancedOptions) {
    switch (tabWizard.SelectedTabId()) {
      case "General":
        cmdAdvanced.show();
        break;
    }
  }
}

// ==========
// Resize Tab
// ==========
function tabWizard_Resize() {
  switch (tabWizard.SelectedTabId()) {
    case "General":
      C.txtKey.WidthResizeFromParent();
      C.txtReference.WidthResizeFromParent();
      C.txtNotes.WidthResizeFromParent();
      break;

    default:
      break;
  }
}

// ===========
// Wizard Move
// ===========
function tabWizard_Move(direction) {
  var Ok;

  // Validate
  if (direction &gt; 0) {
    tabWizard_Validate(function () { tabWizard_MovePost(direction); });
  }
  else {
    // Can always move backwards
    tabWizard_MovePost(direction);
  }
}

function tabWizard_MovePost(direction) {
  var Ok = true;

  // Find Next Tab to Move To
  if (Ok) {
    var found = false;
    var newTab = tabWizard.SelectedTabIndex();

    do {
      newTab += direction;

      switch (tabWizard.GetTabIdByIndex(newTab)) {
        default:
          found = true;
          break;
      }

      // Found?
      if (found) {
        break;
      }
      else if (newTab == tabWizard.TabCount() - 1) {
        // Just in case!
        widget.UI.MsgBoxAlert("tabWizard_MovePost: Tab not handled!");
        break;
      }
    }
    while (true);

    // Refresh the New Tab
    tabWizard_Refresh(newTab);
  }
}

// ===========
// Refresh Tab
// ===========
function tabWizard_Refresh(newTab) {
  // Moving forward onto tab, so Load information
  if (newTab &gt;= tabWizard.SelectedTabIndex()) {
    switch (tabWizard.GetTabIdByIndex(newTab)) {
      case "General":
        pageGeneral_Refresh();
        break;

      default:
        break;
    }
  }

  // Make Tab it
  tabWizard.SelectedTabIndex(newTab);

  // Special
  switch(tabWizard.SelectedTabId()) {
  }

  // Tweak fields

  // Update Heading
  switch (tabWizard.SelectedTabId()) {
    case "General":
      if (!mRecord || mRecord.EditJson || !mRecord.AccountId) {
        frmMain.RefreshHeading(tabWizard.TabCaption(tabWizard.SelectedTabId()), "Enter Standard Transaction details.");
      }
      else {
        frmMain.RefreshHeading(tabWizard.TabCaption(tabWizard.SelectedTabId()), "Enter Standard Transaction details for Account '" + mRecord.AccountId + "', " + mRecord.AccountName + ".");
      }
      break;

    default:
      frmMain.RefreshHeading(tabWizard.TabCaption(tabWizard.SelectedTabId()), tabWizard.TabTooltipText(tabWizard.SelectedTabId()));
      break;
  }

  // Back, Next command buttons valid?
  tabWizard_UpdateButtons();

  // Resize Wizard
  tabWizard_Resize();

  // Focus
  switch (tabWizard.SelectedTabId()) {
    default:
      tabWizard.FocusFirst();
      break;
  }
}

// ===============
// Validate Wizard
// ===============
function tabWizard_Validate(validCallback) {
  // Read-Only
  if (mRecord.ReadOnly) {
    // No validation because form is Read Only
    validCallback();
    return;
  }

  // Validate
  var Ok = tabWizard.Validate(true);

  // Other client-side validation
  if (Ok) {
    switch (tabWizard.SelectedTabId()) {
      case "General":
        // Server side validation required
        break;

      default:
        // No validation
        validCallback();
        return;
    }
  }

  // Server-side validation
  if (Ok) {
    var params;

    switch (tabWizard.SelectedTabId()) {
      case "General":
        params = CreateFinishParameters();
        break;
    }

    if (params) {
      // Disable Form
      frmMain.FormDisable("Validating");

      // Extend parameters
      params.pageId = tabWizard.SelectedTabId();

      // Call WizardValidate method in Script
      widget.GetString("WizardValidate",
                       params,
                       function (data) { tabWizard_ValidatePost(validCallback, data); },
                       tabWizard_ValidateFail);
    }
    else {
      // No server-side validation
      validCallback();
    }
  }
}

function tabWizard_ValidatePost(validCallback, data) {
  // Enable form
  frmMain.FormEnable();

  // Parse Data
  var o = {};
  if (data) o = JSON.parse(data);

  if (o.FailedMessage) {
    // -----------------
    // Validation failed
    // -----------------
    var o = JSON.parse(data);
    widget.UI.MsgBoxAlert(o.FailedMessage);
    if (o.FailedControlId) $("#" + o.FailedControlId).focus();
  }
  else {
    // ---------------------
    // Validation successful
    // ---------------------
    // Validation could pass back additional information, e.g., to use in tabWizard_Refresh
    switch (tabWizard.SelectedTabId()) {
      case "General":
        // General
        if (o.Data &amp;&amp; o.Data.length != 0) {
          // Confirm warnings
          widget.UI.MsgBoxConfirmList("To continue, please approve the following:",
                                      o.Data,
                                      {
                                        heading: "Additional Confirmation",
                                        icon: "Warning",
                                      },
                                      function () { validCallback(); },
                                      null);

          // Allow callbacks to continue
          return;
        };

        break;
    }

    // Callback
    validCallback();
  }
}

function tabWizard_ValidateFail(errorMessage)
{
  widget.UI.MsgBoxAlert(errorMessage);

  // Enable form
  frmMain.FormEnable();
}

// =================
// Execute an Action
// =================
function Form_ExecuteAction(actionId) {
  switch (actionId.toUpperCase()) {
    case "DELETE":
      Form_ExecuteAction_Delete();
      break;

    case "FINISH":
      // Finish
      if (mRecord.ReadOnly) {
        tabWizard_Cancel();
      }
      else {
        Form_ExecuteAction_Finish();
      }
      break;

    case "MOVETOP":
      Form_ExecuteAction_MoveTop();
      break;

    default:
      window.alert(mViewName + ".Form_ExecuteAction: Unhandled action '" + actionId + "'");
      break;
  }
}

// =============
// Delete Action
// =============
function Form_ExecuteAction_Delete() {
  // Validate
  tabWizard_Validate(function () {
    // Confirm
    widget.UI.MsgBoxConfirmDelete("Are you sure you want to delete this Standard Transaction?",
                            {},
                            Form_ExecuteAction_DeletePost);
  });
}

function Form_ExecuteAction_DeletePost() {
  // Disable Form
  widget.UI.Block("Deleting, please wait...");

  // Delete
  widget.GetString("Delete", {},
    function (data) {
      // Close Form
      widget.Close();

      // Refresh Parent (to show updated details)
      widget.RefreshParent();
    },

    function (data) {
      // Show Error
      widget.UI.MsgBoxAlert(data);

      // Enable Form
      widget.UI.Unblock();
    }
  );
}

// ==================
// Move to Top Action
// ==================
function Form_ExecuteAction_MoveTop() {
  // Validate
  tabWizard_Validate(function () {
    // Confirm
    if (mRecord.PromptOnSave) {
      widget.UI.MsgBoxConfirm("Update the Standard Transaction and move it to the top of the list?",
                              { heading: "Update and Promote Standard Transaction" },
                              function () {
                                // Save and Move
                                Form_ExecuteAction_FinishPost("MoveTop");
                              });
    }
    else {
      // Save and Move without prompting
      Form_ExecuteAction_FinishPost("MoveTop");
    }
  });
}

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  // Validate
  tabWizard_Validate(function () {
    if (mRecord.EditJson) {
      // No prompt
      Form_ExecuteAction_FinishPost();
    }
    else if (mRecord.PromptOnSave) {
      // Confirm
      if (mRecord.IsNew) {
        var heading = "Add Standard Transaction";
        var message = "Are you sure you want to add the Standard Transaction to the Account?";
      }
      else {
        var heading = "Update Standard Transaction Details";
        var message = "Are you sure you want to update the Standard Transaction for this Account?";
      }

      widget.UI.MsgBoxConfirm(message,
                              {heading: heading},
                              Form_ExecuteAction_FinishPost,
                              null);
    }
    else {
      // Commit without prompting
      Form_ExecuteAction_FinishPost();
    }
  });
}

function Form_ExecuteAction_FinishPost(moveAction) {
  // Disable Form
  if (mRecord.EditJson) {
    widget.UI.Block("Updating, please wait...");
  }
  else {
    widget.UI.Block("Committing, please wait...");
  }

  // Create Parameters
  var params = CreateFinishParameters();

  // Move?
  if (moveAction) {
    params.MoveAction = moveAction;
  }

  // Finish
  widget.GetString("Finish", params,
    function (data) {
      data = JSON.parse(data);

      // Finalise
      if (data.Warning) {
        widget.UI.MsgBoxAlert("The Account Standard Transaction was successfully updated but the following warning was given:\n\n" + data.Warning, {}, Form_ExecuteAction_FinishPost_Finalise);
      }
      else {
        Form_ExecuteAction_FinishPost_Finalise(data);
      }
    },

    function (data) {
      // Show Error
      widget.UI.MsgBoxAlert(data);

      // Enable Form
      widget.UI.Unblock();
    }
  );
}

function Form_ExecuteAction_FinishPost_Finalise(data) {
  // Not really saving, just passing details back to parent form
  // NOTE: The reason we went through the whole save process was to validate and update details such as ElementDescription on the object
  if (mRecord.EditJson) {
    // Notify parent (e.g., New Account wizard) that a new Standard Transaction has been created or an item edited
    // NOTE: This is essential if this wizard needs to be run from a New Account wizard
    widget.ParentNotify("RecordUpdated", data.StandardTransactionJson);

    // Close
    widget.Close();
    return;
  }

  // Close Form
  widget.Close();

  // Refresh Parent (to show updated details)
  widget.RefreshParent();
}

// ==========
// cboElement
// ==========
function cboElement_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Get Element Type
  mElement = mElements.GetItem(C.cboElement.Text());

  // Default when Element changes
  if (e &amp;&amp; mElement) {
    // Update Cycle List
    C.cboCycle.ListFromCsvString(mElement.CycleList);
    C.cboCycle.ListOtherFromCsvString(mRecord.CycleListOther);

    // Update Cycle
    switch(mElement.ElementType) {
      case "Deposit":
        C.cboCycle.Text("Opening");
        break;
    }

    switch(mElement.ElementType) {
      case "Advance":
      case "Cost":
      case "Deposit":
        switch(mRecord.AccountClass) {
          case "Disbursement":
            if (mRecord.IsQuoteOrClosedQuote) {
              C.cboCycle.Text("Once");
              C.cboCycleFirstPeriod.Text("Opening");
            }
            break;

          case "LoanFR":
          case "LoanFT":
          case "LoanRC":
            if (mRecord.IsQuoteOrClosedQuote) {
              C.cboCycle.Text("Opening");
            }
            break;
        }
        break;

      case "PaymentReceived":
      case "Withdrawal":
        if (C.cboCycle.Text().toUpperCase() == "OPENING") {
          C.cboCycle.Text("");
        }
        break;
    }

    // Other defaults
    C.cboValueBasis.Text("Set Value");
    C.numValueCurrency.Value(mElement.TransactionValue);
    C.txtReference.Text(mElement.TransactionReference);
    C.txtNotes.Text(mElement.TransactionNotes);
  }

  // Refresh Page (regardless of whether updated by User)
  pageGeneral_Refresh();
}

// ========
// cboCycle
// ========
function cboCycle_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Refresh Page
  if (e) {
    pageGeneral_Refresh();
  }
}

// ===================
// cboCycleFirstPeriod
// ===================
function cboCycleFirstPeriod_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Refresh Page
  if (e) {
    pageGeneral_Refresh();
  }
}

// =============
// cboValueBasis
// =============
function cboValueBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Refresh Page
  if (e) {
    pageGeneral_Refresh();
  }
}

function CreateFinishParameters() {
  // Save Fields
  Fields_Save();

  return { StandardTransactionJson: JSON.stringify(mRecord_StdTran), Timestamp: mRecord.Timestamp };
}

// ===========
// pageGeneral
// ===========
function pageGeneral_Refresh() {
  if (mRecord) {
    // Element-related
    var elementType = mElement ? mElement.ElementType : "";

    switch(elementType) {
      case "Investment":
      case "InvestmentAdditional":
        // Investment
        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);

        C.lblPaymentMethod.VisibleRow(true);
        C.pdaPaymentDetails.Visible(true);

        C.lblWithdrawalMethod.VisibleRow(false);
        C.pdaWithdrawalDetails.Visible(false);

        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);
        break;

      case "PaymentReceived":
        // Payment Received
        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);

        C.lblPaymentMethod.VisibleRow(true);
        C.pdaPaymentDetails.Visible(true);
        C.pdaPaymentDetails.ShowCashRegister(mRecord.IsQuoteOrClosedQuote &amp;&amp; mRecord.AddOnBankingAdvanced);

        C.lblWithdrawalMethod.VisibleRow(false);
        C.pdaWithdrawalDetails.Visible(false);

        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);
        break;

      case "Refinance":
        // Refinance
        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);

        C.lblPaymentMethod.VisibleRow(false);
        C.pdaPaymentDetails.Visible(false);

        C.lblWithdrawalMethod.VisibleRow(false);
        C.pdaWithdrawalDetails.Visible(false);

        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);
        break;

      case "Transfer":
        // Transfer
        C.lblTransfer.VisibleRow(true);
        C.cboTransferToAccount.VisibleRow(true);

        switch(mRecord.AccountClass) {
          case "Deposit":
            if (C.cboCycle.Text() == "Opening") {
              C.lblTransfer.Text("Enter the Account to Transfer from");
            }
            else {
              C.lblTransfer.Text("Enter the Account to Transfer to");
            }
            break;

          default:
            C.lblTransfer.Text("Enter the Account to Transfer to");
            break;
        }

        C.lblPaymentMethod.VisibleRow(false);
        C.pdaPaymentDetails.Visible(false);

        C.lblWithdrawalMethod.VisibleRow(false);
        C.pdaWithdrawalDetails.Visible(false);

        C.lblTransfer.VisibleRow(true);
        C.cboTransferToAccount.VisibleRow(true);
        break;

      case "Withdrawal":
        // Withdrawal
        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);

        C.lblPaymentMethod.VisibleRow(false);
        C.pdaPaymentDetails.Visible(false);

        C.lblWithdrawalMethod.VisibleRow(true);
        C.pdaWithdrawalDetails.Visible(true);

        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);
        break;

      default:
        C.lblTransfer.VisibleRow(false);
        C.cboTransferToAccount.VisibleRow(false);

        C.lblPaymentMethod.VisibleRow(false);
        C.pdaPaymentDetails.Visible(false);

        C.lblWithdrawalMethod.VisibleRow(false);
        C.pdaWithdrawalDetails.Visible(false);
        break;
    }

    // Cycle-related
    switch(C.cboCycle.Text()) {
      case "Opening":
        // Opening
        C.cboCycleFirstPeriod.VisibleRow(false);
        C.dateDateNext.VisibleRow(false);
        C.dateDateStop.VisibleRow(false);

        switch(elementType) {
          case "Cost":
          case "Deposit":
          case "Fee":
          case "Journal":
            C.cboValueBasis.ReadOnly(false);
            break;

          default:
            C.cboValueBasis.ReadOnly(true);
            C.cboValueBasis.Text("Set Value");
            break;
        }
        break;

      case "Once":
        // Once
        C.cboCycleFirstPeriod.VisibleRow(mRecord.IsQuoteOrClosedQuote);
        C.dateDateNext.VisibleRow(!mRecord.IsQuoteOrClosedQuote);
        C.dateDateStop.VisibleRow(false);
        C.cboValueBasis.ReadOnly(false);
        break;

      default:
        // Other
        C.cboCycleFirstPeriod.VisibleRow(mRecord.IsQuoteOrClosedQuote);
        C.dateDateNext.VisibleRow(!mRecord.IsQuoteOrClosedQuote);
        C.dateDateStop.VisibleRow(true);
        C.cboValueBasis.ReadOnly(false);
        break;
    }

    // Cycle First Period-related
    switch(C.cboCycleFirstPeriod.Text().toUpperCase()) {
      case "ON DATE":
        C.dateCycleFirstDate.Visible(true);
        break;

      default:
        C.dateCycleFirstDate.Visible(false);
        break;
    }

    // Value Basis-related
    var valueBasis = C.cboValueBasis.ListIndex() == -1 ? "" : mRecord.ValueBasisList[C.cboValueBasis.ListIndex()].Code;
    switch(valueBasis) {
      case "PercentBalance":
      case "PercentCreditLimit":
      case "PercentCreditLimit2":
      case "PercentCreditLimit3":
      case "PercentRegularPayment":
      case "PercentTotalAdvances":
        C.numValueCurrency.VisibleRow(false);
        C.numValuePercent.VisibleRow(true);
        C.numMinValue.VisibleRow(true);
        C.numMaxValue.VisibleRow(true);
        break;

      default:
        C.numValueCurrency.VisibleRow(true);
        C.numValuePercent.VisibleRow(false);
        C.numMinValue.VisibleRow(false);
        C.numMaxValue.VisibleRow(false);
        break;
    }

    // Refinance Element cannot be edited
    if (elementType == "Refinance") {
      C.cboElement.ReadOnly(true);
      C.cboCycle.ReadOnly(true);
      C.numValueCurrency.ReadOnly(true);
    }
  }

  // Advanced Button visible?
  if (mRecord &amp;&amp; !mHasAdvancedOptions) {
    // Hide button
    cmdAdvanced.hide();

    // Remove advanced section styling for everything
    $("tr").removeClass("advanced");
  }
  else if (mAdvancedVisible) {
    // Showing
    $("body").addClass("advanced-visible");
    cmdAdvanced.attr("showing", true);
  }
  else {
    // Not showing
    $("body").removeClass("advanced-visible");
    cmdAdvanced.attr("showing", false);
  }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>Ibb5cykm0U+cCZDKn74w2g</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption />
    <HtmlWidgetAllowInitialEventCaching>false</HtmlWidgetAllowInitialEventCaching>
    <HtmlWidgetMaxHeight>1200</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>800</HtmlWidgetMaxWidth>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>false</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <HtmlWidgetSpecialEventShowAsSummaryPage>false</HtmlWidgetSpecialEventShowAsSummaryPage>
    <HtmlWidgetSummaryPageObjectType>None</HtmlWidgetSummaryPageObjectType>
    <Icon />
    <RestrictedOriginsListEnabled>false</RestrictedOriginsListEnabled>
    <RunAsAdministrator>false</RunAsAdministrator>
    <WebServiceName />
    <WebServiceAllowAnonymous>false</WebServiceAllowAnonymous>
    <WebServiceSendDebugInformation>false</WebServiceSendDebugInformation>
    <ShowInMenu>None</ShowInMenu>
    <ParametersType>Custom</ParametersType>
    <Parameters>
      <ISParameterDefs version="1.00">
        <Parameters>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>Form options.</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>If you do not specify a Default Transaction Type, the Transaction Type selection will be shown regardless of the settings specified below.</TooltipText>
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="ShowKey" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>Advanced</Value>
            <Visible>true</Visible>
            <List>True,False,Advanced</List>
            <LimitToList>true</LimitToList>
            <MaxLength>8</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="ReadOnly" type="Boolean">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>False</Value>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>TESTING</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>These are the Parameters required by this HTML Widget to function correctly.
They are listed here for testing purposes only.</TooltipText>
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="AccountId" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <List>RANGE.Accounts</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="AccountStdTranPk" type="Number">
            <BlankTip />
            <Caption>Standard Transaction Pk</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>For 'Quote' Accounts, this should be the 0-based index of the item in the collection</TooltipText>
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <DecimalPlaces>0</DecimalPlaces>
            <GroupDigits>false</GroupDigits>
            <MaxValue />
            <MinValue />
            <NumberSpecialType>None</NumberSpecialType>
            <SpinChange>1</SpinChange>
          </Parameter>
          <Parameter name="EditJson" type="Boolean">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>False</Value>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="IsRestructure" type="Boolean">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>False</Value>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="StandardTransactionJson" type="Text">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>Used by the New Account wizard to add and edit unsaved or "Quote" Standard Transactions.</TooltipText>
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <MaxLength>0</MaxLength>
            <Rows>4</Rows>
          </Parameter>
          <Parameter name="OwnerClientIds" type="Text">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>