<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2024-09-23T02:13:22.0000000">
    <CreatedUserId>ADMIN</CreatedUserId>
    <CreatedUtcDate>2024-04-15T01:19:07.9550000</CreatedUtcDate>
    <UpdatedUserId>ADMIN</UpdatedUserId>
    <UpdatedUtcDate>2024-09-23T02:13:11.8940000</UpdatedUtcDate>
    <ScriptId>HWATE</ScriptId>
    <Description>Account Type Edit</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_AccountTypeEdit
Option Explicit On
Option Strict On

' #################################################################
' Account Type Edit form HTML Widget
'
' Copyright (C) Intersoft Systems Limited 2022
'
' Version: 1.07 (23/09/2024)
'
' Usage: System-supplied HTML Widget
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.00  06/12/2022  ISS      J028170   Created
'    1.01  10/01/2023  ISS      J030276   Data-loss warning now displaying correctly
'                      ISS      J030261   Various improvements
'          07/02/2023  ISS      J030093   Implemented Promotions
'    1.02  22/03/2023  ISS      J030144   Default Ledger field now ignores the mandatory setting on the Information List (should always be able to leave blank at an Account Type level)
'          04/04/2023  ISS      J030846   Enhancements to the Documents grid
'    1.03  28/07/2023  ISS      J030358   Closed Pending options now available for Deposit Accounts
'          14/08/2023  ISS      J030978   Inactive Documents no longer hidden since this interferes with grid groupings
'    1.04  25/10/2023  ISS      J032284   Added Promotion tooltip to explain the Parameter Set
'    1.05  14/03/2024  ISS      J032970   Added PayTo Defaults
'    1.06  31/07/2024  ISS      J033963   Added OtherInterestDescription
'    1.07  20/08/2024  ISS      J034107   GetAccountClassDetails loads the Account Type using the "GetAccountType" function so duplicating works correctly
'          23/09/2024  ISS      J034337   Changed the Interest Period to display the same as the desktop form
' #################################################################

' Constants
Private Const FORM_KEY As String = "AccountTypes"

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

' Standard Parameters
Private mAccountTypeId As String
Private mDuplicateRecordId As String
Private mPage As String
Private mReadOnly As Boolean

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 Standard Parameters
  With mStartupParameters
    mAccountTypeId = .GetString("AccountTypeId") ' Always use Startup Parameters since the Account Type Id may be updated
  End With
  With mCombinedParameters
    mDuplicateRecordId = .GetString("DuplicateRecordId")
    mPage = .GetString("Page")
    mReadOnly = .GetBoolean("ReadOnly")
  End With

  ' Validate
  Main = finBL.HtmlWidgetUtilities.HasPermissionToViewFormKey(FORM_KEY)

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

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

      Case "GetAccountClassDetails"
        ' Get Account Class Details
        Main = GetAccountClassDetails(returnValue)

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

      Case "GetProductTypeDetails"
        ' Get Product Type Details
        Main = GetProductTypeDetails(returnValue)

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

End Function

''' &lt;summary&gt;
'''  Load AccountType.
''' &lt;/summary&gt;
Private Function GetAccountType(ByRef accountType As finAccountType) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Create and Load Account Type
  If Success Then
    ' Create Account Type
    accountType = finBL.CreateAccountType()

    ' Load Account Type
    If Len(mDuplicateRecordId) &lt;&gt; 0 Then
      ' New record (by duplicating existing)
      Success = accountType.Load(mDuplicateRecordId)
      If Success Then accountType.Duplicate()
    ElseIf Len(mAccountTypeId) = 0 Then
      ' New record
    Else
      Success = accountType.Load(mAccountTypeId)
    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 AccountType As finAccountType
  Dim Document As finDocumentRO
  Dim DocumentAvailable As finAccountTypeDocument
  Dim Element As finElementRO
  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim InterestCycleFriendlyMnemonic As String
  Dim ObjectScript As finObjectScript
  Dim PaymentCycleFriendlyMnemonic As String
  Dim RateTable As finAccountTypeRateTable
  Dim ScriptRO As finScriptRO
  Dim StatementCycleFriendlyMnemonic As String
  Dim Success As Boolean  

  ' Assume Success
  Success = True

  ' Validate

  ' Get Account Type
  If Success Then
    Success = GetAccountType(AccountType)
  End If

  ' Get Date Cycle Friendly Mnemonics
  If Success Then
    finBL.Utilities.DateCycleGetDescription(True, AccountType.InterestCycle, InterestCycleFriendlyMnemonic) 
    finBL.Utilities.DateCycleGetDescription(True, AccountType.PaymentCycle, PaymentCycleFriendlyMnemonic)
    finBL.Utilities.DateCycleGetDescription(True, AccountType.StatementCycle, StatementCycleFriendlyMnemonic)
  End If
  
  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Form
      .PageId = mPage
      If finBL.Database.IsReadOnly OrElse mReadOnly OrElse Not finBL.CurrentUser.Permissions.Allow("Admin.AccountTypes") Then
        .ReadOnly = True
      Else
        .ReadOnly = False
      End If

      ' Record
      .Pk = AccountType.Pk
      .Timestamp = AccountType.Timestamp

      ' Page Permissions (defined here since they are used below)
      ' NOTE: Some of these values may be set to false client-side based on the Account Class
      .AllowPageGeneral = True
      .AllowPageNewAccounts = True
      .AllowPageTerm = True
      .AllowPagePayments = True
      .AllowPageInterest = True
      .AllowPageInterestOptions = True
      .AllowPageRateTables = finBL.Settings.AddOns.RateTable
      .AllowPageDefaults = True
      .AllowPageCreditLimit = True
      .AllowPageCloseOptions = True
      .AllowPageOther = True
      .AllowPagePromotions = finBL.Settings.AddOns.Promotions ' Items are maintained via the finPOWER Connect Cloud form, this page is just for information
      .AllowPageTransactions = True
      .AllowPageDocuments = True
      .AllowPageRules = True ' Items are maintained via the finPOWER Connect Cloud form, this page is just for information
      .AllowPageAccounting = True
      .AllowPageScripts = True
      .AllowPageUserDefined = True ' GetAccountClassDetails will return the Parameter Set to use which in turn will allow this page to be hidden client-side

      ' General
      .AccountTypeId = AccountType.AccountTypeId ' Always need to return AccountType Id
      If .AllowPageGeneral Then
        .Active = AccountType.Active
        .Description = AccountType.Description

        .AccountClassText = AccountType.AccountClassText
        .ProductTypeId = AccountType.ProductTypeId
        .CreditTypeText = AccountType.CreditTypeText
        .ConsumerRegulationTypeText = AccountType.ConsumerRegulationTypeText

        .CreditSale = AccountType.CreditSale
        .LaybySale = AccountType.LaybySale

        .CreditReportingAccountType = AccountType.CreditReportingAccountType
        
        .Category = AccountType.Category
        .Icon = AccountType.Icon

        .Notes = AccountType.Notes
      End If

      ' New Accounts
      If .AllowPageNewAccounts Then
        .NextAccountId = AccountType.NextAccountId
        .DefaultDescription = AccountType.DefaultDescription
        .DefaultLedger = AccountType.DefaultLedger

        .OptionAllowLedger = AccountType.OptionAllowLedger
        .OptionAllowFirstPaymentDate = AccountType.OptionAllowFirstPaymentDate
        .OptionAllowRegularPayment = AccountType.OptionAllowRegularPayment
        .OptionAllowBalloonPayment = AccountType.OptionAllowBalloonPayment
        .OptionAllowResidualValue = AccountType.OptionAllowResidualValue
        .OptionAllowMaturityDate = AccountType.OptionAllowMaturityDate
        .OptionAllowMaturityInstruction = AccountType.OptionAllowMaturityInstruction
        .OptionAllowMinimumPayment = AccountType.OptionAllowMinimumPayment
        .OptionAllowMinimumPaymentDueDays = AccountType.OptionAllowMinimumPaymentDueDays
        .OptionAllowMinimumPaymentHoldTo = AccountType.OptionAllowMinimumPaymentHoldTo
        .OptionAllowTaxCategory = AccountType.OptionAllowTaxCategory
        .OptionAllowInterestCycle = AccountType.OptionAllowInterestCycle
        .OptionAllowInterest = AccountType.OptionAllowInterest
        .OptionAllowStartupInterest = AccountType.OptionAllowStartupInterest
        .OptionAllowTotalInterest = AccountType.OptionAllowTotalInterest
        .OptionAllowReviewDate = AccountType.OptionAllowReviewDate
        .DefaultReviewPeriod = accounttype.DefaultReviewPeriod

        .OptionShowFinancialPageOverridingPaymentsTab = AccountType.OptionShowFinancialPageOverridingPaymentsTab
        .OptionShowFinancialPageOptionsTab = AccountType.OptionShowFinancialPageOptionsTab
        .OptionShowInstalmentsDrilldown = AccountType.OptionShowInstalmentsDrilldown
        .OptionShowInstalmentsDrilldownWeb = AccountType.OptionShowInstalmentsDrilldownWeb
        .OptionShowFinancialPagePrintQuotation = AccountType.OptionShowFinancialPagePrintQuotation

        .UserDefinedShowInNewAccountWizard = AccountType.UserDefinedShowInNewAccountWizard
        .DisbursementsShowInNewAccountWizard = AccountType.DisbursementsShowInNewAccountWizard

        .OptionDefaultQuoteStatus = AccountType.OptionDefaultQuoteStatus
        .OptionDefaultResidualValueFromNetAdvance = AccountType.OptionDefaultResidualValueFromNetAdvance
        .OptionDefaultResidualValueFromSecurities = AccountType.OptionDefaultResidualValueFromSecurities
        .OptionDefaultPrintContractDocument = AccountType.OptionDefaultPrintContractDocument

        .ShowWarningInfos = AccountType.ShowWarningInfos
        .ShowWarningAlerts = AccountType.ShowWarningAlerts
      End If

      ' Term
      If .AllowPageTerm Then
        .TermEntryMethodText = AccountType.TermEntryMethodText

        .TermUse = AccountType.TermUse
        .TermMandatory = AccountType.TermMandatory

        .TermOnCall = AccountType.TermOnCall

        .Term = AccountType.Term
        .TermOnDate = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountType.TermOnDate)
        .TermList = AccountType.TermList
        .TermLimitToList = AccountType.TermLimitToList

        .TermNumberOfPayments = AccountType.TermNumberOfPayments

        .TermMinimum = AccountType.TermMinimum
        .TermMaximum = AccountType.TermMaximum

        .OptionAllowPayArrangeExtendTerm = AccountType.OptionAllowPayArrangeExtendTerm
        .TermRollForward = AccountType.TermRollForward
        .MaturityGraceDays = AccountType.MaturityGraceDays
        .TermCalculateSchedulePastMaturityDate = AccountType.TermCalculateSchedulePastMaturityDate

        .MaturityInstructionText = AccountType.MaturityInstructionText
        .MaturityAvailableInstructionsText = AccountType.MaturityAvailableInstructionsText

        .MaturityAccountTypeId = AccountType.MaturityAccountTypeId
        .MaturityAccountTypesNew = AccountType.MaturityAccountTypesNew
        .MaturityReinvestmentCommonClient = AccountType.MaturityReinvestmentCommonClient

        .MaturityPaymentAvailableTypesText = AccountType.MaturityPaymentAvailableTypesText
        .MaturityPaymentTypeText = AccountType.MaturityPaymentTypeText
        .MaturityAccountTypesTransfer = AccountType.MaturityAccountTypesTransfer
        .MaturityTransferCommonClient = AccountType.MaturityTransferCommonClient
      End If

      ' Payments
      If .AllowPagePayments Then
        .PaymentCycle = PaymentCycleFriendlyMnemonic
        .PaymentCycleList = AccountType.PaymentCycleList
        .PaymentCycleLimitToList = AccountType.PaymentCycleLimitToList
        
        .PaymentFirstPeriod = AccountType.PaymentFirstPeriod
        .PaymentFirstDate = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountType.PaymentFirstDate)      
        .PaymentFirstPeriodList = AccountType.PaymentFirstPeriodList
        .PaymentFirstPeriodLimitToList = AccountType.PaymentFirstPeriodLimitToList
        .PaymentFirstPeriodMaximum = AccountType.PaymentFirstPeriodMaximum
        
        .MinimumPaymentBasis = AccountType.MinimumPaymentBasisText
        .MinimumPaymentValue = AccountType.MinimumPaymentValue
        .MinimumPaymentPercent = AccountType.MinimumPaymentPercent
        .MinimumPaymentDueDays = AccountType.MinimumPaymentDueDays
        .MinimumPaymentMoveToNextBusinessDay = AccountType.MinimumPaymentMoveToNextBusinessDay
        .MinimumPaymentCarryForwardPrepaid = AccountType.MinimumPaymentCarryForwardPrepaid
        
        .MinimumPaymentHoldToPeriod = AccountType.MinimumPaymentHoldToPeriod
        .MinimumPaymentHoldToDate = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountType.MinimumPaymentHoldToDate)
        .MinimumPaymentHoldToList = AccountType.MinimumPaymentHoldToList
        .MinimumPaymentHoldToLimitToList = AccountType.MinimumPaymentHoldToLimitToList
        .MinimumPaymentHoldToMaximum = AccountType.MinimumPaymentHoldToMaximum
        
        .OptionPaymentAllocationMethod = AccountType.OptionPaymentAllocationMethodText
        .OptionPaymentsInAdvance = AccountType.OptionPaymentsInAdvance
        .OptionPaymentsRound = AccountType.OptionPaymentsRound
        .OptionPaymentsRoundMultiple = AccountType.OptionPaymentsRoundMultiple
        .OptionPaymentsFinalPlusBalloon = AccountType.OptionPaymentsFinalPlusBalloon
        .OptionPaymentsAdjustFinalBeforeBalloon = AccountType.OptionPaymentsAdjustFinalBeforeBalloon
        .OptionNextPaymentIncludesMinimumPayments = AccountType.OptionNextPaymentIncludesMinimumPayments
        .OptionAllowCreditBalancePreMaturity = AccountType.OptionAllowCreditBalancePreMaturity
        .PaymentEarlyPartialRepaymentWarning = AccountType.PaymentEarlyPartialRepaymentWarning
        .PaymentArrangementDefaultPrintAdvice = AccountType.PaymentArrangementDefaultPrintAdvice
        
        .OptionPaymentDirectDebitDateOpened = AccountType.OptionPaymentDirectDebitDateOpened
        .OptionPaymentDirectDebitBalloon = AccountType.OptionPaymentDirectDebitBalloon
        .PaymentDirectDebitLimitToBalance = AccountType.PaymentDirectDebitLimitToBalance
        .PaymentDirectDebitMinimumThreshold = AccountType.PaymentDirectDebitMinimumThreshold
        
        .NegativePaymentMatchDays = AccountType.NegativePaymentMatchDays
        
        .PaymentGracePeriodUse = AccountType.PaymentGracePeriodUse
        .PaymentGracePeriodDays = AccountType.PaymentGracePeriodDays
        .PaymentGracePeriodChargeDefault = AccountType.PaymentGracePeriodChargeDefault
        
        .BankReferenceCode = AccountType.BankReferenceCode
        
        .PayToDescription = AccountType.DefaultPayToDescription
        .PayToPurpose = AccountType.DefaultPayToPurpose
        .PayToAccountIdentifierType = AccountType.DefaultPayToAccountIdentifierType
        .PayToPaymentTermFrequency = AccountType.DefaultPayToPaymentTermFrequency
        .PayToPaymentTermType = AccountType.DefaultPayToPaymentTermType
      End If            
      
      ' Interest
      If .AllowPageInterest Then
        .InterestCycle = InterestCycleFriendlyMnemonic       
        .InterestCycleDateNext = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountType.InterestCycleDateNext)
        .InterestCycleList = AccountType.InterestCycleList
        .InterestCycleLimitToList = AccountType.InterestCycleLimitToList
        
        .StartupInterestAvailableTypes = AccountType.StartupInterestAvailableTypesText
        .StartupInterestType = AccountType.StartupInterestTypeText
        .StartupInterestRate = AccountType.StartupInterestRate
        .StartupInterestRateTableId = AccountType.StartupInterestRateTableId
        .StartupInterestRateTablePremium = AccountType.StartupInterestRateTablePremium
        .StartupInterestPeriod = AccountType.StartupInterestPeriod
        .StartupInterestToDate = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountType.StartupInterestToDate)
        .StartupInterestPeriodList = AccountType.StartupInterestPeriodList
        .StartupInterestPeriodLimitToList = AccountType.StartupInterestPeriodLimitToList
        .StartupInterestPeriodMaximum = AccountType.StartupInterestPeriodMaximum
        
        .InterestAvailableTypes = AccountType.InterestAvailableTypesText
        .InterestType = AccountType.InterestTypeText
        .InterestRate = AccountType.InterestRate
        .InterestRateTableId = AccountType.InterestRateTableId
        .InterestRateTablePremium = AccountType.InterestRateTablePremium
        
        .OtherInterestType = AccountType.OtherInterestTypeText
        .OtherInterestRate = AccountType.OtherInterestRate
        .OtherInterestDescription = AccountType.OtherInterestDescription
      End If
      
      ' Interest Options
      If .AllowPageInterestOptions Then        
        .OptionInterestAccruedMethod = AccountType.OptionInterestAccruedMethodText
        .OptionInterestRoundMethod = AccountType.OptionInterestRoundMethodText
        .OptionInterestBackdating = AccountType.OptionInterestBackdatingText
        .OptionInterestBackdatingConvertedTransactions = AccountType.OptionInterestBackdatingConvertedTransactions
        
        .OptionInterestOnInterest = AccountType.OptionInterestOnInterest
        .OptionInterestPrecomputed = (AccountType.OptionInterestChargeOriginal OrElse AccountType.OptionInterestChargeUpfront)
        .OptionInterestChargeUpfront = AccountType.OptionInterestChargeUpfront
        .OptionInterestChargeOriginal = AccountType.OptionInterestChargeOriginal
        .OptionInterestFlatRate = AccountType.OptionInterestFlatRate
        .OptionInterestPostMaturityBasis = AccountType.OptionInterestPostMaturityBasisText
        .InterestNegativeRateAllow = AccountType.InterestNegativeRateAllow
        .InterestNegativeRateTaxNotApplicable = AccountType.InterestNegativeRateTaxNotApplicable
        .TaxCertificateNotIssueAIL = AccountType.TaxCertificateNotIssueAIL
        
        .InterestCycleUpdateFromPaymentCycle = AccountType.InterestCycleUpdateFromPaymentCycle
        .OptionInterestAlignFirst = AccountType.OptionInterestAlignFirst
        .OptionInterestFixRateTable = AccountType.OptionInterestFixRateTable
        
        .InterestInstructionDown = AccountType.InterestInstructionDownText
        .InterestInstructionUp = AccountType.InterestInstructionUpText
        
        .InterestEffectiveDateOrEarliestPaymentDate = AccountType.InterestEffectiveDateOrEarliestPaymentDate
        .InterestEarliestDateDefault = AccountType.InterestEarliestDateDefault
        
        .ComparisonRateType = AccountType.ComparisonRateTypeText
        .ComparisonRateRoundingDecimals = AccountType.ComparisonRateRoundingDecimals
        .ComparisonRateMaximum = AccountType.ComparisonRateMaximum
        .ComparisonRateMaximumNextDate = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountType.ComparisonRateMaximumNextDate)
        .ComparisonRateMaximumNext = AccountType.ComparisonRateMaximumNext
        
        .InterestPaymentAvailableTypes = AccountType.InterestPaymentAvailableTypesText
        .InterestPaymentType = AccountType.InterestPaymentTypeText
        .InterestCommonClient = AccountType.InterestCommonClient
        .InterestPaymentRollForward = AccountType.InterestPaymentRollForward
        .InterestPaymentCompoundFinal = AccountType.InterestPaymentCompoundFinal
        .ReinvestmentPreserveInterestPaymentType = AccountType.ReinvestmentPreserveInterestPaymentType
        
        .InterestIsFromDividends = AccountType.InterestIsFromDividends
        
        .ShowZeroInterestTransactions = AccountType.ShowZeroInterestTransactions
      End If
      
      ' Rate Tables
      If .AllowPageRateTables Then
        .StandardRateTableId = AccountType.StandardRateTableId

        .RateTables = New List(Of AccountTypeRateTable)
        For Each RateTable In AccountType.RateTables
          .RateTables.Add(New AccountTypeRateTable(RateTable))
        Next
        .RateTables.Sort(AddressOf RateTables_SortComparer)
      End If

      ' Overdue &amp; Defaults
      If .AllowPageDefaults Then
        .OverdueLimitToBalance = AccountType.OverdueLimitToBalance
        .ContractualOverdueLimitToBalance = AccountType.ContractualOverdueLimitToBalance
        
        .OverdueSmallBalanceThreshold = AccountType.OverdueSmallBalanceThreshold
        .ContractualOverdueSmallBalanceThreshold = AccountType.ContractualOverdueSmallBalanceThreshold
        
        .DefaultInterestRateBasis = AccountType.DefaultInterestRateBasisText
        .DefaultInterestRate = AccountType.DefaultInterestRate
        
        .DefaultInterestInDefault = AccountType.DefaultInterestInDefault
        .DefaultInterestPostMaturity = AccountType.DefaultInterestPostMaturity
        .DefaultInterestPostFinalDate = AccountType.DefaultInterestPostFinalDate
        
        .DefaultInterestOverdueBasis = AccountType.DefaultInterestOverdueBasisText
        .DefaultInterestOverdueThreshold = AccountType.DefaultInterestOverdueThreshold        
        
        Select Case AccountType.DefaultInterestOverdueChargeBasis
          Case isefinDefaultInterestOverdueChargeBasis.Balance
            .DefaultInterestOverdueChargeBasis = finBL.Enums.isefinDefaultInterestOverdueChargeBasis_ToString(isefinDefaultInterestOverdueChargeBasis.Balance)
            
          Case isefinDefaultInterestOverdueChargeBasis.Overdue
            If AccountType.DefaultInterestOverdueBasis = isefinDefaultInterestOverdueBasis.ContractualOverdue Then
              .DefaultInterestOverdueChargeBasis = "Contractual Overdue"
            Else
              .DefaultInterestOverdueChargeBasis = "Overdue"
            End If            
        End Select
        
        .DefaultInterestMinimumCharge = AccountType.DefaultInterestMinimumCharge
        
        .DefaultFeeChargeBasis = AccountType.DefaultFeeChargeBasisText
        .DefaultFeeValue = AccountType.DefaultFeeValue
        .DefaultFeeIgnoreLimit = AccountType.DefaultFeeIgnoreLimit
        
        .FacilityFeeChargeBasis = AccountType.FacilityFeeChargeBasisText
        .FacilityFeeValue = AccountType.FacilityFeeValue
        .FacilityFeeChargeThresholdApply = AccountType.FacilityFeeChargeThresholdApply
        .FacilityFeeChargeThresholdValue = AccountType.FacilityFeeChargeThresholdValue
        .FacilityFeeChargeIfMovement = AccountType.FacilityFeeChargeIfMovement
      End If
      
      ' Credit Limits
      If .AllowPageCreditLimit Then
        .CreditLimitCount = AccountType.CreditLimitCount
        .CreditLimitKeepOnRefinance = AccountType.CreditLimitKeepOnRefinance
        .CreditLimitUsePendingWithdrawals = AccountType.CreditLimitUsePendingWithdrawals
        .CreditLimitUseUnclearedFunds = AccountType.CreditLimitUseUnclearedFunds
        .CreditLimitUseOtherDeductions = AccountType.CreditLimitUseOtherDeductions
        .CreditLimitOtherDeductionsDescription = AccountType.CreditLimitOtherDeductionsDescription
        
        .CreditLimit1Description = AccountType.CreditLimit1Description
        .CreditLimit1 = AccountType.CreditLimit1
        .CreditLimit1Required = AccountType.CreditLimit1Required
        
        .CreditLimit2Description = AccountType.CreditLimit2Description
        .CreditLimit2 = AccountType.CreditLimit2
        .CreditLimit2Required = AccountType.CreditLimit2Required
        
        .CreditLimit3Description = AccountType.CreditLimit3Description
        .CreditLimit3 = AccountType.CreditLimit3
        .CreditLimit3Required = AccountType.CreditLimit3Required
        
        .OverLimitBasis = AccountType.OverLimitBasisText
        .OverLimitThresholdPercent = AccountType.OverLimitThresholdPercent
        .OverLimitThreshold = AccountType.OverLimitThreshold
        
        .OverLimitFeeChargeBasis = AccountType.OverLimitFeeChargeBasisText
        .OverLimitFeeValue = AccountType.OverLimitFeeValue
      End If
      
      ' Close Options
      If .AllowPageCloseOptions Then
        .ClosedPendingDefault = AccountType.ClosedPendingDefault
        .ClosedPendingReviewDays = AccountType.ClosedPendingReviewDays
        .ClosedPendingAutoClose = AccountType.ClosedPendingAutoClose
        
        .CloseLossFormula = AccountType.CloseLossFormulaText
        
        .RefinanceLossFormula = AccountType.RefinanceLossFormulaText
                
        .SmallBalanceWriteOffDebit = AccountType.SmallBalanceWriteOffDebit
        .SmallBalanceWriteOffCredit = AccountType.SmallBalanceWriteOffCredit
        .SmallBalanceRefundCredit = AccountType.SmallBalanceRefundCredit
                
        .OptionAutomaticClose = AccountType.OptionAutomaticClose
        .OptionAutomaticClosePreMaturity = AccountType.OptionAutomaticClosePreMaturity
        .OptionArchiveDeclinedUnwanted = AccountType.OptionArchiveDeclinedUnwanted
        .OptionAllowStatusClosedToOpen = AccountType.OptionAllowStatusClosedToOpen
      End If
      
      ' Other
      If .AllowPageOther Then
        .StatementUse = AccountType.StatementUse
        .StatementCycle = StatementCycleFriendlyMnemonic
        .StatementDateNext = finBL.HtmlWidgetUtilities.GetNullableJsonUtcDateFromDatabaseDate(AccountType.StatementDateNext)        
        
        .UserDefinedParameterSetId = AccountType.UserDefinedParameterSetId
        
        .DebtRatioThreshold = AccountType.DebtRatioThreshold
                
        .ClientStatisticSourceExtraAsset = AccountType.ClientStatisticSourceExtraAssetText
        .ClientStatisticSourceExtraLiability = AccountType.ClientStatisticSourceExtraLiabilityText
        .ClientStatisticSourceConsolidatedLiability = AccountType.ClientStatisticSourceConsolidatedLiabilityText
        .ClientStatisticSourceConsolidatedExpense = AccountType.ClientStatisticSourceConsolidatedExpenseText
              
        .IncludeAccountLevelInsurance = AccountType.IncludeAccountLevelInsurance
        .OptionAllowWithdrawals = AccountType.OptionAllowWithdrawals
        .DepositAllowWithdrawalsNegativeBalance = AccountType.DepositAllowWithdrawalsNegativeBalance
        .TransferCommonClient = AccountType.TransferCommonClient
        .OptionAllowRestructure = AccountType.OptionAllowRestructure
        .OptionAllowRefinanceInto = AccountType.OptionAllowRefinanceInto
        .OptionAllowRefinanceRedatedForward = AccountType.OptionAllowRefinanceRedatedForward
        .UserFlagA = AccountType.UserFlagA
        .UserFlagB = AccountType.UserFlagB
                
        .ShowAccountIdWithCheckDigit = AccountType.ShowAccountIdWithCheckDigit
        .ShowHistoryRating = AccountType.ShowHistoryRating
        .ShowTotalAdvances = AccountType.ShowTotalAdvances
        .ShowOverdue = AccountType.ShowOverdue
        .ShowContractualOverdue = AccountType.ShowContractualOverdue
      End If
      
      ' Promotions
      If .AllowPagePromotions Then
        .PromotionBasis = AccountType.PromotionBasisText
        .PromotionUserDefinedParameterSetId = AccountType.PromotionUserDefinedParameterSetId
      End If
      
      ' Transactions
      If .AllowPageTransactions Then
        .NetAdvanceMinimum = AccountType.NetAdvanceMinimum
        .NetAdvanceMaximum = AccountType.NetAdvanceMaximum
        .OptionCreateAdjustedToZeroTransactions = AccountType.OptionCreateAdjustedToZeroTransactions
      End If
      
      ' Documents
      If .AllowPageDocuments Then        
        .DocumentsAvailable = New List(Of AccountTypeDocument)
        For Each DocumentAvailable In AccountType.Documents
          .DocumentsAvailable.Add(New AccountTypeDocument(DocumentAvailable))
        Next
        .DocumentsAvailable.Sort(AddressOf DocumentsAvailable_SortComparer)
      End If

      ' Accounting
      If .AllowPageAccounting Then
        .ControlGlAccountId = AccountType.ControlGlAccountId
        .ClearingGlAccountId = AccountType.ClearingGlAccountId        
      End If

      ' Scripts
      If .AllowPageScripts Then
        .AccountTypeScriptLinks = New List(Of AccountTypeScriptLink)
        For Each ObjectScript In AccountType.ObjectScripts
          .AccountTypeScriptLinks.Add(New AccountTypeScriptLink(ObjectScript, AccountType.ObjectScripts.ObjectName))
        Next 
      End If
      
      ' User Defined
      If .AllowPageUserDefined Then
        .UserDataJson = AccountType.UserData.ToSimpleJsonString()
      End If
      
      ' Permissions

      ' Lists
      .AccountCalcComparisonRateTypeList = finBL.Enums.isefinAccountCalcComparisonRateType_GetList().ToCsvString()      
      .AccountClassList = finBL.Enums.isefinAccountClass_ToCodeDescriptionList().ToJsonObject()
      .AccountCloseLossFormulaList = finBL.Enums.isefinAccountCloseLossFormula_GetList(AccountType.AccountClass).ToCsvString()
      .AccountInterestInstructionList = finBL.Enums.isefinAccountInterestInstruction_GetList(False).ToCsvString()
      .AccountInterestPaymentTypeList = finBL.Enums.isefinAccountInterestPaymentType_GetList().ToCsvString()      
      .AccountInterestTypeList = finBL.Enums.isefinAccountInterestType_GetCodeDescriptionList(AccountType.AccountClass, False).ToJsonObject()
      .AccountTypePromotionBasisList = finBL.Enums.isefinAccountTypePromotionBasis_GetList().ToCsvString()
      .AccountTypeStatisticSourceList = finBL.Enums.isefinAccountTypeStatisticSource_GetList().ToCsvString()
      .AccountStartupInterestTypeList = finBL.Enums.isefinAccountInterestType_GetCodeDescriptionList(AccountType.AccountClass, True).ToJsonObject()
      .CreditTypeList = finBL.Enums.isefinAccountCreditType_ToCodeDescriptionList().ToJsonObject()
      .DefaultFeeChargeBasisList = finBL.Enums.isefinDefaultFeeChargeBasis_ToCodeDescriptionList().ToJsonObject()
      .DefaultInterestOverdueBasisList = finBL.Enums.isefinDefaultInterestOverdueBasis_ToCodeDescriptionList().ToJsonObject()
      .DefaultInterestOverdueChargeBasisList = finBL.Enums.isefinDefaultInterestOverdueChargeBasis_GetList().ToCsvString()
      .DefaultInterestRateBasisList = finBL.Enums.isefinDefaultInterestRateBasis_GetList.ToCsvString()
      .ConsumerRegulationTypeList = finBL.Enums.isefinAccountConsumerRegulationType_ToCodeDescriptionList().ToJsonObject()
      .DefaultReviewPeriodList = ",Opening,Today,7 Days,14 Days,30 Days,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years"
      .FacilityFeeChargeBasisList = finBL.Enums.isefinFacilityFeeChargeBasis_ToCodeDescriptionList().ToJsonObject()
      .IconList = finBL.AccountTypeFunctions.GetIconList().ToCsvString()
      .InterestAccruedMethodList = finBL.Enums.isefinAccountCalcAccruedInterestMethod_GetList().ToCsvString()
      .InterestBackdatingList = finBL.Enums.isefinAccountInterestBackdating_ToCodeDescriptionList().ToJsonObject()
      .InterestPostMaturityBasis = finBL.Enums.isefinInterestPostMaturityBasis_GetList().ToCsvString()      
      .InterestRoundMethodList = finBL.Enums.isefinAccountCalcInterestRoundMethod_GetList().ToCsvString()
      .InterestTypeAvailableList = finBL.Enums.isefinAccountInterestType_GetList(AccountType.AccountClass, False).ToCsvString()      
      .MaturityInstructionList = finBL.Enums.isefinAccountMaturityInstruction_GetList().ToCsvString()
      .MaturityPaymentTypeList = finBL.Enums.isefinAccountMaturityPaymentType_GetList().ToCsvString()
      .MinimumPaymentBasisList = finBL.Enums.isefinAccountMinimumPaymentBasis_ToCodeDescriptionList().ToJsonObject()
      .OtherInterestTypeList = finBL.Enums.isefinAccountOtherInterestType_ToCodeDescriptionList().ToJsonObject()
      .OverLimitBasisList = finBL.Enums.isefinOverLimitBasis_ToCodeDescriptionList().ToJsonObject()
      .OverLimitFeeBasisList = finBL.Enums.isefinOverLimitFeeChargeBasis_ToCodeDescriptionList().ToJsonObject()  
      .PaymentAllocationMethodList = finBL.Enums.isefinAccountPaymentAllocationMethod_ToCodeDescriptionList().ToJsonObject()
      .StartupInterestTypeAvailableList = finBL.Enums.isefinAccountInterestType_GetList(AccountType.AccountClass, True).ToCsvString()
      .TermEntryMethodList = finBL.Enums.isefinAccountTermEntryMethod_ToCodeDescriptionList().ToJsonObject()
      .PayToPurposeList = finBL.BankingInterface.GetPayToAgreementPurposeList().ToCsvString()
      .PayToAccountIdentifierTypeList = finBL.BankingInterface.GetPayToAccountIdentifierTypeList().ToCsvString()
      .PayToPaymentTermFrequencyList = finBL.BankingInterface.GetPayToPaymentTermFrequencyList().ToCsvString()
      .PayToPaymentTermTypeList = finBL.BankingInterface.GetPayToPaymentTermTypeList().ToCsvString()
  
      ' Configuration      
      .AddOnBankingAdvanced = finBL.Settings.AddOns.BankingAdvanced
      .AddOnClientStatistics = finBL.Settings.AddOns.ClientStatistics
      .AddOnCostCentre = finBL.Settings.AddOns.CostCentre
      .AddOnDisbursements = finBL.Settings.AddOns.Disbursements
      .AddOnRateTable = finBL.Settings.AddOns.RateTable
      .AddOnSecurityRegister = finBL.Settings.AddOns.SecurityRegister
      .CountryCode = finBL.CountryCode
      .DisplayPayTo = finBL.Settings.AddOns.BankingAdvanced AndAlso finBL.BankingInterface.HasPayToPaymentMethods AndAlso finBL.CountryCode = "AU"
      .HideOtherPages = (mCombinedParameters.GetBoolean("HideOtherPages", False) AndAlso Len(mPage) &lt;&gt; 0)
      .PromptOnSave = finBL.CloudConnectFunctions.CloudConnectSettings.PromptOnSave
      .UserFlagACaption = finBL.Settings.AccountTypeFlagAResolved
      .UserFlagBCaption = finBL.Settings.AccountTypeFlagBResolved

      ' Global Collections
      For Each Document In finBL.Documents
        ' NOTE: Client Documents that link to a Log are required for specifying a Tax Certificate Document
        If Document.Active AndAlso (Document.DocumentType = isefinDocumentType.Account OrElse (Document.DocumentType = isefinDocumentType.Client AndAlso Not Document.AllowStandalone)) Then
          .Documents.Add(New DocumentDetails(Document))
        End If
      Next

      For Each Element In finBL.Elements
        If Element.Active Then
          .Elements.Add(New ElementDetails(Element))
        End If
      Next
      
      For Each ScriptRO In finBL.Scripts
        If ScriptRO.Active Then
          .Scripts.Add(New ScriptDetails(ScriptRO))
        End If
      Next 
    End With
  End If

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

  Return Success

End Function

Private Function DocumentsAvailable_SortComparer(x As AccountTypeDocument, y As AccountTypeDocument) As Integer

  Dim XCategory As String
  Dim YCategory As String

  XCategory = x.Category
  YCategory = y.Category

  ' Ensure (no category) always appears at the top
  If XCategory = "(no category)" Then XCategory = "AAAAAAAAA"
  If YCategory = "(no category)" Then YCategory = "AAAAAAAAA"

  If XCategory &gt; YCategory Then
    Return 1
  ElseIf XCategory &lt; YCategory Then
    Return -1
  Else
    If x.DocumentId &gt; y.DocumentId Then
      Return 1
    ElseIf x.DocumentId &lt; y.DocumentId Then
      Return -1
    Else
      Return 0
    End If
  End If

End Function

Private Function RateTables_SortComparer(x As AccountTypeRateTable, y As AccountTypeRateTable) As Integer

  Dim keyx As String
  Dim keyy As String

  keyx = x.Category &amp; "~" &amp; x.RateTableId
  keyy = y.Category &amp; "~" &amp; y.RateTableId

  Return String.Compare(keyx, keyy)

End Function

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

  Dim AccountType As finAccountType
  Dim AccountTypeDocument As AccountTypeDocument
  Dim AccountTypeDocumentLink As AccountTypeDocumentLink
  Dim AccountTypeElementLink As AccountTypeElementLink
  Dim AccountTypeRateTable As AccountTypeRateTable
  Dim AccountTypeScriptLink As AccountTypeScriptLink
  Dim Document As finAccountTypeDocument
  Dim DocumentLink As finAccountTypeDocumentLink
  Dim ElementLink As finAccountTypeElementLink
  Dim obj As Object
  Dim ObjectScript As finObjectScript
  Dim ParameterSetPk As Integer
  Dim RateTable As finAccountTypeRateTable
  Dim Record As FormInitialisationInfo
  Dim Success As Boolean
  
  ' Assume Success
  Success = True

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

  ' Get Account Type
  If Success Then
    Success = GetAccountType(AccountType)
  End If

  ' Find Parameter Set to Use
  If Success Then
    Select Case AccountType.AccountClass
      Case isefinAccountClass.Current : ParameterSetPk = finBL.Settings.AccountTypeCurrentUserDefinedParameterSetPk
      Case isefinAccountClass.Deposit : ParameterSetPk = finBL.Settings.AccountTypeDepositUserDefinedParameterSetPk
      Case isefinAccountClass.Disbursement : ParameterSetPk = finBL.Settings.AccountTypeDisbursementUserDefinedParameterSetPk
      Case isefinAccountClass.LoanFR : ParameterSetPk = finBL.Settings.AccountTypeLoanFRUserDefinedParameterSetPk
      Case isefinAccountClass.LoanFT : ParameterSetPk = finBL.Settings.AccountTypeLoanFTUserDefinedParameterSetPk
      Case isefinAccountClass.LoanRC : ParameterSetPk = finBL.Settings.AccountTypeLoanRCUserDefinedParameterSetPk
      Case Else
    End Select
  End If

  ' Validate
  If Success Then
    If Record.Timestamp &lt;&gt; AccountType.Timestamp Then
      Success = False
      finBL.Error.ErrorBegin("This record has been updated by another User.")
    End If
  End If

  ' Update and Save
  ' NOTE: Recheck Permissions in addition to the 'AllowPage' properties before updating to prevent spoofing
  If Success Then
    ' Begin Transaction
    If finBL.Database.TransactionBegin() Then
      ' Update AccountType
      With AccountType
        ' General
        If Record.AllowPageGeneral Then
          .AccountTypeId = Record.AccountTypeId
          .Active = Record.Active
          .Description = Record.Description

          .AccountClassText = Record.AccountClassText
          .ProductTypeId = Record.ProductTypeId
          .CreditTypeText = Record.CreditTypeText
          .ConsumerRegulationTypeText = Record.ConsumerRegulationTypeText

          .CreditSale = Record.CreditSale
          .LaybySale = Record.LaybySale

          .CreditReportingAccountType = Record.CreditReportingAccountType
          
          .Category = Record.Category
          .Icon = Record.Icon

          .Notes = Record.Notes
        End If

        ' New Accounts
        If Record.AllowPageNewAccounts Then
          .NextAccountId = Record.NextAccountId
          .DefaultDescription = Record.DefaultDescription
          .DefaultLedger = Record.DefaultLedger

          .OptionAllowLedger = Record.OptionAllowLedger
          .OptionAllowFirstPaymentDate = Record.OptionAllowFirstPaymentDate
          .OptionAllowRegularPayment = Record.OptionAllowRegularPayment
          .OptionAllowBalloonPayment = Record.OptionAllowBalloonPayment
          .OptionAllowResidualValue = Record.OptionAllowResidualValue
          .OptionAllowMaturityDate = Record.OptionAllowMaturityDate
          .OptionAllowMaturityInstruction = Record.OptionAllowMaturityInstruction
          .OptionAllowMinimumPayment = Record.OptionAllowMinimumPayment
          .OptionAllowMinimumPaymentDueDays = Record.OptionAllowMinimumPaymentDueDays
          .OptionAllowMinimumPaymentHoldTo = Record.OptionAllowMinimumPaymentHoldTo
          .OptionAllowTaxCategory = Record.OptionAllowTaxCategory
          .OptionAllowInterestCycle = Record.OptionAllowInterestCycle
          .OptionAllowInterest = Record.OptionAllowInterest
          .OptionAllowStartupInterest = Record.OptionAllowStartupInterest
          .OptionAllowTotalInterest = Record.OptionAllowTotalInterest
          .OptionAllowReviewDate = Record.OptionAllowReviewDate
          .DefaultReviewPeriod = Record.DefaultReviewPeriod

          .OptionShowFinancialPageOverridingPaymentsTab = Record.OptionShowFinancialPageOverridingPaymentsTab
          .OptionShowFinancialPageOptionsTab = Record.OptionShowFinancialPageOptionsTab
          .OptionShowInstalmentsDrilldown = Record.OptionShowInstalmentsDrilldown
          .OptionShowInstalmentsDrilldownWeb = Record.OptionShowInstalmentsDrilldownWeb
          .OptionShowFinancialPagePrintQuotation = Record.OptionShowFinancialPagePrintQuotation

          .UserDefinedShowInNewAccountWizard = Record.UserDefinedShowInNewAccountWizard
          .DisbursementsShowInNewAccountWizard = Record.DisbursementsShowInNewAccountWizard

          .OptionDefaultQuoteStatus = Record.OptionDefaultQuoteStatus
          .OptionDefaultResidualValueFromNetAdvance = Record.OptionDefaultResidualValueFromNetAdvance
          .OptionDefaultResidualValueFromSecurities = Record.OptionDefaultResidualValueFromSecurities
          .OptionDefaultPrintContractDocument = Record.OptionDefaultPrintContractDocument

          .ShowWarningInfos = Record.ShowWarningInfos
          .ShowWarningAlerts = Record.ShowWarningAlerts
        End If

        ' Term
        If Record.AllowPageTerm Then
          .TermEntryMethodText = Record.TermEntryMethodText

          .TermUse = Record.TermUse
          .TermMandatory = Record.TermMandatory

          .TermOnCall = Record.TermOnCall

          .Term = Record.Term
          .TermOnDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(Record.TermOnDate)
          .TermList = Record.TermList
          .TermLimitToList = Record.TermLimitToList

          .TermNumberOfPayments = Record.TermNumberOfPayments

          .TermMinimum = Record.TermMinimum
          .TermMaximum = Record.TermMaximum

          .OptionAllowPayArrangeExtendTerm = Record.OptionAllowPayArrangeExtendTerm
          .TermRollForward = Record.TermRollForward
          .MaturityGraceDays = Record.MaturityGraceDays
          .TermCalculateSchedulePastMaturityDate = Record.TermCalculateSchedulePastMaturityDate

          .MaturityInstructionText = Record.MaturityInstructionText
          .MaturityAvailableInstructionsText = Record.MaturityAvailableInstructionsText

          .MaturityAccountTypeId = Record.MaturityAccountTypeId
          .MaturityAccountTypesNew = Record.MaturityAccountTypesNew
          .MaturityReinvestmentCommonClient = Record.MaturityReinvestmentCommonClient

          .MaturityPaymentAvailableTypesText = Record.MaturityPaymentAvailableTypesText
          .MaturityPaymentTypeText = Record.MaturityPaymentTypeText
          .MaturityAccountTypesTransfer = Record.MaturityAccountTypesTransfer
          .MaturityTransferCommonClient = Record.MaturityTransferCommonClient
        End If

        ' Transactions
        If Record.AllowPageTransactions Then
          .NetAdvanceMinimum = Record.NetAdvanceMinimum
          .NetAdvanceMaximum = Record.NetAdvanceMaximum
          .OptionCreateAdjustedToZeroTransactions = Record.OptionCreateAdjustedToZeroTransactions
        End If
        
        ' Documents
        If Record.AllowPageDocuments Then
          ' Document Links
          For Each DocumentLink In AccountType.DocumentLinks
            If DocumentLink.Available Then
              For Each AccountTypeDocumentLink In Record.DocumentLinks
                If DocumentLink.DocumentLinkType = AccountTypeDocumentLink.DocumentLinkType Then
                  ' Update
                  DocumentLink.DocumentId = AccountTypeDocumentLink.DocumentId

                  Exit For
                End If
              Next
            End If
          Next

          ' Available Documents
          For Each Document In AccountType.Documents
            Document.Available = False
          Next
          For Each AccountTypeDocument In Record.DocumentsAvailable
            If AccountType.Documents.Exists(AccountTypeDocument.DocumentId) Then
              Document = AccountType.Documents(AccountTypeDocument.DocumentId)
              Document.Available = AccountTypeDocument.Available
            End If
          Next
        End If

        ' Payments
        If Record.AllowPagePayments Then
          .PaymentCycle = Record.PaymentCycle
          .PaymentCycleList = Record.PaymentCycleList
          .PaymentCycleLimitToList = Record.PaymentCycleLimitToList
          
          .PaymentFirstPeriod = Record.PaymentFirstPeriod
          .PaymentFirstDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(Record.PaymentFirstDate)      
          .PaymentFirstPeriodList = Record.PaymentFirstPeriodList
          .PaymentFirstPeriodLimitToList = Record.PaymentFirstPeriodLimitToList
          .PaymentFirstPeriodMaximum = Record.PaymentFirstPeriodMaximum
          
          .MinimumPaymentBasisText = Record.MinimumPaymentBasis
          .MinimumPaymentValue = Record.MinimumPaymentValue
          .MinimumPaymentPercent = Record.MinimumPaymentPercent
          .MinimumPaymentDueDays = Record.MinimumPaymentDueDays
          .MinimumPaymentMoveToNextBusinessDay = Record.MinimumPaymentMoveToNextBusinessDay
          .MinimumPaymentCarryForwardPrepaid = Record.MinimumPaymentCarryForwardPrepaid
          
          .MinimumPaymentHoldToPeriod = Record.MinimumPaymentHoldToPeriod
          .MinimumPaymentHoldToDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(Record.MinimumPaymentHoldToDate)
          .MinimumPaymentHoldToList = Record.MinimumPaymentHoldToList
          .MinimumPaymentHoldToLimitToList = Record.MinimumPaymentHoldToLimitToList
          .MinimumPaymentHoldToMaximum = Record.MinimumPaymentHoldToMaximum
          
          .OptionPaymentAllocationMethodText = Record.OptionPaymentAllocationMethod
          .OptionPaymentsInAdvance = Record.OptionPaymentsInAdvance
          .OptionPaymentsRound = Record.OptionPaymentsRound
          .OptionPaymentsRoundMultiple = Record.OptionPaymentsRoundMultiple
          .OptionPaymentsFinalPlusBalloon = Record.OptionPaymentsFinalPlusBalloon
          .OptionPaymentsAdjustFinalBeforeBalloon = Record.OptionPaymentsAdjustFinalBeforeBalloon
          .OptionNextPaymentIncludesMinimumPayments = Record.OptionNextPaymentIncludesMinimumPayments
          .OptionAllowCreditBalancePreMaturity = Record.OptionAllowCreditBalancePreMaturity
          .PaymentEarlyPartialRepaymentWarning = Record.PaymentEarlyPartialRepaymentWarning
          .PaymentArrangementDefaultPrintAdvice = Record.PaymentArrangementDefaultPrintAdvice
          
          .OptionPaymentDirectDebitDateOpened = Record.OptionPaymentDirectDebitDateOpened
          .OptionPaymentDirectDebitBalloon = Record.OptionPaymentDirectDebitBalloon
          .PaymentDirectDebitLimitToBalance = Record.PaymentDirectDebitLimitToBalance
          .PaymentDirectDebitMinimumThreshold = Record.PaymentDirectDebitMinimumThreshold
          
          .NegativePaymentMatchDays = Record.NegativePaymentMatchDays
          
          .PaymentGracePeriodUse = Record.PaymentGracePeriodUse
          .PaymentGracePeriodDays = Record.PaymentGracePeriodDays
          .PaymentGracePeriodChargeDefault = Record.PaymentGracePeriodChargeDefault
          
          .BankReferenceCode = Record.BankReferenceCode
          
          .DefaultPayToDescription = Record.PayToDescription
          .DefaultPayToPurpose = Record.PayToPurpose
          .DefaultPayToAccountIdentifierType = Record.PayToAccountIdentifierType
          .DefaultPayToPaymentTermFrequency = Record.PayToPaymentTermFrequency
          .DefaultPayToPaymentTermType = Record.PayToPaymentTermType
        End If
        
        ' Interest
        If Record.AllowPageInterest Then
          .InterestCycle = Record.InterestCycle
          .InterestCycleDateNext = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(Record.InterestCycleDateNext)
          .InterestCycleList = Record.InterestCycleList
          .InterestCycleLimitToList = Record.InterestCycleLimitToList
          
          .StartupInterestAvailableTypesText = Record.StartupInterestAvailableTypes
          .StartupInterestTypeText = Record.StartupInterestType
          .StartupInterestRate = Record.StartupInterestRate
          .StartupInterestRateTableId = Record.StartupInterestRateTableId
          .StartupInterestRateTablePremium = Record.StartupInterestRateTablePremium
          .StartupInterestPeriod = Record.StartupInterestPeriod
          .StartupInterestToDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(Record.StartupInterestToDate)
          .StartupInterestPeriodList = Record.StartupInterestPeriodList
          .StartupInterestPeriodLimitToList = Record.StartupInterestPeriodLimitToList
          .StartupInterestPeriodMaximum = Record.StartupInterestPeriodMaximum
          
          .InterestAvailableTypesText = Record.InterestAvailableTypes
          .InterestTypeText = Record.InterestType
          .InterestRate = Record.InterestRate
          .InterestRateTableId = Record.InterestRateTableId
          .InterestRateTablePremium = Record.InterestRateTablePremium
          
          .OtherInterestTypeText = Record.OtherInterestType
          .OtherInterestRate = Record.OtherInterestRate
          .OtherInterestDescription = Record.OtherInterestDescription
        End If
        
        ' Interest Options
        If Record.AllowPageInterestOptions Then        
          .OptionInterestAccruedMethodText = Record.OptionInterestAccruedMethod
          .OptionInterestRoundMethodText = Record.OptionInterestRoundMethod
          .OptionInterestBackdatingText = Record.OptionInterestBackdating
          .OptionInterestBackdatingConvertedTransactions = Record.OptionInterestBackdatingConvertedTransactions
          
          .OptionInterestOnInterest = Record.OptionInterestOnInterest          
          If Record.OptionInterestPrecomputed Then
            .OptionInterestChargeUpfront = Record.OptionInterestChargeUpfront
            .OptionInterestChargeOriginal = Record.OptionInterestChargeOriginal
            .OptionInterestFlatRate = Record.OptionInterestFlatRate
          Else 
            .OptionInterestChargeUpfront = False
            .OptionInterestChargeOriginal = False
            .OptionInterestFlatRate = False
          End If          
          .OptionInterestPostMaturityBasisText = Record.OptionInterestPostMaturityBasis
          .InterestNegativeRateAllow = Record.InterestNegativeRateAllow
          .InterestNegativeRateTaxNotApplicable = Record.InterestNegativeRateTaxNotApplicable
          .TaxCertificateNotIssueAIL = Record.TaxCertificateNotIssueAIL
          
          .InterestCycleUpdateFromPaymentCycle = Record.InterestCycleUpdateFromPaymentCycle
          .OptionInterestAlignFirst = Record.OptionInterestAlignFirst
          .OptionInterestFixRateTable = Record.OptionInterestFixRateTable
          
          .InterestInstructionDownText = Record.InterestInstructionDown
          .InterestInstructionUpText = Record.InterestInstructionUp
          
          .InterestEffectiveDateOrEarliestPaymentDate = Record.InterestEffectiveDateOrEarliestPaymentDate
          .InterestEarliestDateDefault = Record.InterestEarliestDateDefault
          
          .ComparisonRateTypeText = Record.ComparisonRateType
          .ComparisonRateRoundingDecimals = Record.ComparisonRateRoundingDecimals
          .ComparisonRateMaximum = Record.ComparisonRateMaximum
          .ComparisonRateMaximumNextDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(Record.ComparisonRateMaximumNextDate)
          .ComparisonRateMaximumNext = Record.ComparisonRateMaximumNext
          
          .InterestPaymentAvailableTypesText = Record.InterestPaymentAvailableTypes
          .InterestPaymentTypeText = Record.InterestPaymentType
          .InterestCommonClient = Record.InterestCommonClient
          .InterestPaymentRollForward = Record.InterestPaymentRollForward
          .InterestPaymentCompoundFinal = Record.InterestPaymentCompoundFinal
          .ReinvestmentPreserveInterestPaymentType = Record.ReinvestmentPreserveInterestPaymentType
          
          .InterestIsFromDividends = Record.InterestIsFromDividends
          
          .ShowZeroInterestTransactions = Record.ShowZeroInterestTransactions
        End If
        
        ' Rate Tables
        If Record.AllowPageRateTables AndAlso finBL.Settings.AddOns.RateTable Then
          .StandardRateTableId = Record.StandardRateTableId

          ' Available Rate Tables
          For Each RateTable In AccountType.RateTables
            RateTable.Available = False
            RateTable.AvailableStartup = False
          Next
          For Each AccountTypeRateTable In Record.RateTables
            If AccountType.RateTables.Exists(AccountTypeRateTable.RateTableId) Then
              RateTable = AccountType.RateTables(AccountTypeRateTable.RateTableId)
              RateTable.Available = AccountTypeRateTable.Available
              RateTable.AvailableStartup = AccountTypeRateTable.AvailableStartup
            End If
          Next
        End If

        ' Overdue &amp; Defaults
        If Record.AllowPageDefaults Then
          .OverdueLimitToBalance = Record.OverdueLimitToBalance
          .ContractualOverdueLimitToBalance = Record.ContractualOverdueLimitToBalance
          
          .OverdueSmallBalanceThreshold = Record.OverdueSmallBalanceThreshold
          .ContractualOverdueSmallBalanceThreshold = Record.ContractualOverdueSmallBalanceThreshold
          
          .DefaultInterestRateBasisText = Record.DefaultInterestRateBasis
          .DefaultInterestRate = Record.DefaultInterestRate
          
          .DefaultInterestInDefault = Record.DefaultInterestInDefault
          .DefaultInterestPostMaturity = Record.DefaultInterestPostMaturity
          .DefaultInterestPostFinalDate = Record.DefaultInterestPostFinalDate
          
          .DefaultInterestOverdueBasisText = Record.DefaultInterestOverdueBasis
          .DefaultInterestOverdueThreshold = Record.DefaultInterestOverdueThreshold
          .DefaultInterestOverdueChargeBasisText = Record.DefaultInterestOverdueChargeBasis
          
          .DefaultInterestMinimumCharge = Record.DefaultInterestMinimumCharge
          
          .DefaultFeeChargeBasisText = Record.DefaultFeeChargeBasis
          .DefaultFeeValue = Record.DefaultFeeValue
          .DefaultFeeIgnoreLimit = Record.DefaultFeeIgnoreLimit
          
          .FacilityFeeChargeBasisText = Record.FacilityFeeChargeBasis
          .FacilityFeeValue = Record.FacilityFeeValue
          .FacilityFeeChargeThresholdApply = Record.FacilityFeeChargeThresholdApply
          .FacilityFeeChargeThresholdValue = Record.FacilityFeeChargeThresholdValue
          .FacilityFeeChargeIfMovement = Record.FacilityFeeChargeIfMovement
        End If
        
        ' Credit Limit
        If Record.AllowPageCreditLimit Then
          .CreditLimitCount = Record.CreditLimitCount
          .CreditLimitKeepOnRefinance = Record.CreditLimitKeepOnRefinance
          .CreditLimitUsePendingWithdrawals = Record.CreditLimitUsePendingWithdrawals
          .CreditLimitUseUnclearedFunds = Record.CreditLimitUseUnclearedFunds
          .CreditLimitUseOtherDeductions = Record.CreditLimitUseOtherDeductions
          .CreditLimitOtherDeductionsDescription = Record.CreditLimitOtherDeductionsDescription
          
          .CreditLimit1Description = Record.CreditLimit1Description
          .CreditLimit1 = Record.CreditLimit1
          .CreditLimit1Required = Record.CreditLimit1Required
          
          .CreditLimit2Description = Record.CreditLimit2Description
          .CreditLimit2 = Record.CreditLimit2
          .CreditLimit2Required = Record.CreditLimit2Required
          
          .CreditLimit3Description = Record.CreditLimit3Description
          .CreditLimit3 = Record.CreditLimit3
          .CreditLimit3Required = Record.CreditLimit3Required
          
          .OverLimitBasisText = Record.OverLimitBasis
          .OverLimitThresholdPercent = Record.OverLimitThresholdPercent
          .OverLimitThreshold = Record.OverLimitThreshold
          
          .OverLimitFeeChargeBasisText = Record.OverLimitFeeChargeBasis
          .OverLimitFeeValue = Record.OverLimitFeeValue
        End If
        
        ' Close Options
        If Record.AllowPageCloseOptions Then
          .ClosedPendingDefault = Record.ClosedPendingDefault
          .ClosedPendingReviewDays = Record.ClosedPendingReviewDays
          .ClosedPendingAutoClose = Record.ClosedPendingAutoClose
          
          .CloseLossFormulaText = Record.CloseLossFormula
          
          .RefinanceLossFormulaText = Record.RefinanceLossFormula
                  
          .SmallBalanceWriteOffDebit = Record.SmallBalanceWriteOffDebit
          .SmallBalanceWriteOffCredit = Record.SmallBalanceWriteOffCredit
          .SmallBalanceRefundCredit = Record.SmallBalanceRefundCredit
                  
          .OptionAutomaticClose = Record.OptionAutomaticClose
          .OptionAutomaticClosePreMaturity = Record.OptionAutomaticClosePreMaturity
          .OptionArchiveDeclinedUnwanted = Record.OptionArchiveDeclinedUnwanted
          .OptionAllowStatusClosedToOpen = Record.OptionAllowStatusClosedToOpen
        End If
        
        ' Other
        If Record.AllowPageOther Then
          .StatementUse = Record.StatementUse
          .StatementCycle = Record.StatementCycle
          .StatementDateNext = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(Record.StatementDateNext)        
          
          .UserDefinedParameterSetId = Record.UserDefinedParameterSetId
          
          .DebtRatioThreshold = Record.DebtRatioThreshold
                  
          .ClientStatisticSourceExtraAssetText = Record.ClientStatisticSourceExtraAsset
          .ClientStatisticSourceExtraLiabilityText = Record.ClientStatisticSourceExtraLiability
          .ClientStatisticSourceConsolidatedLiabilityText = Record.ClientStatisticSourceConsolidatedLiability
          .ClientStatisticSourceConsolidatedExpenseText = Record.ClientStatisticSourceConsolidatedExpense
                
          .IncludeAccountLevelInsurance = Record.IncludeAccountLevelInsurance
          .OptionAllowWithdrawals = Record.OptionAllowWithdrawals
          .DepositAllowWithdrawalsNegativeBalance = Record.DepositAllowWithdrawalsNegativeBalance
          .TransferCommonClient = Record.TransferCommonClient
          .OptionAllowRestructure = Record.OptionAllowRestructure
          .OptionAllowRefinanceInto = Record.OptionAllowRefinanceInto
          .OptionAllowRefinanceRedatedForward = Record.OptionAllowRefinanceRedatedForward
          .UserFlagA = Record.UserFlagA
          .UserFlagB = Record.UserFlagB
                  
          .ShowAccountIdWithCheckDigit = Record.ShowAccountIdWithCheckDigit
          .ShowHistoryRating = Record.ShowHistoryRating
          .ShowTotalAdvances = Record.ShowTotalAdvances
          .ShowOverdue = Record.ShowOverdue
          .ShowContractualOverdue = Record.ShowContractualOverdue
        End If
        
        ' Promotions
        If Record.AllowPagePromotions Then
          .PromotionBasisText = Record.PromotionBasis
          .PromotionUserDefinedParameterSetId = Record.PromotionUserDefinedParameterSetId
        End If
        
        ' Accounting
        If Record.AllowPageAccounting Then
          .ControlGlAccountId = Record.ControlGlAccountId
          .ClearingGlAccountId = Record.ClearingGlAccountId

          For Each ElementLink In AccountType.ElementLinks
            If ElementLink.Available Then
              For Each AccountTypeElementLink In Record.ElementLinks
                If ElementLink.ElementLinkType = AccountTypeElementLink.ElementLinkType Then
                  ' Update
                  ElementLink.ElementId = AccountTypeElementLink.ElementId
                  ElementLink.AllowValueUpdates = AccountTypeElementLink.AllowValueUpdates
                  ElementLink.NormallyCharge = AccountTypeElementLink.NormallyCharge
                  ElementLink.Value = AccountTypeElementLink.Value
                  ElementLink.ValueInclusive = AccountTypeElementLink.ValueInclusive

                  Exit For
                End If
              Next
            End If
          Next
        End If

        ' Scripts
        If Record.AllowPageScripts Then
          For Each ObjectScript In AccountType.ObjectScripts
            For Each AccountTypeScriptLink In Record.AccountTypeScriptLinks
              If StrComp(ObjectScript.Key, AccountTypeScriptLink.Key, CompareMethod.Text) = 0 Then
                ObjectScript.ScriptId = AccountTypeScriptLink.ScriptId
                Exit For
              End If
            Next 
          Next 
        End If
        
        ' User Defined
        If Record.AllowPageUserDefined AndAlso finBL.AccountTypeFunctions.CreateUserDefinedParameters(ParameterSetPk).CountPersistable &lt;&gt; 0 Then
          .UserData.UpdateFromSimpleJsonString(Record.UserDataJson)
        End If
      End With

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

      ' Commit/ Rollback Transaction
      If Success Then
        finBL.Database.TransactionCommit()
      Else
        finBL.Database.TransactionRollback()
      End If
    Else
      Success = False
    End If
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Validate a Wizard page.
''' &lt;/summary&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 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
  End Select

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

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Account Class details.
''' &lt;/summary&gt;
Public Function GetAccountClassDetails(ByRef returnValue As String) As Boolean

  Dim AccountClass As isefinAccountClass
  Dim AccountType As finAccountType  
  Dim AccountTypeDocumentLinks As List(Of AccountTypeDocumentLink)
  Dim Data As Object
  Dim DocumentLink As finAccountTypeDocumentLink
  Dim ParameterSetPk As Integer
  Dim Success As Boolean
  Dim ElementLinks As List(Of AccountTypeElementLink)
  Dim ElementLink As finAccountTypeElementLink
  
  ' Assume Success
  Success = True
  
  ' Parameters
  With mCombinedParameters
    AccountClass = finBL.Enums.isefinAccountClass_FromString(.GetString("AccountClassText"))
  End With

  ' Find Parameter Set to Use
  Select Case AccountClass
    Case isefinAccountClass.Current : ParameterSetPk = finBL.Settings.AccountTypeCurrentUserDefinedParameterSetPk
    Case isefinAccountClass.Deposit : ParameterSetPk = finBL.Settings.AccountTypeDepositUserDefinedParameterSetPk
    Case isefinAccountClass.Disbursement : ParameterSetPk = finBL.Settings.AccountTypeDisbursementUserDefinedParameterSetPk
    Case isefinAccountClass.LoanFR : ParameterSetPk = finBL.Settings.AccountTypeLoanFRUserDefinedParameterSetPk
    Case isefinAccountClass.LoanFT : ParameterSetPk = finBL.Settings.AccountTypeLoanFTUserDefinedParameterSetPk
    Case isefinAccountClass.LoanRC : ParameterSetPk = finBL.Settings.AccountTypeLoanRCUserDefinedParameterSetPk
    Case Else
  End Select

  ' Load Account Type if known
  Success = GetAccountType(AccountType)
  
  If Success Then
    ' Set Account Class (for Document Links)
    If AccountType.AccountClass &lt;&gt; AccountClass Then
      AccountType.AccountClass = AccountClass
    End If  
    
    ' Document Links
    AccountTypeDocumentLinks = New List(Of AccountTypeDocumentLink)
    For Each DocumentLink In AccountType.DocumentLinks
      If DocumentLink.Available Then
        AccountTypeDocumentLinks.Add(New AccountTypeDocumentLink(DocumentLink))
      End If
    Next
    
    ' Element Links
    ElementLinks = New List(Of AccountTypeElementLink)
    For Each ElementLink In AccountType.ElementLinks
      If ElementLink.Available Then
        ElementLinks.Add(New AccountTypeElementLink(ElementLink))
      End If
    Next
  End If  
  
  ' Add to Object
  If Success Then
    Data = New With {
      .AccountCloseLossFormulaList = finBL.Enums.isefinAccountCloseLossFormula_GetList(AccountClass),
      .AccountInterestTypeList = finBL.Enums.isefinAccountInterestType_GetCodeDescriptionList(AccountClass, False).ToJsonObject(),
      .AccountStartupInterestTypeList = finBL.Enums.isefinAccountInterestType_GetCodeDescriptionList(AccountClass, True).ToJsonObject(),
      .AccountTypeDocumentLinks = AccountTypeDocumentLinks,
      .ElementLinks = ElementLinks,
      .InterestTypeAvailableList = finBL.Enums.isefinAccountInterestType_GetList(AccountClass, False).ToCsvString(),
      .StartupInterestTypeAvailableList = finBL.Enums.isefinAccountInterestType_GetList(AccountClass, True).ToCsvString(),
      .UserDefinedParameters = finBL.CreateWsParameters(finBL.AccountTypeFunctions.CreateUserDefinedParameters(ParameterSetPk, False))
    }
  End If  

  ' Serialise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(Data, returnValue)
  End If  

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Product Type details.
''' &lt;/summary&gt;
Public Function GetProductTypeDetails(ByRef returnValue As String) As Boolean

  Dim CategoryInformationListId As String
  Dim CreditReportAccountTypeInformationListId As String
  Dim Data As Object
  Dim DefaultCategory As String
  Dim DefaultCreditReportAccountType As String
  Dim ProductTypeId As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Parameters
  With mCombinedParameters
    ProductTypeId = .GetString("ProductTypeId")
  End With

  ' Credit Report Account Types List
  If finBL.Settings.AddOns.CreditReporting Then
    CreditReportAccountTypeInformationListId = "CreditReportAccountTypes"
    If finBL.ProductTypes.Exists(ProductTypeId) Then
      CreditReportAccountTypeInformationListId = finBL.ProductTypes(ProductTypeId).AccountTypeCreditReportingAccountTypeInformationListIdResolved
    End If
    DefaultCreditReportAccountType = finBL.InformationLists.GetDefaultValue(CreditReportAccountTypeInformationListId)
  End If

  ' Category Information List
  CategoryInformationListId = "AccountTypeCategory"
  If finBL.ProductTypes.Exists(ProductTypeId) Then
    CategoryInformationListId = finBL.ProductTypes(ProductTypeId).AccountTypeCategoryInformationListIdResolved
  End If
  DefaultCategory = finBL.InformationLists.GetDefaultValue(CategoryInformationListId)

  ' Add to Object
  Data = New With {
    .CategoryInformationListId = CategoryInformationListId,
    .DefaultCategory = DefaultCategory,
    .CreditReportAccountTypeInformationListId = CreditReportAccountTypeInformationListId,
    .DefaultCreditReportAccountType = DefaultCreditReportAccountType
  }

  ' Serialise
  Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(Data, returnValue)

  Return Success

End Function



''' &lt;summary&gt;
'''  Wizard Initialisation Information.
''' &lt;/summary&gt;
''' &lt;remarks&gt;
'''  This object is also used to save the Employment.
''' &lt;/remarks&gt;
Public Class FormInitialisationInfo

  ' Form
  Public PageId As String
  Public [ReadOnly] As Boolean

  ' Record
  Public Pk As Integer
  Public Timestamp As Integer

  ' General
  Public AccountTypeId As String
  Public Active As Boolean
  Public Description As String

  Public AccountClassText As String
  Public ProductTypeId As String
  Public CreditTypeText As String
  Public ConsumerRegulationTypeText As String

  Public CreditSale As Boolean
  Public LaybySale As Boolean

  Public CreditReportingAccountType As String

  Public Category As String
  Public Icon As String

  Public Notes As String

  ' New Accounts
  Public NextAccountId As String
  Public DefaultDescription As String
  Public DefaultLedger As String

  Public OptionAllowLedger As Boolean
  Public OptionAllowFirstPaymentDate As Boolean
  Public OptionAllowRegularPayment As Boolean
  Public OptionAllowBalloonPayment As Boolean
  Public OptionAllowResidualValue As Boolean
  Public OptionAllowMaturityDate As Boolean
  Public OptionAllowMaturityInstruction As Boolean
  Public OptionAllowMinimumPayment As Boolean
  Public OptionAllowMinimumPaymentDueDays As Boolean
  Public OptionAllowMinimumPaymentHoldTo As Boolean
  Public OptionAllowTaxCategory As Boolean
  Public OptionAllowInterestCycle As Boolean
  Public OptionAllowInterest As Boolean
  Public OptionAllowStartupInterest As Boolean
  Public OptionAllowTotalInterest As Boolean
  Public OptionAllowReviewDate As Boolean
  Public DefaultReviewPeriod As String
  Public OptionShowFinancialPageOverridingPaymentsTab As Boolean
  Public OptionShowFinancialPageOptionsTab As Boolean
  Public OptionShowInstalmentsDrilldown As Boolean
  Public OptionShowInstalmentsDrilldownWeb As Boolean
  Public OptionShowFinancialPagePrintQuotation As Boolean
  Public UserDefinedShowInNewAccountWizard As Boolean
  Public DisbursementsShowInNewAccountWizard As Boolean
  Public OptionDefaultQuoteStatus As Boolean
  Public OptionDefaultResidualValueFromNetAdvance As Boolean
  Public OptionDefaultResidualValueFromSecurities As Boolean
  Public OptionDefaultPrintContractDocument As Boolean

  Public ShowWarningInfos As Boolean
  Public ShowWarningAlerts As Boolean

  ' Term
  Public TermEntryMethodText As String

  Public TermUse As Boolean
  Public TermMandatory As Boolean

  Public TermOnCall As Boolean

  Public Term As String
  Public TermOnDate As Date?
  Public TermList As String
  Public TermLimitToList As Boolean

  Public TermNumberOfPayments As Integer

  Public TermMinimum As String
  Public TermMaximum As String

  Public OptionAllowPayArrangeExtendTerm As Boolean
  Public TermRollForward As Boolean
  Public MaturityGraceDays As Integer
  Public TermCalculateSchedulePastMaturityDate As Boolean

  Public MaturityInstructionText As String
  Public MaturityAvailableInstructionsText As String

  Public MaturityAccountTypeId As String
  Public MaturityAccountTypesNew As String
  Public MaturityReinvestmentCommonClient As Boolean

  Public MaturityPaymentAvailableTypesText As String
  Public MaturityPaymentTypeText As String
  Public MaturityAccountTypesTransfer As String
  Public MaturityTransferCommonClient As Boolean

  ' Payments
  Public PaymentCycle As String
  Public PaymentCycleList As String
  Public PaymentCycleLimitToList As Boolean
  
  Public PaymentFirstPeriod As String
  Public PaymentFirstDate As Date?
  Public PaymentFirstPeriodList As String
  Public PaymentFirstPeriodLimitToList As Boolean
  Public PaymentFirstPeriodMaximum As String
  
  Public MinimumPaymentBasis As String
  Public MinimumPaymentValue As Decimal
  Public MinimumPaymentPercent As Double
  Public MinimumPaymentDueDays As Integer
  Public MinimumPaymentMoveToNextBusinessDay As Boolean
  Public MinimumPaymentCarryForwardPrepaid As Boolean
  
  Public MinimumPaymentHoldToPeriod As String
  Public MinimumPaymentHoldToDate As Date?
  Public MinimumPaymentHoldToList As String
  Public MinimumPaymentHoldToLimitToList As Boolean
  Public MinimumPaymentHoldToMaximum As String
  
  Public OptionPaymentAllocationMethod As String
  Public OptionPaymentsInAdvance As Boolean
  Public OptionPaymentsRound As Boolean
  Public OptionPaymentsRoundMultiple As Decimal
  Public OptionPaymentsFinalPlusBalloon As Boolean
  Public OptionPaymentsAdjustFinalBeforeBalloon As Boolean
  Public OptionNextPaymentIncludesMinimumPayments As Boolean
  Public OptionAllowCreditBalancePreMaturity As Boolean
  Public PaymentEarlyPartialRepaymentWarning As Boolean
  Public PaymentArrangementDefaultPrintAdvice As Boolean
  
  Public OptionPaymentDirectDebitDateOpened As Boolean
  Public OptionPaymentDirectDebitBalloon As Boolean
  Public PaymentDirectDebitLimitToBalance As Boolean
  Public PaymentDirectDebitMinimumThreshold As Decimal
  
  Public NegativePaymentMatchDays As Integer
  
  Public PaymentGracePeriodUse As Boolean
  Public PaymentGracePeriodDays As Integer
  Public PaymentGracePeriodChargeDefault As Boolean
  
  Public BankReferenceCode As String
  
  Public PayToDescription As String
  Public PayToPurpose As String
  Public PayToAccountIdentifierType As String
  Public PayToPaymentTermFrequency As String
  Public PayToPaymentTermType As String
          
  ' Interest
  Public InterestCycle As String
  Public InterestCycleDateNext As Date?
  Public InterestCycleList As String
  Public InterestCycleLimitToList As Boolean
  
  Public StartupInterestAvailableTypes As String
  Public StartupInterestType As String
  Public StartupInterestRate As Double
  Public StartupInterestRateTableId As String
  Public StartupInterestRateTablePremium As Double
  Public StartupInterestPeriod As String
  Public StartupInterestToDate As Date?
  Public StartupInterestPeriodList As String
  Public StartupInterestPeriodLimitToList As Boolean
  Public StartupInterestPeriodMaximum As String
  
  Public InterestAvailableTypes As String
  Public InterestType As String
  Public InterestRate As Double
  Public InterestRateTableId As String
  Public InterestRateTablePremium As Double
  
  Public OtherInterestType As String
  Public OtherInterestRate As Double
  Public OtherInterestDescription As String
  
  ' Interest Options
  Public OptionInterestAccruedMethod As String
  Public OptionInterestRoundMethod As String
  Public OptionInterestBackdating As String
  Public OptionInterestBackdatingConvertedTransactions As Boolean
  
  Public OptionInterestOnInterest As Boolean
  Public OptionInterestPrecomputed As Boolean
  Public OptionInterestChargeUpfront As Boolean
  Public OptionInterestChargeOriginal As Boolean
  Public OptionInterestFlatRate As Boolean
  Public OptionInterestPostMaturityBasis As String
  Public InterestNegativeRateAllow As Boolean
  Public InterestNegativeRateTaxNotApplicable As Boolean
  Public TaxCertificateNotIssueAIL As Boolean
  
  Public InterestCycleUpdateFromPaymentCycle As Boolean
  Public OptionInterestAlignFirst As Boolean
  Public OptionInterestFixRateTable As Boolean
  
  Public InterestInstructionDown As String
  Public InterestInstructionUp As String
  
  Public InterestEffectiveDateOrEarliestPaymentDate As Boolean
  Public InterestEarliestDateDefault As String
  
  Public ComparisonRateType As String
  Public ComparisonRateRoundingDecimals As Integer
  Public ComparisonRateMaximum As Double
  Public ComparisonRateMaximumNextDate As Date?
  Public ComparisonRateMaximumNext As Double
  
  Public InterestPaymentAvailableTypes As String
  Public InterestPaymentType As String
  Public InterestCommonClient As Boolean
  Public InterestPaymentRollForward As Boolean
  Public InterestPaymentCompoundFinal As Boolean
  Public ReinvestmentPreserveInterestPaymentType As Boolean
  
  Public InterestIsFromDividends As Boolean
  
  Public ShowZeroInterestTransactions As Boolean
  
  ' Rate Tables
  Public StandardRateTableId As String
  Public RateTables As List(Of AccountTypeRateTable)

  ' Overdue &amp; Defaults
  Public OverdueLimitToBalance As Boolean
  Public ContractualOverdueLimitToBalance As Boolean
  
  Public OverdueSmallBalanceThreshold As Decimal
  Public ContractualOverdueSmallBalanceThreshold As Decimal
  
  Public DefaultInterestRateBasis As String
  Public DefaultInterestRate As Double
  
  Public DefaultInterestInDefault As Boolean
  Public DefaultInterestPostMaturity As Boolean
  Public DefaultInterestPostFinalDate As Boolean
  
  Public DefaultInterestOverdueBasis As String
  Public DefaultInterestOverdueThreshold As Decimal
  Public DefaultInterestOverdueChargeBasis As String
  
  Public DefaultInterestMinimumCharge As Decimal
  
  Public DefaultFeeChargeBasis As String
  Public DefaultFeeValue As Decimal
  Public DefaultFeeIgnoreLimit As Boolean
  
  Public FacilityFeeChargeBasis As String
  Public FacilityFeeValue As Decimal
  Public FacilityFeeChargeThresholdApply As Boolean
  Public FacilityFeeChargeThresholdValue As Decimal
  Public FacilityFeeChargeIfMovement As Boolean
  
  ' Credit Limit
  Public CreditLimitCount As Integer
  Public CreditLimitKeepOnRefinance As Boolean
  Public CreditLimitUsePendingWithdrawals As Boolean
  Public CreditLimitUseUnclearedFunds As Boolean
  Public CreditLimitUseOtherDeductions As Boolean
  Public CreditLimitOtherDeductionsDescription As String
  
  Public CreditLimit1Description As String
  Public CreditLimit1 As Decimal
  Public CreditLimit1Required As Boolean
  
  Public CreditLimit2Description As String
  Public CreditLimit2 As Decimal
  Public CreditLimit2Required As Boolean
  
  Public CreditLimit3Description As String
  Public CreditLimit3 As Decimal
  Public CreditLimit3Required As Boolean
  
  Public OverLimitBasis As String
  Public OverLimitThresholdPercent As Double
  Public OverLimitThreshold As Decimal
  
  Public OverLimitFeeChargeBasis As String
  Public OverLimitFeeValue As Decimal
  
  ' Close Options
  Public ClosedPendingDefault As Boolean
  Public ClosedPendingReviewDays As Integer
  Public ClosedPendingAutoClose As Boolean
  
  Public CloseLossFormula As String
  
  Public RefinanceLossFormula As String
          
  Public SmallBalanceWriteOffDebit As Decimal
  Public SmallBalanceWriteOffCredit As Decimal
  Public SmallBalanceRefundCredit As Decimal
          
  Public OptionAutomaticClose As Boolean
  Public OptionAutomaticClosePreMaturity As Boolean
  Public OptionArchiveDeclinedUnwanted As Boolean
  Public OptionAllowStatusClosedToOpen As Boolean
  
  ' Other
  Public StatementUse As Boolean
  Public StatementCycle As String
  Public StatementDateNext As Date?  
  
  Public UserDefinedParameterSetId As String
  
  Public DebtRatioThreshold As Double
          
  Public ClientStatisticSourceExtraAsset As String
  Public ClientStatisticSourceExtraLiability As String
  Public ClientStatisticSourceConsolidatedLiability As String
  Public ClientStatisticSourceConsolidatedExpense As String
        
  Public IncludeAccountLevelInsurance As Boolean
  Public OptionAllowWithdrawals As Boolean
  Public DepositAllowWithdrawalsNegativeBalance As Boolean
  Public TransferCommonClient As Boolean
  Public OptionAllowRestructure As Boolean
  Public OptionAllowRefinanceInto As Boolean
  Public OptionAllowRefinanceRedatedForward As Boolean
  Public UserFlagA As Boolean
  Public UserFlagB As Boolean
          
  Public ShowAccountIdWithCheckDigit As Boolean
  Public ShowHistoryRating As Boolean
  Public ShowTotalAdvances As Boolean
  Public ShowOverdue As Boolean
  Public ShowContractualOverdue As Boolean
  
  ' Promotions
  Public PromotionBasis As String
  Public PromotionUserDefinedParameterSetId As String
  
  ' Transactions
  Public NetAdvanceMinimum As Decimal
  Public NetAdvanceMaximum As Decimal
  Public OptionCreateAdjustedToZeroTransactions As Boolean
  
  ' Documents
  Public DocumentLinks As List(Of AccountTypeDocumentLink)
  Public DocumentsAvailable As List(Of AccountTypeDocument) ' Named with 'Available' suffix so as not to clash with the Global Collection property defined below

  ' Accounting
  Public ControlGlAccountId As String
  Public ClearingGlAccountId As String
  Public ElementLinks As List(Of AccountTypeElementLink)

  ' Scripts
  Public AccountTypeScriptLinks As List(Of AccountTypeScriptLink)
  
  ' User Defined
  Public UserDefinedParameters As ISWsParameters
  Public UserDataJson As String

  ' Permissions
  Public AllowPageGeneral As Boolean
  Public AllowPageNewAccounts As Boolean
  Public AllowPageTerm As Boolean
  Public AllowPagePayments As Boolean
  Public AllowPageInterest As Boolean
  Public AllowPageInterestOptions As Boolean
  Public AllowPageRateTables As Boolean
  Public AllowPageDefaults As Boolean
  Public AllowPageCreditLimit As Boolean
  Public AllowPageCloseOptions As Boolean
  Public AllowPageOther As Boolean
  Public AllowPagePromotions As Boolean
  Public AllowPageTransactions As Boolean
  Public AllowPageDocuments As Boolean
  Public AllowPageRules As Boolean
  Public AllowPageAccounting As Boolean
  Public AllowPageScripts As Boolean
  Public AllowPageUserDefined As Boolean

  ' Lists
  Public AccountCalcComparisonRateTypeList As String
  Public AccountClassList As Object
  Public AccountCloseLossFormulaList As String
  Public AccountInterestInstructionList As String
  Public AccountInterestPaymentTypeList As String
  Public AccountInterestTypeList As Object
  Public AccountTypePromotionBasisList As String
  Public AccountTypeStatisticSourceList As String
  Public AccountStartupInterestTypeList As Object
  Public ConsumerRegulationTypeList As Object
  Public CreditTypeList As Object
  Public DefaultFeeChargeBasisList As Object
  Public DefaultInterestOverdueBasisList As Object
  Public DefaultInterestOverdueChargeBasisList As String
  Public DefaultInterestRateBasisList As String  
  Public DefaultReviewPeriodList As String   
  Public FacilityFeeChargeBasisList As Object
  Public IconList As String  
  Public InterestAccruedMethodList As String
  Public InterestBackdatingList As Object
  Public InterestPostMaturityBasis As String  
  Public InterestRoundMethodList As String
  Public InterestTypeAvailableList As String
  Public MaturityInstructionList As String
  Public MaturityPaymentTypeList As String
  Public MinimumPaymentBasisList As Object
  Public OtherInterestTypeList As Object
  Public OverLimitBasisList As Object
  Public OverLimitFeeBasisList As Object
  Public PaymentAllocationMethodList As Object
  Public StartupInterestTypeAvailableList As String
  Public TermEntryMethodList As Object    
  Public PayToPurposeList As String
  Public PayToAccountIdentifierTypeList As String
  Public PayToPaymentTermFrequencyList As String
  Public PayToPaymentTermTypeList As String

  ' Configuration
  Public AddOnBankingAdvanced As Boolean
  Public AddOnClientStatistics As Boolean
  Public AddOnCostCentre As Boolean
  Public AddOnDisbursements As Boolean
  Public AddOnRateTable As Boolean
  Public AddOnSecurityRegister As Boolean
  Public CountryCode As String
  Public DisplayPayTo As Boolean
  Public HideOtherPages As Boolean
  Public PromptOnSave As Boolean
  Public UserFlagACaption As String
  Public UserFlagBCaption As String

  ' Global Collections
  Public Documents As New List(Of DocumentDetails)
  Public Elements As New List(Of ElementDetails)
  Public Scripts As New List(Of ScriptDetails)

End Class



''' &lt;summary&gt;
'''  Account Type Document.
''' &lt;/summary&gt;
Public Class AccountTypeDocument

  Public Active As Boolean
  Public Available As Boolean
  Public Category As String
  Public Description As String
  Public DocumentId As String
  Public Message As String

  Public Sub New()
  End Sub

  Public Sub New(document As finAccountTypeDocument)

    Dim Details As String
    
    With document
      Me.Active = .Active
      Me.Available = .Available
      Me.Description = .Description
      Me.DocumentId = .DocumentId
      Me.Message = finBLShared.Documents(.DocumentId).GetObsoleteMessage(Details)
      If Len(Details) &lt;&gt; 0 Then
        Me.Message &amp;= vbNewLine &amp; Details
      End If
      
      If Len(.Category) = 0 Then
        Me.Category = "(no category)"
      Else
        Me.Category = .Category
      End If
    End With

  End Sub

End Class



''' &lt;summary&gt;
'''  Account Type Rate Table.
''' &lt;/summary&gt;
Public Class AccountTypeRateTable

  Public Active As Boolean
  Public Available As Boolean
  Public AvailableStartup As Boolean
  Public Category As String
  Public CurrentRate As String
  Public Description As String
  Public RateTableId As String

  Public Sub New()
  End Sub

  Public Sub New(rateTable As finAccountTypeRateTable)

    Dim Rate As Double
    Dim RateTiered As Boolean

    With rateTable
      Me.Active = .Active
      Me.Available = .Available
      Me.AvailableStartup = .AvailableStartup
      Me.Category = .Category
      Me.Description = .Description
      Me.RateTableId = .RateTableId
    End With

    ' Current Rate
    Rate = finBLShared.RateTables(rateTable.RateTableId).GetRate(finBLShared.TimeZoneFunctions.GetCurrentDatabaseDate(), 99999999999, , , RateTiered)
    Me.CurrentRate = If(RateTiered, "Tiered, ", "") &amp; finBLShared.FormatPercentage(Rate / 100, 4)

  End Sub

End Class



''' &lt;summary&gt;
'''  Account Type Element Link.
''' &lt;/summary&gt;
Public Class AccountTypeElementLink

  Public AllowValue As Boolean
  Public AllowValueInclusive As Boolean
  Public AllowValueUpdates As Boolean
  Public Available As Boolean
  Public Category As String
  Public Description As String
  Public ElementId As String
  Public ElementDescription As String
  Public ElementLinkType As isefinAccountTypeElementLinkType
  Public ElementType As isefinElementType
  Public Mandatory As Boolean
  Public NormallyCharge As Boolean
  Public System As Boolean
  Public Value As Decimal
  Public ValueInclusive As Boolean

  Public Sub New()
  End Sub

  Public Sub New(elementLink As finAccountTypeElementLink)

    With elementLink
      Me.AllowValue = .AllowValue
      Me.AllowValueInclusive = .AllowValueInclusive
      Me.AllowValueUpdates = .AllowValueUpdates
      Me.Available = .Available
      Me.Category = .Category
      Me.Description = .Description
      Me.ElementId = .ElementId
      Me.ElementDescription = .ElementDescription
      Me.ElementLinkType = .ElementLinkType
      Me.ElementType = .ElementType
      Me.Mandatory = .Mandatory
      Me.NormallyCharge = .NormallyCharge
      Me.System = .System
      Me.Value = .Value
      Me.ValueInclusive = .ValueInclusive
    End With

  End Sub

End Class



''' &lt;summary&gt;
'''  Account Type Element Link.
''' &lt;/summary&gt;
Public Class AccountTypeDocumentLink

  Public Description As String
  Public DocumentId As String
  Public DocumentDescription As String
  Public DocumentLinkType As isefinAccountTypeDocumentLinkType
  Public DocumentType As isefinDocumentType
  Public Mandatory As Boolean

  Public Sub New()
  End Sub

  Public Sub New(documentLink As finAccountTypeDocumentLink)

    With documentLink      
      Me.Description = .Description
      Me.DocumentId = .DocumentId
      Me.DocumentDescription = .DocumentDescription
      Me.DocumentLinkType = .DocumentLinkType
      Me.DocumentType = .DocumentType
      Me.Mandatory = .Mandatory
    End With

  End Sub

End Class



''' &lt;summary&gt;
'''  Account Type Script Link.
''' &lt;/summary&gt;
Public Class AccountTypeScriptLink
  
  Public AvailableScripts As Object
  Public Category As String
  Public Description As String
  Public Key As String
  Public KeyWithPrefixRemoved As String
  Public ScriptDescription As String
  Public ScriptId As String
  
  Public Sub New()
  End Sub
  
  Public Sub New(objectScript As finObjectScript,
                 defaultObjectName As String)
    
    Dim ScriptList As ISList    
    Dim TargetObjectList As ISList
    Dim ScriptRO As finScriptRO
    Dim Include As Boolean
    
    ' Initialise    
    ScriptList = finBLShared.Runtime.CreateList()
    TargetObjectList = finBLShared.Runtime.CreateList()
    
    ' Target Object Type
    If Len(objectScript.ObjectName) = 0 AndAlso Len(objectScript.ObjectName2) = 0 Then
      ' No Object (e.g., HTML Widget)
    ElseIf objectScript.ObjectName = "#GeneralUserInterface" Then
      ' General User Interface Scripts
    ElseIf Len(objectScript.ObjectName) = 0 AndAlso Len(objectScript.ObjectName2) &lt;&gt; 0 Then
      TargetObjectList.Add(objectScript.ObjectName2)
    ElseIf Len(objectScript.ObjectName2) = 0 Then
      ' Only using ObjectName (or the default Object Name)
      If Len(objectScript.ObjectName) = 0 Then
        TargetObjectList.Add(defaultObjectName)
      Else
        TargetObjectList.Add(objectScript.ObjectName)
      End If
    Else 
      ' Using ObjectName and ObjectName2
      If Len(objectScript.ObjectName) = 0 Then
        TargetObjectList.Add(defaultObjectName)
      Else
        TargetObjectList.Add(objectScript.ObjectName)
      End If
      TargetObjectList.Add(objectScript.ObjectName2)
    End If
    
    ' Get allowed Scripts
    For Each ScriptRO In finBLShared.Scripts
      Include = True
      
      ' Initial Checks
      If ScriptRO.Active OrElse ScriptRO.Pk = objectScript.ScriptPk Then
        If TargetObjectList.Count &lt;&gt; 0 AndAlso Not TargetObjectList.Exists(ScriptRO.TargetObjectType, True) Then
          Include = False  
        End If
      Else 
        Include = False
      End If
      
      ' Script Type checks
      If Include Then
        Select Case objectScript.Category
          Case "Event"
            If objectScript.ObjectName = "#GeneralUserInterface" Then
              ' General User Interface Script
              Include = (ScriptRO.ScriptType = isefinScriptType.GeneralUserInterface)
            Else
              Include = (ScriptRO.ScriptType = isefinScriptType.ObjectEvents)
            End If
            
          Case "HTML Widget"
            Include = (ScriptRO.ScriptType = isefinScriptType.HtmlWidget)
            
          Case "Summary Page" To "Summary Page~"
            If Len(objectScript.ObjectName2) = 0 Then
              Include = (ScriptRO.ScriptType = isefinScriptType.SummaryPage)
            Else 
              Include = (ScriptRO.ScriptType = isefinScriptType.SummaryPage OrElse ScriptRO.ScriptType = isefinScriptType.SummaryPage2)
            End If
            
          Case "Wizard Validator"
            Include = (ScriptRO.ScriptType = isefinScriptType.WizardValidator)
            
          Case Else
            Include = False
        End Select
      End If
      
      ' Allow Script
      If Include Then
        ScriptList.Add(ScriptRO.ScriptId)
      End If
    Next 
    
    ' Build Object
    With objectScript
      Me.AvailableScripts = ScriptList.ToJsonObject()
      Me.Category = .Category
      Me.Description = .Description
      Me.Key = .Key
      Me.KeyWithPrefixRemoved = .KeyWithPrefixRemoved()
      Me.ScriptDescription = .ScriptDescription
      Me.ScriptId = .ScriptId
    End With
    
  End Sub
  
End Class



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

  Public Data As Object
  Public FailedMessage As String
  Public FailedControlId 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;
'''  Global Collection: Documents.
''' &lt;/summary&gt;
Public Class DocumentDetails

  ' Properties
  Public DocumentId As String
  Public AllowLog As Boolean
  Public AllowStandalone As Boolean
  Public Description As String
  Public DocumentType As isefinDocumentType

  Public Sub New(document As finDocumentRO)

    With document
      Me.DocumentId = .DocumentId
      Me.AllowLog = .AllowLog
      Me.AllowStandalone = .AllowStandalone
      Me.Description = .Description
      Me.DocumentType = .DocumentType
    End With

  End Sub

End Class



''' &lt;summary&gt;
'''  Global Collection: Elements.
''' &lt;/summary&gt;
Public Class ElementDetails

  ' Properties
  Public ElementId As String
  Public Description As String
  Public ElementType As isefinElementType

  Public Sub New(element As finElementRO)

    With element
      Me.ElementId = .ElementId
      Me.Description = .Description
      Me.ElementType = .ElementType
    End With

  End Sub

End Class



''' &lt;summary&gt;
'''  Global Collection: Scripts.
''' &lt;/summary&gt;
Public Class ScriptDetails

  Public ScriptId As String
  Public Description As String
  Public ScriptType As String
  
  Public Sub New(scriptRO As finScriptRO)
    
    With scriptRO
      Me.ScriptId = .ScriptId
      Me.Description = .Description
      Me.ScriptType = .ScriptType.ToString()
    End With
    
  End Sub
  
End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System-supplied HTML Widget to edit an Account Type.

NOTE: This is phase 1 of this Widget and will be enhanced in the future.</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;!-- Tabs --&gt;
    &lt;div id="tabDetails" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;li tabId="General"&gt;General&lt;/li&gt;
        &lt;li tabId="NewAccounts"&gt;New Accounts&lt;/li&gt;
        &lt;li tabId="Term"&gt;Term&lt;/li&gt;
        &lt;li tabId="Payments"&gt;Payments&lt;/li&gt;
        &lt;li tabId="Interest"&gt;Interest&lt;/li&gt;
        &lt;li tabId="InterestOptions"&gt;Interest Options&lt;/li&gt;
        &lt;li tabId="RateTables"&gt;Rate Tables&lt;/li&gt;
        &lt;li tabId="Defaults"&gt;Overdue &amp;amp; Defaults&lt;/li&gt;
        &lt;li tabId="CreditLimit"&gt;Credit Limit&lt;/li&gt;
        &lt;li tabId="CloseOptions"&gt;Close Options&lt;/li&gt;
        &lt;li tabId="Other"&gt;Other&lt;/li&gt;
        &lt;li tabId="Promotions"&gt;Promotions&lt;/li&gt;
        &lt;li tabId="Transactions"&gt;Transactions&lt;/li&gt;
        &lt;li tabId="Documents"&gt;Documents&lt;/li&gt;
        &lt;li tabId="Rules"&gt;Rules&lt;/li&gt;
        &lt;li tabId="Accounting"&gt;Accounting&lt;/li&gt;
        &lt;li tabId="Scripts"&gt;Scripts&lt;/li&gt;
        &lt;li tabId="UserDefined"&gt;User Defined&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;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCodeAndName"&gt;Code and Description&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtAccountTypeId"&gt;Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtAccountTypeId"/&gt; &lt;input id="chkActive" type="checkbox"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDescription"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDescription"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label&gt;Account Class, Product and Credit Type&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboAccountClass"&gt;Account Class:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboAccountClass"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboProductType"&gt;Product Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboProductType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCreditType"&gt;Credit Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCreditType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboConsumerRegulationType"&gt;Regulation:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboConsumerRegulationType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblGeneralOtherOptions"&gt;Other options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkCreditSale" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkLaybySale" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCreditReporting"&gt;Credit Reporting settings&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCreditReportingAccountType"&gt;Account Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCreditReportingAccountType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label&gt;Category and Icon&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCategory"&gt;Category&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCategory"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboIcon"&gt;Icon:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboIcon"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label&gt;Notes&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="txtNotes"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- New Accounts --&gt;
    &lt;div id="pageNewAccounts"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblNewAccountDefaults"&gt;Defaults for new Accounts&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtNextAccountId"&gt;Next Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtNextAccountId"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDefaultDescription"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDefaultDescription"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultLedger"&gt;Ledger:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultLedger"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label&gt;New Account wizard&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Allow entry of the following&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowLedger" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowFirstPaymentDate" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowRegularPayment" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowBalloonPayment" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowResidualValue" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowMaturityDate" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowMaturityInstruction" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowMinimumPayment" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowMinimumPaymentDueDays" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowMinimumPaymentHoldTo" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowTaxCategory" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowInterestCycle" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowInterest" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowStartupInterest" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowTotalInterest" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowReviewDate" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="cboDefaultReviewPeriod"&gt;Review&amp;nbsp;Period:&amp;nbsp;&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultReviewPeriod"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr id="trFinancialPageOptions"&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Show the following on the Financial page&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowFinancialPageOverridingPaymentsTab" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowFinancialPageOptionsTab" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowInstalmentsDrilldown" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkShowInstalmentsDrilldownWeb" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowFinancialPagePrintQuotation" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Other pages to show&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkDisbursementsShowInNewAccountWizard" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkUserDefinedShowInNewAccountWizard" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Defaults&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionDefaultQuoteStatus" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionDefaultResidualValueFromNetAdvance" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionDefaultResidualValueFromSecurities" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionDefaultPrintContractDocument" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Account Warnings to include&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowWarningInfos" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowWarningAlerts" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Term --&gt;
    &lt;div id="pageTerm"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTermEntryMethod"&gt;Term entry method for new Accounts&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTermEntryMethod"&gt;Method:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTermEntryMethod"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTermUse"&gt;Term/ Maturity Date&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTermUse" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTermMandatory" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTermOnCall"&gt;On Call Deposit?&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTermOnCall" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTermDefault"&gt;Default Term&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTerm"&gt;Term:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTerm"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="dateTermOnDate"&gt;Date To:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="dateTermOnDate"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtTermList"&gt;Term List:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtTermList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTermLimitToList" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTermNumberOfPayments"&gt;Default Number of Payments&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numTermNumberOfPayments"&gt;Payments:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numTermNumberOfPayments"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTermLimits"&gt;New Account Term limits&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTermMinimum"&gt;Min Term:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTermMinimum"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboTermMaximum"&gt;Max Term:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboTermMaximum"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTermOptions"&gt;Options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowPayArrangeExtendTerm" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTermRollForward" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numMaturityGraceDays"&gt;Grace Days:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numMaturityGraceDays"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTermCalculateSchedulePastMaturityDate" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblMaturityInstructions"&gt;Maturity Instructions&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="lstMaturityInstructionAvailableList"&gt;Available Instructions:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="lstMaturityInstructionAvailableList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboMaturityInstruction"&gt;Instruction:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboMaturityInstruction"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblMaturityReinvestmentDetails"&gt;Maturity Reinvestment details&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboMaturityAccountType"&gt;Reinvest to:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboMaturityAccountType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtMaturityAccountTypesNew"&gt;New Types:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtMaturityAccountTypesNew"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkMaturityReinvestmentCommonClient" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblMaturityRepaymentDetails"&gt;Maturity Repayment details&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="lstMaturityPaymentAvailableTypes"&gt;Available Types:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="lstMaturityPaymentAvailableTypes"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboMaturityPaymentType"&gt;Payment Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboMaturityPaymentType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtMaturityAccountTypesTransfer"&gt;Transfer to:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtMaturityAccountTypesTransfer"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkMaturityTransferCommonClient" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Payments --&gt;
    &lt;div id="pagePayments"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:10em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDefaultPayments"&gt;Default Payments&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;     
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboPaymentCycle"&gt;Payment Cycle:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboPaymentCycle"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtPaymentCycleList"&gt;Payment List:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtPaymentCycleList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;   
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkPaymentCycleLimitToList" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDefaultFirstPayment"&gt;Default First Payment&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboPaymentFirstPeriod"&gt;First Payment:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;div style="display:inline-flex;"&gt;&lt;input id="cboPaymentFirstPeriod"/&gt; &lt;input id="datePaymentFirstDate"/&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtPaymentFirstPeriodList"&gt;Period List:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtPaymentFirstPeriodList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkPaymentFirstPeriodLimitToList" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboPaymentFirstPeriodMaximum"&gt;Max Period:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboPaymentFirstPeriodMaximum"/&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblMinimumPayments"&gt;Minimum Payments&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboMinimumPaymentBasis"&gt;Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboMinimumPaymentBasis"/&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numMinimumPaymentValue"&gt;Value:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numMinimumPaymentValue"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numMinimumPaymentPercent"&gt;Percentage:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numMinimumPaymentPercent"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numMinimumPaymentDueDays"&gt;Due days:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numMinimumPaymentDueDays"/&gt;&lt;span style="margin-right:8px"&gt;&lt;/span&gt;&lt;input id="chkMinimumPaymentMoveToNextBusinessDay" type="checkbox"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkMinimumPaymentCarryForwardPrepaid" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblMinimumPaymentsHoldTo"&gt;Default Minimum Payments 'Hold To' date&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboMinimumPaymentHoldToPeriod"&gt;Hold To Period:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;div style="display:inline-flex;"&gt;&lt;input id="cboMinimumPaymentHoldToPeriod"/&gt; &lt;input id="dateMinimumPaymentHoldToDate"/&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtMinimumPaymentHoldToList"&gt;Period List:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtMinimumPaymentHoldToList"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkMinimumPaymentHoldToLimitToList" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboMinimumPaymentHoldToMaximum"&gt;Max Period:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboMinimumPaymentHoldToMaximum"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblPaymentOptions"&gt;Payment options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOptionPaymentAllocationMethod"&gt;Allocation:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOptionPaymentAllocationMethod"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionPaymentsInAdvance" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionPaymentsRound" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="numOptionPaymentsRoundMultiple"&gt;Multiple:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numOptionPaymentsRoundMultiple"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionPaymentsFinalPlusBalloon" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionPaymentsAdjustFinalBeforeBalloon" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionNextPaymentIncludesMinimumPayments" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowCreditBalancePreMaturity" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkPaymentEarlyPartialRepaymentWarning" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkPaymentArrangementDefaultPrintAdvice" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDirectDebitOptions"&gt;Direct Debit options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionPaymentDirectDebitDateOpened" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionPaymentDirectDebitBalloon" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkPaymentDirectDebitLimitToBalance" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numPaymentDirectDebitMinimumThreshold"&gt;Minimum Other:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numPaymentDirectDebitMinimumThreshold"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblNegativePaymentOptions"&gt;Negative Payment options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkNegativePaymentMatch" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numNegativePaymentMatchDays"&gt;Maximum days:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numNegativePaymentMatchDays"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblGracePeriod"&gt;Grace Period&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkPaymentGracePeriodUse" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="numPaymentGracePeriodDays"&gt;Business days:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numPaymentGracePeriodDays"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkPaymentGracePeriodChargeDefault" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblBankReference"&gt;Bank Reference code&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtBankReferenceCode"&gt;Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtBankReferenceCode"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblPayTo"&gt;PayTo defaults&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDefaultPayToDescription"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDefaultPayToDescription"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultPayToPurpose"&gt;Purpose:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultPayToPurpose"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultPayToAccountIdentifierType"&gt;Account Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultPayToAccountIdentifierType"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultPayToPaymentTermType"&gt;Term Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultPayToPaymentTermType"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultPayToPaymentTermFrequency"&gt;Term Frequency:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultPayToPaymentTermFrequency"/&gt;&lt;/td&gt;
        &lt;/tr&gt; 
                                
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Interest --&gt;
    &lt;div id="pageInterest"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:10em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterestCycle"&gt;Interest Cycle&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;     
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInterestCycle"&gt;Cycle:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInterestCycle"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="dateInterestCycleDateNext"&gt;Next Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="dateInterestCycleDateNext"/&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtInterestCycleList"&gt;Interest List:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtInterestCycleList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestCycleLimitToList" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblStartupInterest"&gt;Startup Interest&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="lstStartupInterestTypeAvailableList"&gt;Available Types:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="lstStartupInterestTypeAvailableList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboStartupInterestType"&gt;Startup Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboStartupInterestType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numStartupInterestRate"&gt;Interest Rate:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numStartupInterestRate"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboStartupInterestRateTable"&gt;Rate Table:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;div style="display:inline-flex;"&gt;&lt;input id="cboStartupInterestRateTable"/&gt;&lt;span id="spanStartupInterestRatePremium"&gt;&amp;nbsp;&amp;nbsp;plus&amp;nbsp;&amp;nbsp;&lt;input id="numStartupInterestRatePremium" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboStartupInterestPeriod"&gt;Period:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;div style="display:inline-flex;"&gt;&lt;input id="cboStartupInterestPeriod"/&gt;&lt;span id="spanStartupInterestToDate" style="display:inline-flex;"&gt;&amp;nbsp;&amp;nbsp;to&amp;nbsp;&amp;nbsp;&lt;input id="dateStartupInterestToDate" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtStartupInterestPeriodList"&gt;Period List:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtStartupInterestPeriodList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkStartupInterestPeriodLimitToList" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboStartupInterestPeriodMaximum"&gt;Max Period:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboStartupInterestPeriodMaximum"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterest"&gt;Interest&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="lstInterestTypeAvailableList"&gt;Available Types:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="lstInterestTypeAvailableList"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInterestType"&gt;Interest Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInterestType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numInterestRate"&gt;Interest Rate:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numInterestRate"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInterestRateTable"&gt;Rate Table:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;div style="display:inline-flex;"&gt;&lt;input id="cboInterestRateTable"/&gt;&lt;span id="spanInterestRatePremium"&gt;&amp;nbsp;&amp;nbsp;plus&amp;nbsp;&amp;nbsp;&lt;input id="numInterestRatePremium" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblOtherInterest"&gt;Other Interest&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOtherInterestType"&gt;Other Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOtherInterestType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numOtherInterestRate"&gt;Other Rate:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numOtherInterestRate"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtOtherInterestDescription"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtOtherInterestDescription"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Interest Options --&gt;
    &lt;div id="pageInterestOptions"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:9em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterestCalculationOptions"&gt;Interest Calculation options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOptionInterestAccruedMethod"&gt;Accrued Int:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOptionInterestAccruedMethod"/&gt;&lt;/td&gt;
        &lt;/tr&gt;    
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOptionInterestRoundMethod"&gt;Rounding:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOptionInterestRoundMethod"/&gt;&lt;/td&gt;
        &lt;/tr&gt;       
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOptionInterestBackdating"&gt;Backdating:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOptionInterestBackdating"/&gt;&lt;span style="margin-right:8px"&gt;&lt;/span&gt;&lt;input id="chkOptionInterestBackdatingConvertedTransactions" type="checkbox" /&gt;&lt;/td&gt;
        &lt;/tr&gt;   
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterestOptions"&gt;Options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionInterestOnInterest" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionInterestPrecomputed" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkOptionInterestChargedUpfront" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkOptionInterestChargedOriginal" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkOptionInterestFlatRate" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOptionInterestPostMaturityBasis"&gt;Post Maturity:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOptionInterestPostMaturityBasis"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestNegativeRateAllow" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkInterestNegativeRateTaxNotApplicable" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTaxCertificateNotIssueAIL" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterestNewAccountOptions"&gt;New Account options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestCycleUpdateFromPaymentCycle" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionInterestAlignFirst" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionInterestFixRateTable" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterestInstructions"&gt;Interest Rate change instructions&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInterestInstructionDown"&gt;Rate Decrease:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInterestInstructionDown"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInterestInstructionUp"&gt;Rate Increase:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInterestInstructionUp"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblFloatingInterestRateOptions"&gt;Floating Interest Rate options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestEffectiveDateOrEarliestPaymentDate" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInterestEarliestDateDefault"&gt;Earliest Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInterestEarliestDateDefault"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblComparisonRate"&gt;Comparison Rate options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboComparisonRateType"&gt;Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboComparisonRateType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numComparisonRateRoundingDecimals"&gt;Round digits:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numComparisonRateRoundingDecimals"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numComparisonRateMaximum"&gt;Max Rate:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numComparisonRateMaximum"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="dateComparisonRateMaximumNextDate"&gt;Next Max Rate:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="dateComparisonRateMaximumNextDate"/&gt; &lt;input id="numComparisonRateMaximumNext"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterestPayment"&gt;Interest Payment options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="lstInterestPaymentAvailableTypes"&gt;Available Types:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="lstInterestPaymentAvailableTypes"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInterestPaymentType"&gt;Payment Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInterestPaymentType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestCommonClient" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestPaymentRollForward" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestPaymentCompoundFinal" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkReinvestmentPreserveInterestPaymentType" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInvestmentIncomeReportingOptions"&gt;Investment Income Reporting options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkInterestIsFromDividends" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInterestOtherOptions"&gt;Other options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowZeroInterestTransactions" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Rate Tables --&gt;
    &lt;div id="pageRateTables"&gt;
      &lt;div style="display:flex; flex-direction:column; position:absolute; top:0; left:0; right:0; bottom:0; padding:4px"&gt;
        &lt;div&gt;
          &lt;table class="is-form"&gt;
            &lt;colgroup&gt;
              &lt;col style="width:8em" /&gt;
              &lt;col /&gt;
            &lt;/colgroup&gt;

            &lt;tr&gt;
              &lt;th colspan="2"&gt;&lt;label&gt;Standard Rate Table&lt;/label&gt;&lt;/th&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboStandardRateTable"&gt;Standard:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="cboStandardRateTable"/&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
              &lt;th colspan="2"&gt;&lt;label&gt;Rate Tables available to this Account Type&lt;/label&gt;&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;
        &lt;div style="position:relative; flex-grow:1; max-width:1024px; margin-left:8px"&gt;
          &lt;div id="gridRateTables" class="is-dock-fill"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;



    &lt;!-- Defaults --&gt;
    &lt;div id="pageDefaults"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblOverdueOptions"&gt;Overdue options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;   
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOverdueLimitToBalance" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;   
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkContractualOverdueLimitToBalance" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblOverdueSmallBalanceThresholds"&gt;Small Overdue balance thresholds&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numOverdueSmallBalanceThreshold"&gt;Overdue:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numOverdueSmallBalanceThreshold" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numContractualOverdueSmallBalanceThreshold"&gt;Contractual:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numContractualOverdueSmallBalanceThreshold" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDefaultInterest"&gt;Default Interest&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Default Interest Rate&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultInterestRateBasis"&gt;Rate Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultInterestRateBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numDefaultInterestRate"&gt;Default Rate:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numDefaultInterestRate" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Charge Default Interest on Account 'Balance' when:&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkDefaultInterestInDefault" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkDefaultInterestPostMaturity" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkDefaultInterestPostFinalDate" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Charge Default Interest when Overdue?&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultInterestOverdueBasis"&gt;Overdue Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultInterestOverdueBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numDefaultInterestOverdueThreshold"&gt;Threshold:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numDefaultInterestOverdueThreshold" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultInterestOverdueChargeBasis"&gt;Charge Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultInterestOverdueChargeBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;b&gt;Default Interest Minimum Charge threshold&lt;/b&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numDefaultInterestMinimumCharge"&gt;Min Charge:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numDefaultInterestMinimumCharge" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDefaultFee"&gt;Default Fee&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboDefaultFeeChargeBasis"&gt;Charge Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultFeeChargeBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numDefaultFeeValue"&gt;Value:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numDefaultFeeValue" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkDefaultFeeIgnoreLimit" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblFacilityFee"&gt;Facility Fee&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboFacilityFeeChargeBasis"&gt;Charge Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboFacilityFeeChargeBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numFacilityFeeValue"&gt;Value:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numFacilityFeeValue" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkFacilityFeeChargeThresholdApply" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="numFacilityFeeChargeThresholdValue"&gt;Threshold&amp;nbsp;value:&amp;nbsp;&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numFacilityFeeChargeThresholdValue" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkFacilityFeeChargeIfMovement" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Credit Limit --&gt;
    &lt;div id="pageCreditLimit"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCreditLimits"&gt;Credit Limits&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCreditLimitCount"&gt;Used/ Count:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCreditLimitCount" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkCreditLimitKeepOnRefinance" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkCreditLimitUsePendingWithdrawals" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkCreditLimitUseUnclearedFunds" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkCreditLimitUseOtherDeductions" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="txtCreditLimitOtherDeductionsDescription"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtCreditLimitOtherDeductionsDescription" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
                
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCreditLimit1"&gt;Credit Limit 1&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtCreditLimit1Description"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtCreditLimit1Description" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numCreditLimit1"&gt;Value:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;
            &lt;input id="numCreditLimit1" /&gt;
            &lt;input id="chkCreditLimit1Required" type="checkbox" /&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCreditLimit2"&gt;Credit Limit 2&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtCreditLimit2Description"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtCreditLimit2Description" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numCreditLimit2"&gt;Value:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;
            &lt;input id="numCreditLimit2" /&gt;
            &lt;input id="chkCreditLimit2Required" type="checkbox" /&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCreditLimit3"&gt;Credit Limit 3&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtCreditLimit3Description"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtCreditLimit3Description" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numCreditLimit3"&gt;Value:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;
            &lt;input id="numCreditLimit3" /&gt;
            &lt;input id="chkCreditLimit3Required" type="checkbox" /&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblOverLimitDefault"&gt;Over Limit Default&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOverLimitBasis"&gt;Default Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOverLimitBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numOverLimitThresholdPercent"&gt;Threshold %:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numOverLimitThresholdPercent" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numOverLimitThreshold"&gt;Threshold:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numOverLimitThreshold" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblOverLimitFee"&gt;Over Limit Fee&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOverLimitFeeChargeBasis"&gt;Charge Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOverLimitFeeChargeBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numOverLimitFeeValue"&gt;Value:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numOverLimitFeeValue" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Close Options --&gt;
    &lt;div id="pageCloseOptions"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:9em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblClosedPending"&gt;Closed Pending status options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;    
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkClosedPendingDefault" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numClosedPendingReviewDays"&gt;Review Days:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numClosedPendingReviewDays" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkClosedPendingAutoClose" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblLossCalculationClosing"&gt;Loss calculation when closing an Account&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCloseLossFormula"&gt;Loss Formula:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCloseLossFormula" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblLossCalculationRefinancing"&gt;Loss calculation when refinancing an Account&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboRefinanceLossFormula"&gt;Loss Formula:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboRefinanceLossFormula" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblSmallBalanceWriteOff"&gt;Small Balance Write-Off and Refund thresholds&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numSmallBalanceWriteOffDebit"&gt;Write-Off Debit:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numSmallBalanceWriteOffDebit" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numSmallBalanceWriteOffCredit"&gt;Write-Off Credit:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numSmallBalanceWriteOffCredit" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numSmallBalanceRefundCredit"&gt;Refund Credit:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numSmallBalanceRefundCredit" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCloseOptions"&gt;Other options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAutomaticClose" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkOptionAutomaticClosePreMaturity" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionArchiveDeclinedUnwanted" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowStatusClosedToOpen" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Other --&gt;
    &lt;div id="pageOther"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:12em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblStatementOptions"&gt;Statement options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;   
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkStatementUse" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;   
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboStatementCycle"&gt;Statements:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboStatementCycle" /&gt;&lt;/td&gt;
        &lt;/tr&gt;     
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="dateStatementDateNext"&gt;Next Date:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="dateStatementDateNext" /&gt;&lt;/td&gt;
        &lt;/tr&gt;   
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblParameterSetUserDefined"&gt;Parameter Set to enter User Defined details&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboParameterSetUserDefined"&gt;Parameter Set:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboParameterSetUserDefined" /&gt;&lt;/td&gt;
        &lt;/tr&gt;   
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDebtRatioThreshold"&gt;Debt Ratio Threshold&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numDebtRatioThreshold"&gt;Debt Ratio:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numDebtRatioThreshold" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblClientStatisticDataSource"&gt;Client Statistic Data Source&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientStatisticSourceExtraAsset"&gt;Extra Asset:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientStatisticSourceExtraAsset" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientStatisticSourceExtraLiability"&gt;Extra Liability:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientStatisticSourceExtraLiability" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientStatisticSourceConsolidatedLiability"&gt;Consolidated Liability:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientStatisticSourceConsolidatedLiability" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboClientStatisticSourceConsolidatedExpense"&gt;Consolidated Expense:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboClientStatisticSourceConsolidatedExpense" /&gt;&lt;/td&gt;
        &lt;/tr&gt;  
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblOtherOptions"&gt;Other options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeAccountLevelInsurance" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowWithdrawals" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkDepositAllowWithdrawalsNegativeBalance" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkTransferCommonClient" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowRestructure" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionAllowRefinanceInto" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkOptionAllowRefinanceRedatedForward" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkUserFlagA" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkUserFlagB" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblSummaryPageOptions"&gt;Summary Page options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;  
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowAccountIdWithCheckDigit" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowHistoryRating" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowTotalAdvances" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowOverdue" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkShowContractualOverdue" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt; 
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Promotions --&gt;
    &lt;div id="pagePromotions"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:9em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblPromotionOptions"&gt;Promotion options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboPromotionBasis"&gt;Basis:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboPromotionBasis" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboPromotionParameterSetUserDefined"&gt;Parameter Set:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboPromotionParameterSetUserDefined" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblPromotions"&gt;Promotions&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;    
        &lt;tr id="trPromotionMessage"&gt;
          &lt;th colspan="2"&gt;&lt;div class="is-info-text info"&gt;Promotions are maintained via the Promotions page on the read-only version of this form in finPOWER Connect Cloud.&lt;/div&gt;&lt;/th&gt;
        &lt;/tr&gt;    
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Transactions --&gt;
    &lt;div id="pageTransactions"&gt;            
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblNetAdvanceLimits"&gt;New Account Net Advance limits&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numNetAdvanceMinimum"&gt;Minimum:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numNetAdvanceMinimum" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numNetAdvanceMaximum"&gt;Maximum:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numNetAdvanceMaximum" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTransactionOptions"&gt;Transaction Options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkOptionCreateAdjustedToZeroTransactions" type="checkbox" /&gt;&lt;/th&gt;          
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblTransactions"&gt;Transactions (Opening and Ongoing)&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;div class="is-info-text info"&gt;Opening and ongoing Transactions are maintained via the Transactions page on the read-only version of this form in finPOWER Connect Cloud.&lt;/div&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Documents --&gt;
    &lt;div id="pageDocuments"&gt;
      &lt;div style="display:flex; flex-direction:column; position:absolute; top:0; left:0; right:0; bottom:0; padding:4px"&gt;
        &lt;div style="flex-grow:0"&gt;
          &lt;table class="is-form"&gt;
            &lt;tr&gt;
              &lt;th colspan="2"&gt;&lt;label&gt;Special Account Documents&lt;/label&gt;&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;

        &lt;div style="position:relative; flex-grow:1; max-width:1024px; margin-left:8px; max-height:320px"&gt;
          &lt;div id="gridDocumentLinks" class="is-dock-fill"&gt;&lt;/div&gt;
        &lt;/div&gt;

        &lt;div style="flex-grow:0"&gt;
          &lt;table class="is-form"&gt;
            &lt;tr&gt;
              &lt;td colspan="2"&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th colspan="2"&gt;&lt;label&gt;Documents available to this Account Type&lt;/label&gt;&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;

        &lt;div style="position:relative; flex-grow:1; max-width:1024px; margin-left:8px"&gt;
          &lt;div id="gridDocuments" class="is-dock-fill"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;



    &lt;!-- Rules --&gt;
    &lt;div id="pageRules"&gt;
      &lt;div class="is-info-text"&gt;Rules are maintained via the Rules page on the read-only version of this form in finPOWER Connect Cloud.&lt;/div&gt;
    &lt;/div&gt;



    &lt;!-- Accounting --&gt;
    &lt;div id="pageAccounting"&gt;
      &lt;div style="display:flex; flex-direction:column; position:absolute; top:0; left:0; right:0; bottom:0; padding:4px"&gt;
        &lt;div&gt;
          &lt;table class="is-form"&gt;
            &lt;colgroup&gt;
              &lt;col style="width:10em" /&gt;
              &lt;col /&gt;
            &lt;/colgroup&gt;

            &lt;tr&gt;
              &lt;th colspan="2"&gt;&lt;label&gt;GL Accounts where Transactions are posted to&lt;/label&gt;&lt;/th&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboControlGlAccount"&gt;Control Account:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="cboControlGlAccount"/&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;th&gt;&lt;label for="cboClearingGlAccount"&gt;Clearing Account:&lt;/label&gt;&lt;/th&gt;
              &lt;td&gt;&lt;input id="cboClearingGlAccount"/&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
              &lt;th colspan="2"&gt;&lt;label&gt;Elements where Transactions are posted to&lt;/label&gt;&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;
        &lt;div style="position:relative; flex-grow:1; max-width:1024px; margin-left:8px"&gt;
          &lt;div id="gridElementLinks" class="is-dock-fill"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;



    &lt;!-- Scripts --&gt;
    &lt;div id="pageScripts"&gt;
      &lt;div style="display:flex; flex-direction:column; position:absolute; top:0; left:0; right:0; bottom:0; padding:4px"&gt;
        &lt;div style="flex-grow:0"&gt;
          &lt;table class="is-form"&gt;
            &lt;tr&gt;
              &lt;th colspan="2"&gt;&lt;label&gt;Scripts&lt;/label&gt;&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/div&gt;

        &lt;div style="position:relative; flex-grow:1; margin-left:8px"&gt;
          &lt;div id="gridScriptLinks" class="is-dock-fill"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;



    &lt;!-- User Defined --&gt;
    &lt;div id="pageUserDefined"&gt;
      &lt;div id="phUserDefined" style="display:block"&gt;&lt;/div&gt;
    &lt;/div&gt;

  &lt;/div&gt;


  &lt;!-- Form Footer --&gt;
  &lt;footer&gt;
    &lt;button id="cmdCancel" class="is-button"&gt;Cancel&lt;/button&gt;
    &lt;button id="cmdFinish" class="is-button ok"&gt;Save&lt;/button&gt;
  &lt;/footer&gt;

&lt;/div&gt;


&lt;script&gt;
// Properties
var mRecord;
var mRecord_DocumentLinks;
var mRecord_Documents;
var mRecord_ElementLinks;
var mRecord_RateTables;
var mRecord_ScriptLinks;

var mRecord_AccountClassData;
var mRecord_ProductTypeData;

var mOriginalJson;

// Global Collections
var mDocuments;
var mElements;
var mScripts;

// Controls
var C = {
  //   General
  lblCodeAndName: null,
  chkActive: null,
  txtAccountTypeId: null,
  txtDescription: null,

  cboAccountClass: null,
  cboProductType: null,
  cboCreditType: null,
  cboConsumerRegulationType: null,

  lblGeneralOtherOptions: null,
  chkCreditSale: null,
  chkLaybySale: null,

  lblCreditReporting: null,
  cboCreditReportingAccountType: null,

  cboCategory: null,
  cboIcon: null,

  txtNotes: null,

  //   New Accounts
  lblNewAccountDefaults: null,
  txtNextAccountId: null,
  txtDefaultDescription: null,
  cboDefaultLedger: null,

  chkOptionAllowLedger: null,
  chkOptionAllowFirstPaymentDate: null,
  chkOptionAllowRegularPayment: null,
  chkOptionAllowBalloonPayment: null,
  chkOptionAllowResidualValue: null,
  chkOptionAllowMaturityDate: null,
  chkOptionAllowMaturityInstruction: null,
  chkOptionAllowMinimumPayment: null,
  chkOptionAllowMinimumPaymentDueDays: null,
  chkOptionAllowMinimumPaymentHoldTo: null,
  chkOptionAllowTaxCategory: null,
  chkOptionAllowInterestCycle: null,
  chkOptionAllowInterest: null,
  chkOptionAllowStartupInterest: null,
  chkOptionAllowTotalInterest: null,
  chkOptionAllowReviewDate: null,
  cboDefaultReviewPeriod: null,

  trFinancialPageOptions: null,
  chkShowFinancialPageOverridingPaymentsTab: null,
  chkShowFinancialPageOptionsTab: null,
  chkShowInstalmentsDrilldown: null,
  chkShowInstalmentsDrilldownWeb: null,
  chkShowFinancialPagePrintQuotation: null,

  chkDisbursementsShowInNewAccountWizard: null,
  chkUserDefinedShowInNewAccountWizard: null,

  chkOptionDefaultQuoteStatus: null,
  chkOptionDefaultResidualValueFromNetAdvance: null,
  chkOptionDefaultResidualValueFromSecurities: null,
  chkOptionDefaultPrintContractDocument: null,

  chkShowWarningInfos: null,
  chkShowWarningAlerts: null,

  //   Term
  lblTermEntryMethod: null,
  cboTermEntryMethod: null,

  lblTermUse: null,
  chkTermUse: null,
  chkTermMandatory: null,

  lblTermOnCall: null,
  chkTermOnCall: null,

  lblTermDefault: null,
  cboTerm: null,
  dateTermOnDate: null,
  txtTermList: null,
  chkTermLimitToList: null,

  lblTermNumberOfPayments: null,
  numTermNumberOfPayments: null,

  lblTermLimits: null,
  cboTermMinimum: null,
  cboTermMaximum: null,

  lblTermOptions: null,
  chkOptionAllowPayArrangeExtendTerm: null,
  chkTermRollForward: null,
  numMaturityGraceDays: null,
  chkTermCalculateSchedulePastMaturityDate: null,

  lblMaturityInstructions: null,
  lstMaturityInstructionAvailableList: null,
  cboMaturityInstruction: null,

  lblMaturityReinvestmentDetails: null,
  cboMaturityAccountType: null,
  txtMaturityAccountTypesNew: null,
  chkMaturityReinvestmentCommonClient: null,

  lblMaturityRepaymentDetails: null,
  lstMaturityPaymentAvailableTypes: null,
  cboMaturityPaymentType: null,
  txtMaturityAccountTypesTransfer: null,
  chkMaturityTransferCommonClient: null,

  //   Payments
  lblDefaultPayments: null,
  cboPaymentCycle: null,
  txtPaymentCycleList: null,
  chkPaymentCycleLimitToList: null,
  
  lblDefaultFirstPayment: null,
  cboPaymentFirstPeriod: null,
  datePaymentFirstDate: null,
  txtPaymentFirstPeriodList: null,
  chkPaymentFirstPeriodLimitToList: null,
  cboPaymentFirstPeriodMaximum: null,
  
  lblMinimumPayments: null,
  cboMinimumPaymentBasis: null,
  numMinimumPaymentValue: null,
  numMinimumPaymentPercent: null,
  numMinimumPaymentDueDays: null,
  chkMinimumPaymentMoveToNextBusinessDay: null,
  chkMinimumPaymentCarryForwardPrepaid: null,
  
  lblMinimumPaymentsHoldTo: null,
  cboMinimumPaymentHoldToPeriod: null,
  dateMinimumPaymentHoldToDate: null,
  txtMinimumPaymentHoldToList: null,
  chkMinimumPaymentHoldToLimitToList: null,
  cboMinimumPaymentHoldToMaximum: null,
  
  lblPaymentOptions: null,
  cboOptionPaymentAllocationMethod: null,
  chkOptionPaymentsInAdvance: null,
  chkOptionPaymentsRound: null,
  numOptionPaymentsRoundMultiple: null,
  chkOptionPaymentsFinalPlusBalloon: null,
  chkOptionPaymentsAdjustFinalBeforeBalloon: null,
  chkOptionNextPaymentIncludesMinimumPayments: null,
  chkOptionAllowCreditBalancePreMaturity: null,
  chkPaymentEarlyPartialRepaymentWarning: null,
  chkPaymentArrangementDefaultPrintAdvice: null,
  
  lblDirectDebitOptions: null,
  chkOptionPaymentDirectDebitDateOpened: null,
  chkOptionPaymentDirectDebitBalloon: null,
  chkPaymentDirectDebitLimitToBalance: null,
  numPaymentDirectDebitMinimumThreshold: null,
  
  lblNegativePaymentOptions: null,
  chkNegativePaymentMatch: null,
  numNegativePaymentMatchDays: null,
  
  lblGracePeriod: null,
  chkPaymentGracePeriodUse: null,
  numPaymentGracePeriodDays: null,
  chkPaymentGracePeriodChargeDefault: null,
  
  lblBankReference: null,
  txtBankReferenceCode: null,
  
  lblPayTo: null,
  txtDefaultPayToDescription: null,
  cboDefaultPayToPurpose: null,
  cboDefaultPayToAccountIdentifierType: null,
  cboDefaultPayToPaymentTermType: null,
  cboDefaultPayToPaymentTermFrequency: null,

  //   Interest
  lblInterestCycle: null,
  cboInterestCycle: null,
  dateInterestCycleDateNext: null,
  txtInterestCycleList: null,
  chkInterestCycleLimitToList: null,
  
  lblStartupInterest: null,
  lstStartupInterestTypeAvailableList: null,
  cboStartupInterestType: null,
  numStartupInterestRate: null,
  cboStartupInterestRateTable: null,
  spanStartupInterestRatePremium: null,
  numStartupInterestRatePremium: null,
  cboStartupInterestPeriod: null,
  spanStartupInterestToDate: null,
  dateStartupInterestToDate: null,
  txtStartupInterestPeriodList: null,
  chkStartupInterestPeriodLimitToList: null,
  cboStartupInterestPeriodMaximum: null,
  
  lblInterest: null,
  lstInterestTypeAvailableList: null,
  cboInterestType: null,
  numInterestRate: null,
  cboInterestRateTable: null,
  spanInterestRatePremium: null,
  numInterestRatePremium: null,
  
  lblOtherInterest: null,
  cboOtherInterestType: null,
  numOtherInterestRate: null,
  txtOtherInterestDescription: null,

  //   Interest Options
  lblInterestCalculationOptions: null,
  cboOptionInterestAccruedMethod: null,
  cboOptionInterestRoundMethod: null,
  cboOptionInterestBackdating: null,
  chkOptionInterestBackdatingConvertedTransactions: null,
  
  lblInterestOptions: null,
  chkOptionInterestOnInterest: null,
  chkOptionInterestPrecomputed: null,
  chkOptionInterestChargedUpfront: null,
  chkOptionInterestChargedOriginal: null,
  chkOptionInterestFlatRate: null,
  cboOptionInterestPostMaturityBasis: null,
  chkInterestNegativeRateAllow: null,
  chkInterestNegativeRateTaxNotApplicable: null,
  chkTaxCertificateNotIssueAIL: null,
  
  lblInterestNewAccountOptions: null,
  chkInterestCycleUpdateFromPaymentCycle: null,
  chkOptionInterestAlignFirst: null,
  chkOptionInterestFixRateTable: null,
  
  lblInterestInstructions: null,
  cboInterestInstructionDown: null,
  cboInterestInstructionUp: null,
  
  lblFloatingInterestRateOptions: null,
  chkInterestEffectiveDateOrEarliestPaymentDate: null,
  cboInterestEarliestDateDefault: null,
  
  lblComparisonRate: null,
  cboComparisonRateType: null,
  numComparisonRateRoundingDecimals: null,
  numComparisonRateMaximum: null,
  dateComparisonRateMaximumNextDate: null,
  numComparisonRateMaximumNext: null,
  
  lblInterestPayment: null,
  lstInterestPaymentAvailableTypes: null,
  cboInterestPaymentType: null,
  chkInterestCommonClient: null,
  chkInterestPaymentRollForward: null,
  chkInterestPaymentCompoundFinal: null,
  chkReinvestmentPreserveInterestPaymentType: null,
  
  lblInvestmentIncomeReportingOptions: null,
  chkInterestIsFromDividends: null,
  
  lblInterestOtherOptions: null,
  chkShowZeroInterestTransactions: null,

  //   Rate Tables
  cboStandardRateTable: null,
  gridRateTables: null,

  //   Overdue &amp; Defaults
  lblOverdueOptions: null,
  chkOverdueLimitToBalance: null,
  chkContractualOverdueLimitToBalance: null,
  
  lblOverdueSmallBalanceThresholds: null,
  numOverdueSmallBalanceThreshold: null,
  numContractualOverdueSmallBalanceThreshold: null,
  
  lblDefaultInterest: null,
  cboDefaultInterestRateBasis: null,
  numDefaultInterestRate: null,
  
  chkDefaultInterestInDefault: null,
  chkDefaultInterestPostMaturity: null,
  chkDefaultInterestPostFinalDate: null,
  
  cboDefaultInterestOverdueBasis: null,
  numDefaultInterestOverdueThreshold: null,
  cboDefaultInterestOverdueChargeBasis: null,
  
  numDefaultInterestMinimumCharge: null,
  
  lblDefaultFee: null,
  cboDefaultFeeChargeBasis: null,
  numDefaultFeeValue: null,
  chkDefaultFeeIgnoreLimit: null,
  
  lblFacilityFee: null,
  cboFacilityFeeChargeBasis: null,
  numFacilityFeeValue: null,
  chkFacilityFeeChargeThresholdApply: null,
  numFacilityFeeChargeThresholdValue: null,
  chkFacilityFeeChargeIfMovement: null,

  //   Credit Limit
  lblCreditLimits: null,
  cboCreditLimitCount: null,
  chkCreditLimitKeepOnRefinance: null,
  chkCreditLimitUsePendingWithdrawals: null,
  chkCreditLimitUseUnclearedFunds: null,
  chkCreditLimitUseOtherDeductions: null,
  txtCreditLimitOtherDeductionsDescription: null,
  
  lblCreditLimit1: null,
  txtCreditLimit1Description: null,
  numCreditLimit1: null,
  chkCreditLimit1Required: null,
  
  lblCreditLimit2: null,
  txtCreditLimit2Description: null,
  numCreditLimit2: null,
  chkCreditLimit2Required: null,
  
  lblCreditLimit3: null,
  txtCreditLimit3Description: null,
  numCreditLimit3: null,
  chkCreditLimit3Required: null,

  lblOverLimitDefault: null,
  cboOverLimitBasis: null,
  numOverLimitThresholdPercent: null,
  numOverLimitThreshold: null,
  
  lblOverLimitFee: null,
  cboOverLimitFeeChargeBasis: null,
  numOverLimitFeeValue: null,

  //   Close Options
  lblClosedPending: null,
  chkClosedPendingDefault: null,
  numClosedPendingReviewDays: null,
  chkClosedPendingAutoClose: null,
  
  lblLossCalculationClosing: null,
  cboCloseLossFormula: null,
  
  lblLossCalculationRefinancing: null,
  cboRefinanceLossFormula: null,
  
  lblSmallBalanceWriteOff: null,
  numSmallBalanceWriteOffDebit: null,
  numSmallBalanceWriteOffCredit: null,
  numSmallBalanceRefundCredit: null,
  
  lblCloseOptions: null,
  chkOptionAutomaticClose: null,
  chkOptionAutomaticClosePreMaturity: null,
  chkOptionArchiveDeclinedUnwanted: null,
  chkOptionAllowStatusClosedToOpen: null,

  //   Other
  lblStatementOptions: null,
  chkStatementUse: null,
  cboStatementCycle: null,
  dateStatementDateNext: null,
  
  lblParameterSetUserDefined: null,
  cboParameterSetUserDefined: null,
  
  lblDebtRatioThreshold: null,
  numDebtRatioThreshold: null,
  
  lblClientStatisticDataSource: null,
  cboClientStatisticSourceExtraAsset: null,
  cboClientStatisticSourceExtraLiability: null,
  cboClientStatisticSourceConsolidatedLiability: null,
  cboClientStatisticSourceConsolidatedExpense: null,
  
  lblOtherOptions: null,
  chkIncludeAccountLevelInsurance: null,
  chkOptionAllowWithdrawals: null,
  chkDepositAllowWithdrawalsNegativeBalance: null,
  chkTransferCommonClient: null,
  chkOptionAllowRestructure: null,
  chkOptionAllowRefinanceInto: null,
  chkOptionAllowRefinanceRedatedForward: null,
  chkUserFlagA: null,
  chkUserFlagB: null,
  
  lblSummaryPageOptions: null,
  chkShowAccountIdWithCheckDigit: null,
  chkShowHistoryRating: null,
  chkShowTotalAdvances: null,
  chkShowOverdue: null,
  chkShowContractualOverdue: null,

  //   Promotions
  lblPromotionOptions: null,
  cboPromotionBasis: null,
  cboPromotionParameterSetUserDefined: null,
  
  lblPromotions: null,
  trPromotionMessage: null,

  //   Transactions
  lblNetAdvanceLimits: null,
  numNetAdvanceMinimum: null,
  numNetAdvanceMaximum: null,
  
  lblTransactionOptions: null,
  chkOptionCreateAdjustedToZeroTransactions: null,
  lblTransactions: null,

  //   Documents
  gridDocumentLinks: null,
  gridDocuments: null,

  //   Accounting
  cboControlGlAccount: null,
  cboClearingGlAccount: null,
  gridElementLinks: null,

  //   Scripts
  gridScriptLinks: null,

  //   User Defined
  phUserDefined: null,
}

// Form
var frmMain;
var tabDetails;

// Buttons
var cmdCancel;
var cmdFinish;

// Other

// ==========
// Initialise
// ==========
$(function () {
  // --------
  // Controls
  // --------
  //   General
  C.lblCodeAndName = widget.UI.Label("lblCodeAndName", {});
  C.txtAccountTypeId = widget.UI.TextBox("txtAccountTypeId", {
    allowBlank: false,
    maxLength: 10,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.chkActive = widget.UI.CheckBox("chkActive", {
    caption: "Active?",
  });
  C.txtDescription = widget.UI.TextBox("txtDescription", {
    allowBlank: false,
    maxLength: 50,
  });

  C.cboAccountClass = widget.UI.ComboBox("cboAccountClass", {
    allowBlank: false,
    maxLength: 20,

    onChange: cboAccountClass_Change,
  });
  C.cboProductType = widget.UI.DBCombo("cboProductType", {
    formKeyOpen: "ProductTypes",
    width: widget.UI.FIELD_WIDTH_CODE_10,

    onChange: cboProductType_Change,
  });
  C.cboCreditType = widget.UI.ComboBox("cboCreditType", {
    allowBlank: false,
    limitToList: true,
    maxLength: 20,
    
    onChange: cboCreditType_Change,
  });
  C.cboConsumerRegulationType = widget.UI.ComboBox("cboConsumerRegulationType", {
    allowBlank: false,
    limitToList: true,
    maxLength: 50,
  });

  C.lblGeneralOtherOptions = widget.UI.Label("lblGeneralOtherOptions", {});
  C.chkCreditSale = widget.UI.CheckBox("chkCreditSale", {
    caption: "Is this a Credit Sale?"
  });
  C.chkLaybySale = widget.UI.CheckBox("chkLaybySale", {
    caption: "Is this a Layby Sale?"
  });

  C.lblCreditReporting = widget.UI.Label("lblCreditReporting", {});
  C.cboCreditReportingAccountType = widget.UI.InformationListComboBox("cboCreditReportingAccountType", {
    maxLength: 50,
  });

  C.cboCategory = widget.UI.InformationListComboBox("cboCategory", {
    maxLength: 50,
  });
  C.cboIcon = widget.UI.IconComboBox("cboIcon", {
    iconPrefix: "AccountType_",
    limitToList: true,
    width: "12em",
  });

  C.txtNotes = widget.UI.TextBox("txtNotes", {
    multiLine: true,
    rows: 6,
  });

  //   New Accounts
  C.lblNewAccountDefaults = widget.UI.Label("lblNewAccountDefaults", {
    tooltipText: "The tags '[Security]' and '[Dealer]' can be inserted into the Description. These will be replaced with a semi-colon separated list of Security Descriptions and the Dealer Name respectively when creating a new Account.",
  });
  C.txtNextAccountId = widget.UI.TextBox("txtNextAccountId", {
    maxLength: 10,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.txtDefaultDescription = widget.UI.TextBox("txtDefaultDescription", {
    maxLength: 255,
  });
  C.cboDefaultLedger = widget.UI.InformationListComboBox("cboDefaultLedger", {
    allowBlank: true,
    maxLength: 20,
  });

  C.chkOptionAllowLedger = widget.UI.CheckBox("chkOptionAllowLedger", {
    caption: "Ledger"
  });
  C.chkOptionAllowFirstPaymentDate = widget.UI.CheckBox("chkOptionAllowFirstPaymentDate", {
    caption: "First Payment Date"
  });
  C.chkOptionAllowRegularPayment = widget.UI.CheckBox("chkOptionAllowRegularPayment", {
    caption: "Overriding Regular Payment"
  });
  C.chkOptionAllowBalloonPayment = widget.UI.CheckBox("chkOptionAllowBalloonPayment", {
    caption: "Balloon Payment"
  });
  C.chkOptionAllowResidualValue = widget.UI.CheckBox("chkOptionAllowResidualValue", {
    caption: "Residual Value"
  });
  C.chkOptionAllowMaturityDate = widget.UI.CheckBox("chkOptionAllowMaturityDate", {
    caption: "Maturity Date"
  });
  C.chkOptionAllowMaturityInstruction = widget.UI.CheckBox("chkOptionAllowMaturityInstruction", {
    caption: "Maturity Instructions"
  });
  C.chkOptionAllowMinimumPayment = widget.UI.CheckBox("chkOptionAllowMinimumPayment", {
    caption: "Minimum Payment"
  });
  C.chkOptionAllowMinimumPaymentDueDays = widget.UI.CheckBox("chkOptionAllowMinimumPaymentDueDays", {
    caption: "Minimum Payment Due Days"
  });
  C.chkOptionAllowMinimumPaymentHoldTo = widget.UI.CheckBox("chkOptionAllowMinimumPaymentHoldTo", {
    caption: "Minimum Payment 'Hold To' date"
  });
  C.chkOptionAllowTaxCategory = widget.UI.CheckBox("chkOptionAllowTaxCategory", {
    caption: "Tax Category"
  });
  C.chkOptionAllowInterestCycle = widget.UI.CheckBox("chkOptionAllowInterestCycle", {
    caption: "Interest Cycle"
  });
  C.chkOptionAllowInterest = widget.UI.CheckBox("chkOptionAllowInterest", {
    caption: "Interest"
  });
  C.chkOptionAllowStartupInterest = widget.UI.CheckBox("chkOptionAllowStartupInterest", {
    caption: "Startup Interest"
  });
  C.chkOptionAllowTotalInterest = widget.UI.CheckBox("chkOptionAllowTotalInterest", {
    caption: "Total Interest (to calculate Interest Rate)"
  });
  C.chkOptionAllowReviewDate = widget.UI.CheckBox("chkOptionAllowReviewDate", {
    caption: "Review Date",

    onChange: chkOptionAllowReviewDate_Change,
  });
  C.cboDefaultReviewPeriod = widget.UI.DateCycleComboBox("cboDefaultReviewPeriod", {
    isFrequency: false,
  });

  C.trFinancialPageOptions = $("#trFinancialPageOptions");
  C.chkShowFinancialPageOverridingPaymentsTab = widget.UI.CheckBox("chkShowFinancialPageOverridingPaymentsTab", {
    caption: "Overriding Payments tab"
  });
  C.chkShowFinancialPageOptionsTab = widget.UI.CheckBox("chkShowFinancialPageOptionsTab", {
    caption: "Options tab"
  });
  C.chkShowInstalmentsDrilldown = widget.UI.CheckBox("chkShowInstalmentsDrilldown", {
    caption: "'Instalments' button",

    onChange: chkShowInstalmentsDrilldown_Change,
  });
  C.chkShowInstalmentsDrilldownWeb = widget.UI.CheckBox("chkShowInstalmentsDrilldownWeb", {
    caption: "Show in Web Interface?"
  });
  C.chkShowFinancialPagePrintQuotation = widget.UI.CheckBox("chkShowFinancialPagePrintQuotation", {
    caption: "'Print' button to print a Quotation"
  });

  C.chkDisbursementsShowInNewAccountWizard = widget.UI.CheckBox("chkDisbursementsShowInNewAccountWizard", {
    caption: "Disbursements"
  });
  C.chkUserDefinedShowInNewAccountWizard = widget.UI.CheckBox("chkUserDefinedShowInNewAccountWizard", {
    caption: "User Defined"
  });

  C.chkOptionDefaultQuoteStatus = widget.UI.CheckBox("chkOptionDefaultQuoteStatus", {
    caption: "Status as 'Quote'"
  });
  C.chkOptionDefaultResidualValueFromNetAdvance = widget.UI.CheckBox("chkOptionDefaultResidualValueFromNetAdvance", {
    caption: "Residual Value from Net Advance",
    
    onChange: chkOptionDefaultResidualValueFromNetAdvance_Change,
  });
  C.chkOptionDefaultResidualValueFromSecurities = widget.UI.CheckBox("chkOptionDefaultResidualValueFromSecurities", {
    caption: "Residual Value from Securities",
    
    onChange: chkOptionDefaultResidualValueFromSecurities_Change,
  });
  C.chkOptionDefaultPrintContractDocument = widget.UI.CheckBox("chkOptionDefaultPrintContractDocument", {
    caption: "Print Contract Document"
  });

  C.chkShowWarningInfos = widget.UI.CheckBox("chkShowWarningInfos", {
    caption: "Information items"
  });
  C.chkShowWarningAlerts = widget.UI.CheckBox("chkShowWarningAlerts", {
    caption: "Alert items"
  });

  //   Term
  C.lblTermEntryMethod = widget.UI.Label("lblTermEntryMethod", {});
  C.cboTermEntryMethod = widget.UI.ComboBox("cboTermEntryMethod", {
    allowBlank: false,
    limitToList: true,
    width: "13em",

    onChange: pageTerm_Refresh,
  });

  C.lblTermUse = widget.UI.Label("lblTermUse", {});
  C.chkTermUse = widget.UI.CheckBox("chkTermUse", {
    caption: "Use Term and Maturity Date?",

    onChange: pageTerm_Refresh,
  });
  C.chkTermMandatory = widget.UI.CheckBox("chkTermMandatory", {
    caption: "Is the Maturity Date mandatory?",
  });

  C.lblTermOnCall = widget.UI.Label("lblTermOnCall", {});
  C.chkTermOnCall = widget.UI.CheckBox("chkTermOnCall", {
    caption: "Is this an On Call Deposit Type?",

    onChange: pageTerm_Refresh,
  });

  C.lblTermDefault = widget.UI.Label("lblTermDefault", {});
  C.cboTerm = widget.UI.DateCycleComboBox("cboTerm", {
    allowBlank: false,
    isFrequency: false,

    onChange: pageTerm_Refresh,
  });
  C.dateTermOnDate = widget.UI.DateBox("dateTermOnDate", {
  });
  C.txtTermList = widget.UI.TextBox("txtTermList", {
    maxLength: 255,
    multiLine: true,
    rows: 3,
  });
  C.chkTermLimitToList = widget.UI.CheckBox("chkTermLimitToList", {
    caption: "Limit Term to List (for New Accounts)?",
  });

  C.lblTermNumberOfPayments = widget.UI.Label("lblTermNumberOfPayments", {});
  C.numTermNumberOfPayments = widget.UI.NumberBox("numTermNumberOfPayments", {
    allowBlank: false,
    decimals: 0,
    minValue: 1,
    maxValue: 9999,
    width: "4em",
  });

  C.lblTermLimits = widget.UI.Label("lblTermLimits", {});
  C.cboTermMinimum = widget.UI.DateCycleComboBox("cboTermMinimum", {
    isFrequency: false,
  });
  C.cboTermMaximum = widget.UI.DateCycleComboBox("cboTermMaximum", {
    isFrequency: false,
  });

  C.lblTermOptions = widget.UI.Label("lblTermOptions", {});
  C.chkOptionAllowPayArrangeExtendTerm = widget.UI.CheckBox("chkOptionAllowPayArrangeExtendTerm", {
    caption: "Allow Payment Arrangement to extend Term?",
  });
  C.chkTermRollForward = widget.UI.CheckBox("chkTermRollForward", {
    caption: "Roll Maturity Date forward if it falls on a non-Business Day?",
  });
  C.numMaturityGraceDays = widget.UI.NumberBox("numMaturityGraceDays", {
    decimals: 0,
    minValue: 0,
    maxValue: 9999,
    width: "4em",
  });
  C.chkTermCalculateSchedulePastMaturityDate = widget.UI.CheckBox("chkTermCalculateSchedulePastMaturityDate", {
    caption: "Calculate Schedule past Maturity Date?",
  });

  C.lblMaturityInstructions = widget.UI.Label("lblMaturityInstructions", {});
  C.lstMaturityInstructionAvailableList = widget.UI.CheckList("lstMaturityInstructionAvailableList", {
    allowBlank: false,

    onChange: pageTerm_Refresh,
  });
  C.cboMaturityInstruction = widget.UI.ComboBox("cboMaturityInstruction", {
    allowBlank: false,
    limitToList: true,
  });

  C.lblMaturityReinvestmentDetails = widget.UI.Label("lblMaturityReinvestmentDetails", {});
  C.cboMaturityAccountType = widget.UI.DBCombo("cboMaturityAccountType", {
    formKeyOpen: "AccountTypes",
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.txtMaturityAccountTypesNew = widget.UI.TextBox("txtMaturityAccountTypesNew", {
    maxLength: 255,

    onButtonClick: txtMaturityAccountTypesNew_ButtonClick,
  });
  C.txtMaturityAccountTypesNew.ButtonsDefine([{id: "Lookup", icon: "Find", tooltipText: "Lookup"}]);
  C.chkMaturityReinvestmentCommonClient = widget.UI.CheckBox("chkMaturityReinvestmentCommonClient", {
    caption: "Reinvestment Deposit must include a common Client?",
  });

  C.lblMaturityRepaymentDetails = widget.UI.Label("lblMaturityRepaymentDetails", {});
  C.lstMaturityPaymentAvailableTypes = widget.UI.CheckList("lstMaturityPaymentAvailableTypes", {
    allowBlank: false,

    onChange: pageTerm_Refresh,
  });
  C.cboMaturityPaymentType = widget.UI.ComboBox("cboMaturityPaymentType", {
    limitToList: true,
  });
  C.txtMaturityAccountTypesTransfer = widget.UI.TextBox("txtMaturityAccountTypesTransfer", {
    maxLength: 255,

    onButtonClick: txtMaturityAccountTypesNew_ButtonClick, // Co-opt the same lookup button
  });
  C.txtMaturityAccountTypesTransfer.ButtonsDefine([{id: "Lookup", icon: "Find", tooltipText: "Lookup"}]);
  C.chkMaturityTransferCommonClient = widget.UI.CheckBox("chkMaturityTransferCommonClient", {
    caption: "Transfer Deposit must include a common Client?",
  });

  //   Payments
  C.lblDefaultPayments = widget.UI.Label("lblDefaultPayments", {
    tooltipText: "Payment List: A comma separated list of default Payment cycles to suggest in the New Account Wizard\n\nLimit Payment cycle to List?: If checked the Payment cycle for a new Account must be an item in the List above",
  });
  C.cboPaymentCycle = widget.UI.DateCycleComboBox("cboPaymentCycle", {
    allowBlank: false,    
    isFrequency: true,
  });
  C.txtPaymentCycleList = widget.UI.TextBox("txtPaymentCycleList", {
    blankTip: "Weekly,Fortnightly,Monthly,End of Month,Quarterly,Yearly",
    multiLine: true,
    rows: 4,
  });
  C.chkPaymentCycleLimitToList = widget.UI.CheckBox("chkPaymentCycleLimitToList", {
    caption: "Limit Payment cycle to List?",
  });
  
  C.lblDefaultFirstPayment = widget.UI.Label("lblDefaultFirstPayment", {
    tooltipText: "Period List: A comma separated list of default First Payment periods to suggest in the New Account Wizard",
  });
  C.cboPaymentFirstPeriod = widget.UI.DateCycleComboBox("cboPaymentFirstPeriod", {
    allowBlank: false,
    
    onChange: cboPaymentFirstPeriod_Change,
  });
  C.datePaymentFirstDate = widget.UI.DateBox("datePaymentFirstDate", {});
  C.txtPaymentFirstPeriodList = widget.UI.TextBox("txtPaymentFirstPeriodList", {
    blankTip: "Standard,Opening,On Date,At Maturity,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years",
    multiLine: true,
    rows: 4,
  });
  C.chkPaymentFirstPeriodLimitToList = widget.UI.CheckBox("chkPaymentFirstPeriodLimitToList", {
    caption: "Limit First Payment period to List?",
  });
  C.cboPaymentFirstPeriodMaximum = widget.UI.DateCycleComboBox("cboPaymentFirstPeriodMaximum", {});
  
  C.lblMinimumPayments = widget.UI.Label("lblMinimumPayments", {
    tooltipText: "'Interest Balance' and 'Interest/Fees Balance' may not be suitable without customisations if Interest is charged on the same day as the Statement and the Minimum Payment Due Days is set to 0\n\nDue Days: Number of days after the Statement that the Minimum Payment is due",
  });  
  C.cboMinimumPaymentBasis = widget.UI.ComboBox("cboMinimumPaymentBasis", {
    limitToList: true,
    
    onChange: cboMinimumPaymentBasis_Change,
  });
  C.numMinimumPaymentValue = widget.UI.NumberBox("numMinimumPaymentValue", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.numMinimumPaymentPercent = widget.UI.NumberBox("numMinimumPaymentPercent", {
    decimals: 4,
    minValue: 0,
    maxValue: 999999999999999,
    percentage: true,
  });
  C.numMinimumPaymentDueDays = widget.UI.NumberBox("numMinimumPaymentDueDays", {
    decimals: 0,
    minValue: 0,
    maxValue: 999,
  });
  C.chkMinimumPaymentMoveToNextBusinessDay = widget.UI.CheckBox("chkMinimumPaymentMoveToNextBusinessDay", {
    caption: "Roll forward if non-business day?",
    captionWrap: true,
  });
  C.chkMinimumPaymentCarryForwardPrepaid = widget.UI.CheckBox("chkMinimumPaymentCarryForwardPrepaid", {
    caption: "Carry forward prepaid overdue Balance?",  
  });
  
  C.lblMinimumPaymentsHoldTo = widget.UI.Label("lblMinimumPaymentsHoldTo", {
    tooltipText: "Period List: A comma separated list of default Hold To periods to suggest in the New Account Wizard",
  });
  C.cboMinimumPaymentHoldToPeriod = widget.UI.DateCycleComboBox("cboMinimumPaymentHoldToPeriod", {
    allowBlank: false,    
    
    onChange: cboMinimumPaymentHoldToPeriod_Change,
  });
  C.dateMinimumPaymentHoldToDate = widget.UI.DateBox("dateMinimumPaymentHoldToDate", {
    allowBlank: false,
  });
  C.txtMinimumPaymentHoldToList = widget.UI.TextBox("txtMinimumPaymentHoldToList", {
    blankTip: "None,On Date,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years",
    multiLine: true,
    rows: 4,
  });
  C.chkMinimumPaymentHoldToLimitToList = widget.UI.CheckBox("chkMinimumPaymentHoldToLimitToList", {
    caption: "Limit Hold To period to List (for New Accounts)?",
  });
  C.cboMinimumPaymentHoldToMaximum = widget.UI.DateCycleComboBox("cboMinimumPaymentHoldToMaximum", {});
  
  C.lblPaymentOptions = widget.UI.Label("lblPaymentOptions", {
    tooltipText: "Are Payments in Advance?: Leave unchecked for Payments in Arrears\n\nRound up Regular Payment?: If checked the Regular Payment in the New Account wizard will be rounded up to the multiple defined",
  });
  C.cboOptionPaymentAllocationMethod = widget.UI.ComboBox("cboOptionPaymentAllocationMethod", {
    limitToList: true,
  });
  C.chkOptionPaymentsInAdvance = widget.UI.CheckBox("chkOptionPaymentsInAdvance", {
    caption: "Are Payments in Advance, i.e., at the beginning of a Payment Period?",
    captionWrap: true,
  });
  C.chkOptionPaymentsRound = widget.UI.CheckBox("chkOptionPaymentsRound", {
    caption: "Round up Regular Payment?",
    captionWrap: true,
    
    onChange: chkOptionPaymentsRound_Change,
  });
  C.numOptionPaymentsRoundMultiple = widget.UI.NumberBox("numOptionPaymentsRoundMultiple", {
    decimals: 2,
    minValue: 0,
    maxValue: 100,
  });
  C.chkOptionPaymentsFinalPlusBalloon = widget.UI.CheckBox("chkOptionPaymentsFinalPlusBalloon", {
    caption: "Include Regular Payment with Balloon Payment?",
    captionWrap: true,
  });
  C.chkOptionPaymentsAdjustFinalBeforeBalloon = widget.UI.CheckBox("chkOptionPaymentsAdjustFinalBeforeBalloon", {
    caption: "Adjust Final Payment before Balloon Payment?",
    captionWrap: true,
  });
  C.chkOptionNextPaymentIncludesMinimumPayments = widget.UI.CheckBox("chkOptionNextPaymentIncludesMinimumPayments", {
    caption: "Next Payment includes future Minimum Payments?",
    captionWrap: true,
  });
  C.chkOptionAllowCreditBalancePreMaturity = widget.UI.CheckBox("chkOptionAllowCreditBalancePreMaturity", {
    caption: "Allow Credit/ Zero balance before maturity date (normally only where Payments in Advance)?",
    captionWrap: true,
  });
  C.chkPaymentEarlyPartialRepaymentWarning = widget.UI.CheckBox("chkPaymentEarlyPartialRepaymentWarning", {
    caption: "Warn User in Account Payment wizard if early partial Repayment?",
    captionWrap: true,
  });
  C.chkPaymentArrangementDefaultPrintAdvice = widget.UI.CheckBox("chkPaymentArrangementDefaultPrintAdvice", {
    caption: "Default 'Print Advice?' in Payment Arrangement wizard?",
    captionWrap: true,
  });
  
  C.lblDirectDebitOptions = widget.UI.Label("lblDirectDebitOptions", {
    tooltipText: "Minimum Other: Minimum threshold for Direct Debiting other (i.e. non-Payment Due) amounts"
  });
  C.chkOptionPaymentDirectDebitDateOpened = widget.UI.CheckBox("chkOptionPaymentDirectDebitDateOpened", {
    caption: "Direct Debit Payments due on opening date?",
    captionWrap: true,
  });
  C.chkOptionPaymentDirectDebitBalloon = widget.UI.CheckBox("chkOptionPaymentDirectDebitBalloon", {
    caption: "Direct Debit Balloon Payment?",
    captionWrap: true,
  });
  C.chkPaymentDirectDebitLimitToBalance = widget.UI.CheckBox("chkPaymentDirectDebitLimitToBalance", {
    caption: "Limit Direct Debits to Account Balance (including Accruals)?",
    captionWrap: true,
  });
  C.numPaymentDirectDebitMinimumThreshold = widget.UI.NumberBox("numPaymentDirectDebitMinimumThreshold", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  
  C.lblNegativePaymentOptions = widget.UI.Label("lblNegativePaymentOptions", {});
  C.chkNegativePaymentMatch = widget.UI.CheckBox("chkNegativePaymentMatch", {
    caption: "Match Negative Payments to Original?",
    captionWrap: true,
    
    onChange: chkNegativePaymentMatch_Change,
  });
  C.numNegativePaymentMatchDays = widget.UI.NumberBox("numNegativePaymentMatchDays", {
    decimals: 0,
    minValue: 0,
    maxValue: 31,
  });
  
  C.lblGracePeriod = widget.UI.Label("lblGracePeriod", {
    tooltipText: "Business Days: Zero indicates today if a business day, otherwise the next business day after today",
  });
  C.chkPaymentGracePeriodUse = widget.UI.CheckBox("chkPaymentGracePeriodUse", {
    caption: "Use Payment Grace Period?",
    captionWrap: true,
    
    onChange: chkPaymentGracePeriodUse_Change,
  });
  C.numPaymentGracePeriodDays = widget.UI.NumberBox("numPaymentGracePeriodDays", {
    decimals: 0,
    minValue: 0,
    maxValue: 15,
  });
  C.chkPaymentGracePeriodChargeDefault = widget.UI.CheckBox("chkPaymentGracePeriodChargeDefault", {
    caption: "Charge Defaults in partial grace period at end of Interest Period?",
    captionWrap: true,
  });
  
  C.lblBankReference = widget.UI.Label("lblBankReference", {});
  C.txtBankReferenceCode = widget.UI.TextBox("txtBankReferenceCode", {
    maxLength: 20,
  });

  C.lblPayTo = widget.UI.Label("lblPayTo", {});
  C.txtDefaultPayToDescription = widget.UI.TextBox("txtDefaultPayToDescription", {
    maxLength: 140,
  });
  C.cboDefaultPayToPurpose = widget.UI.ComboBox("cboDefaultPayToPurpose", {
    allowBlank: true,
    limitToList: false,
  });
  C.cboDefaultPayToAccountIdentifierType = widget.UI.ComboBox("cboDefaultPayToAccountIdentifierType", {
    allowBlank: true,
    limitToList: false,
  });
  C.cboDefaultPayToPaymentTermType = widget.UI.ComboBox("cboDefaultPayToPaymentTermType", {
    allowBlank: true,
    limitToList: false,
  });
  C.cboDefaultPayToPaymentTermFrequency = widget.UI.ComboBox("cboDefaultPayToPaymentTermFrequency", {
    allowBlank: true,
    limitToList: false,
  });

  //   Interest
  C.lblInterestCycle = widget.UI.Label("lblInterestCycle", {
    tooltipText: "Interest List: A comma separated list of default Interest cycles to suggest in the New Account Wizard\n\nLimit Interest cycle to List?: If checked the Interest cycle for a new Account must be an item in the 'Interest List'",
  });
  C.cboInterestCycle = widget.UI.DateCycleComboBox("cboInterestCycle", {
    allowBlank: false,
    isFrequency: true,
  });
  C.dateInterestCycleDateNext = widget.UI.DateBox("dateInterestCycleDateNext", {});
  C.txtInterestCycleList = widget.UI.TextBox("txtInterestCycleList", {
    blankTip: "Weekly,Fortnightly,Monthly,End of Month,Quarterly,Yearly",
    multiLine: true,
    rows: 4,
  });
  C.chkInterestCycleLimitToList = widget.UI.CheckBox("chkInterestCycleLimitToList", {
    caption: "Limit Interest cycle to List (for New Accounts)?",
    captionWrap: true,
  });
  
  C.lblStartupInterest = widget.UI.Label("lblStartupInterest", {});
  C.lstStartupInterestTypeAvailableList = widget.UI.CheckList("lstStartupInterestTypeAvailableList", {
    allowBlank: false,
    
    onChange: lstStartupInterestTypeAvailableList_Change,
  });
  C.cboStartupInterestType = widget.UI.ComboBox("cboStartupInterestType", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_15,
  });
  C.numStartupInterestRate = widget.UI.NumberBox("numStartupInterestRate", {
    decimals: 4,
    minValue: -10000,
    maxValue: 10000,
    percentage: true,    
  });
  C.cboStartupInterestRateTable = widget.UI.DBCombo("cboStartupInterestRateTable", {
    limitToList: true,
    showDescription: false,
    width: widget.UI.FIELD_WIDTH_CODE_10,
    
    onChange: cboStartupInterestRateTable_Change,
  });
  C.spanStartupInterestRatePremium = $("#spanStartupInterestRatePremium");
  C.numStartupInterestRatePremium = widget.UI.NumberBox("numStartupInterestRatePremium", {
    decimals: 4,
    minValue: -9999,
    maxValue: 9999,
    percentage: true,
  });
  C.cboStartupInterestPeriod = widget.UI.DateCycleComboBox("cboStartupInterestPeriod", {
    isFrequency: false,
    
    onChange: cboStartupInterestPeriod_Change,
  });
  C.spanStartupInterestToDate = $("#spanStartupInterestToDate");
  C.dateStartupInterestToDate = widget.UI.DateBox("dateStartupInterestToDate", {});
  C.txtStartupInterestPeriodList = widget.UI.TextBox("txtStartupInterestPeriodList", {
    blankTip: "To Date,1 Week,2 Weeks,4 Weeks,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years",
    multiLine: true,
    rows: 4,
  });
  C.chkStartupInterestPeriodLimitToList = widget.UI.CheckBox("chkStartupInterestPeriodLimitToList", {
    caption: "Limit Startup Interest period to List?",
    captionWrap: true,
  });
  C.cboStartupInterestPeriodMaximum = widget.UI.DateCycleComboBox("cboStartupInterestPeriodMaximum", {
    isFrequency: true,
  });
  
  C.lblInterest = widget.UI.Label("lblInterest", {});
  C.lstInterestTypeAvailableList = widget.UI.CheckList("lstInterestTypeAvailableList", {
    allowBlank: false,
    
    onChange: lstInterestTypeAvailableList_Change,
  });
  C.cboInterestType = widget.UI.ComboBox("cboInterestType", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_15,
  });
  C.numInterestRate = widget.UI.NumberBox("numInterestRate", {
    decimals: 4,
    minValue: -10000,
    maxValue: 10000,
    percentage: true,    
  });
  C.cboInterestRateTable = widget.UI.DBCombo("cboInterestRateTable", {
    limitToList: true,
    showDescription: false,
    width: widget.UI.FIELD_WIDTH_CODE_10,
    
    onChange: cboInterestRateTable_Change,
  });
  C.spanInterestRatePremium = $("#spanInterestRatePremium");
  C.numInterestRatePremium = widget.UI.NumberBox("numInterestRatePremium", {
    decimals: 4,
    minValue: -9999,
    maxValue: 9999,
    percentage: true,
  });
  
  C.lblOtherInterest = widget.UI.Label("lblOtherInterest", {});
  C.cboOtherInterestType = widget.UI.ComboBox("cboOtherInterestType", {
    limitToList: true,    
    
    onChange: cboOtherInterestType_Change,
  });
  C.numOtherInterestRate = widget.UI.NumberBox("numOtherInterestRate", {
    decimals: 4,
    minValue: 0,
    maxValue: 999999999999999,
    percentage: true,
  });
  C.txtOtherInterestDescription = widget.UI.TextBox("txtOtherInterestDescription", {
    maxLength: 20
  });

  //   Interest Options
  C.lblInterestCalculationOptions = widget.UI.Label("lblInterestCalculationOptions", {
    tooltipText: "Backdating: Select the relevant option to review Interest when Transactions and other changes are backdated into prior Interest periods\n\nInclude Converted Transactions?: Revise Interest back prior to converted Interest Transactions?",
  });
  C.cboOptionInterestAccruedMethod = widget.UI.ComboBox("cboOptionInterestAccruedMethod", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_15,
  });
  C.cboOptionInterestRoundMethod = widget.UI.ComboBox("cboOptionInterestRoundMethod", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_15,
  });
  C.cboOptionInterestBackdating = widget.UI.ComboBox("cboOptionInterestBackdating", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_15,
    
    onChange: cboOptionInterestBackdating_Change,
  });
  C.chkOptionInterestBackdatingConvertedTransactions = widget.UI.CheckBox("chkOptionInterestBackdatingConvertedTransactions", {
    caption: "Include converted Transactions?",
    captionWrap: true,
  });
  
  C.lblInterestOptions = widget.UI.Label("lblInterestOptions", {
    tooltipText: "Post Maturity: Basis applies after the Maturity Date or Final Payment Date from Payment Arrangement (if checked under Default Interest), whichever is later",
  });
  C.chkOptionInterestOnInterest = widget.UI.CheckBox("chkOptionInterestOnInterest", {
    caption: "Charge Interest on Interest (uncheck for Principal Only)?",
    captionWrap: true,    
  });
  C.chkOptionInterestPrecomputed = widget.UI.CheckBox("chkOptionInterestPrecomputed", {
    caption: "Use Precomputed Contractual Interest?",
    captionWrap: true,  
    
    onChange: chkOptionInterestPrecomputed_Change,
  });
  C.chkOptionInterestChargedUpfront = widget.UI.CheckBox("chkOptionInterestChargedUpfront", {
    caption: "Charge upfront?",
    captionWrap: true,  
    
    onChange: chkOptionInterestChargedUpfront_Change,
  });
  C.chkOptionInterestChargedOriginal = widget.UI.CheckBox("chkOptionInterestChargedOriginal", {
    caption: "Charge during Term?",
    captionWrap: true,  
    
    onChange: chkOptionInterestChargedOriginal_Change
  });
  C.chkOptionInterestFlatRate = widget.UI.CheckBox("chkOptionInterestFlatRate", {
    caption: "Calculate Interest using a Flat Rate basis?",
    captionWrap: true,  
  });
  C.cboOptionInterestPostMaturityBasis = widget.UI.ComboBox("cboOptionInterestPostMaturityBasis", {
    limitToList: true,
  });
  C.chkInterestNegativeRateAllow = widget.UI.CheckBox("chkInterestNegativeRateAllow", {
    caption: "Allow Negative Interest Rates?",
    captionWrap: true,  
    
    onChange: chkInterestNegativeRateAllow_Change,
  });
  C.chkInterestNegativeRateTaxNotApplicable = widget.UI.CheckBox("chkInterestNegativeRateTaxNotApplicable", {
    caption: "Set Withholding Tax to 'Not Applicable'?",
    captionWrap: true,  
  });
  C.chkTaxCertificateNotIssueAIL = widget.UI.CheckBox("chkTaxCertificateNotIssueAIL", {
    caption: "'Not Issue' Client Document Logs created for AIL Tax Certificates?",
    captionWrap: true,  
  });
  
  C.lblInterestNewAccountOptions = widget.UI.Label("lblInterestNewAccountOptions", {
    tooltipText: "Fix Interest Rate from Rate Table?: Is Interest calculated based upon the Opening Date and Investment Value from the Rate Table? When opened the Account is converted from 'Rate Table' to 'Fixed Rate'",
  });
  C.chkInterestCycleUpdateFromPaymentCycle = widget.UI.CheckBox("chkInterestCycleUpdateFromPaymentCycle", {
    caption: "Update Interest Cycle from Payment Cycle?",
    captionWrap: true,  
  });
  C.chkOptionInterestAlignFirst = widget.UI.CheckBox("chkOptionInterestAlignFirst", {
    caption: "Align first Interest date to first Payment date?",
    captionWrap: true,  
  });
  C.chkOptionInterestFixRateTable = widget.UI.CheckBox("chkOptionInterestFixRateTable", {
    caption: "Fix Interest Rate from Rate Table?",
    captionWrap: true,  
  });
  
  C.lblInterestInstructions = widget.UI.Label("lblInterestInstructions", {});
  C.cboInterestInstructionDown = widget.UI.ComboBox("cboInterestInstructionDown", {
    allowBlank: false,
    limitToList: true,
  });
  C.cboInterestInstructionUp = widget.UI.ComboBox("cboInterestInstructionUp", {
    allowBlank: false,
    limitToList: true,
  });
  
  C.lblFloatingInterestRateOptions = widget.UI.Label("lblFloatingInterestRateOptions", {});
  C.chkInterestEffectiveDateOrEarliestPaymentDate = widget.UI.CheckBox("chkInterestEffectiveDateOrEarliestPaymentDate", {
    caption: "Effective date 'Or earliest payment date' setting default.",
    captionWrap: true,  
  });
  C.cboInterestEarliestDateDefault = widget.UI.DateCycleComboBox("cboInterestEarliestDateDefault", {
    isFrequency: false,
  });
  
  C.lblComparisonRate = widget.UI.Label("lblComparisonRate", {});
  C.cboComparisonRateType = widget.UI.ComboBox("cboComparisonRateType", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_25,
  });
  C.numComparisonRateRoundingDecimals = widget.UI.NumberBox("numComparisonRateRoundingDecimals", {
    allowBlank: false,
    decimals: 0,
    minValue: 0,
    maxValue: 8,
  });
  C.numComparisonRateMaximum = widget.UI.NumberBox("numComparisonRateMaximum", {
    decimals: 4,
    minValue: 0,
    maxValue: 9999,
    percentage: true,
  });
  C.dateComparisonRateMaximumNextDate = widget.UI.DateBox("dateComparisonRateMaximumNextDate", {
    onChange: dateComparisonRateMaximumNextDate_Change,
  });
  C.numComparisonRateMaximumNext = widget.UI.NumberBox("numComparisonRateMaximumNext", {
    decimals: 4,
    minValue: 0,
    maxValue: 9999,
    percentage: true,
  });
  
  C.lblInterestPayment = widget.UI.Label("lblInterestPayment", {});
  C.lstInterestPaymentAvailableTypes = widget.UI.CheckList("lstInterestPaymentAvailableTypes", {
    allowBlank: false,
    
    onChange: lstInterestPaymentAvailableTypes_Change,
  });
  C.cboInterestPaymentType = widget.UI.ComboBox("cboInterestPaymentType", {
    limitToList: true,
  });
  C.chkInterestCommonClient = widget.UI.CheckBox("chkInterestCommonClient", {
    caption: "Transfer must include a common Client?",
    captionWrap: true,
  });
  C.chkInterestPaymentRollForward = widget.UI.CheckBox("chkInterestPaymentRollForward", {
    caption: "Roll Interest Payout Date forward if it falls on a non-Banking Day?",
    captionWrap: true,
  });
  C.chkInterestPaymentCompoundFinal = widget.UI.CheckBox("chkInterestPaymentCompoundFinal", {
    caption: "Compound Final Interest Payment?",
    captionWrap: true,
  });
  C.chkReinvestmentPreserveInterestPaymentType = widget.UI.CheckBox("chkReinvestmentPreserveInterestPaymentType", {
    caption: "Preserve Payment Type when Reinvesting from another Deposit?",
    captionWrap: true,
  });
  
  C.lblInvestmentIncomeReportingOptions = widget.UI.Label("lblInvestmentIncomeReportingOptions", {});
  C.chkInterestIsFromDividends = widget.UI.CheckBox("chkInterestIsFromDividends", {
    caption: "Interest is from Dividends?",
    captionWrap: true,
  });
  
  C.lblInterestOtherOptions = widget.UI.Label("lblInterestOtherOptions", {});
  C.chkShowZeroInterestTransactions = widget.UI.CheckBox("chkShowZeroInterestTransactions", {
    caption: "Show Zero value Interest Transactions?",
    captionWrap: true,
  });

  //   Rate Tables
  C.cboStandardRateTable = widget.UI.DBCombo("cboStandardRateTable", {
    formKeyOpen: "RateTables",
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_10,

    onChange: cboStandardRateTable_Change,
  });

  //   Overdue &amp; Defaults
  C.lblOverdueOptions = widget.UI.Label("lblOverdueOptions", {});
  C.chkOverdueLimitToBalance = widget.UI.CheckBox("chkOverdueLimitToBalance", {
    caption: "Limit the Overdue Balance (for Reporting) to the balance of the Account?",
    captionWrap: true,
  });
  C.chkContractualOverdueLimitToBalance = widget.UI.CheckBox("chkContractualOverdueLimitToBalance", {
    caption: "Limit the Contractual Overdue Balance (for Reporting) to the balance of the Account?",
    captionWrap: true,
  });
  
  C.lblOverdueSmallBalanceThresholds = widget.UI.Label("lblOverdueSmallBalanceThresholds", {
    tooltipText: "If the oldest Overdue Balance is less than the threshold then it is moved to the next oldest balance.",
  });
  C.numOverdueSmallBalanceThreshold = widget.UI.NumberBox("numOverdueSmallBalanceThreshold", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.numContractualOverdueSmallBalanceThreshold = widget.UI.NumberBox("numContractualOverdueSmallBalanceThreshold", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  
  C.lblDefaultInterest = widget.UI.Label("lblDefaultInterest", {
    tooltipText: "Threshold: If Contractual Overdue/ Overdue is less than this value treat as not overdue",
  });  
  C.cboDefaultInterestRateBasis = widget.UI.ComboBox("cboDefaultInterestRateBasis", {
    allowBlank: false,
    limitToList: true,
  });
  C.numDefaultInterestRate = widget.UI.NumberBox("numDefaultInterestRate", {
    decimals: 4,
    minValue: 0,
    maxValue: 10000,
    percentage: true,
  });
  
  C.chkDefaultInterestInDefault = widget.UI.CheckBox("chkDefaultInterestInDefault", {
    caption: "In Default?",
    captionWrap: true,
  });
  C.chkDefaultInterestPostMaturity = widget.UI.CheckBox("chkDefaultInterestPostMaturity", {
    caption: "Post Maturity?",
    captionWrap: true,
    
    onChange: chkDefaultInterestPostMaturity_Change,
  });
  C.chkDefaultInterestPostFinalDate = widget.UI.CheckBox("chkDefaultInterestPostFinalDate", {
    caption: "Or post final payment date from Payment Arrangement?",
    captionWrap: true,
  });
  
  C.cboDefaultInterestOverdueBasis = widget.UI.ComboBox("cboDefaultInterestOverdueBasis", {
    allowBlank: false,
    limitToList: true,
    
    onChange: cboDefaultInterestOverdueBasis_Change,
  });
  C.numDefaultInterestOverdueThreshold = widget.UI.NumberBox("numDefaultInterestOverdueThreshold", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.cboDefaultInterestOverdueChargeBasis = widget.UI.ComboBox("cboDefaultInterestOverdueChargeBasis", {
    allowBlank: false,
    limitToList: true,
    
    onChange: cboDefaultInterestOverdueChargeBasis_Change,
  });
  
  C.numDefaultInterestMinimumCharge = widget.UI.NumberBox("numDefaultInterestMinimumCharge", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  
  C.lblDefaultFee = widget.UI.Label("lblDefaultFee", {});
  C.cboDefaultFeeChargeBasis = widget.UI.ComboBox("cboDefaultFeeChargeBasis", {
    limitToList: true,
    
    onChange: cboDefaultFeeChargeBasis_Change,
  });
  C.numDefaultFeeValue = widget.UI.NumberBox("numDefaultFeeValue", {
    allowBlank: false,
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.chkDefaultFeeIgnoreLimit = widget.UI.CheckBox("chkDefaultFeeIgnoreLimit", {
    caption: "Ignore maximum Default Fee limit?",
    captionWrap: true,
  });
  
  C.lblFacilityFee = widget.UI.Label("lblFacilityFee", {});
  C.cboFacilityFeeChargeBasis = widget.UI.ComboBox("cboFacilityFeeChargeBasis", {
    limitToList: true,
    
    onChange: cboFacilityFeeChargeBasis_Change,
  });
  C.numFacilityFeeValue = widget.UI.NumberBox("numFacilityFeeValue", {
    allowBlank: false,
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.chkFacilityFeeChargeThresholdApply = widget.UI.CheckBox("chkFacilityFeeChargeThresholdApply", {
    caption: "Apply Minimum Balance threshold?",
    captionWrap: true,
  });
  C.numFacilityFeeChargeThresholdValue = widget.UI.NumberBox("numFacilityFeeChargeThresholdValue", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.chkFacilityFeeChargeIfMovement = widget.UI.CheckBox("chkFacilityFeeChargeIfMovement", {
    caption: "Or if Account has had movement in period?",
    captionWrap: true,
  });

  //   Credit Limit
  C.lblCreditLimits = widget.UI.Label("lblCreditLimits", {});
  C.cboCreditLimitCount = widget.UI.ComboBox("cboCreditLimitCount", {
    listCsv: "Not Used,1,2,3",
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_10,
    
    onChange: cboCreditLimitCount_Change,
  });
  C.chkCreditLimitKeepOnRefinance = widget.UI.CheckBox("chkCreditLimitKeepOnRefinance", {
    caption: "Keep Credit Limits when Refinancing?",
  });
  C.chkCreditLimitUsePendingWithdrawals = widget.UI.CheckBox("chkCreditLimitUsePendingWithdrawals", {
    caption: "Use Pending Withdrawals?",
  });
  C.chkCreditLimitUseUnclearedFunds = widget.UI.CheckBox("chkCreditLimitUseUnclearedFunds", {
    caption: "Use Uncleared Funds?",
  });
  C.chkCreditLimitUseOtherDeductions = widget.UI.CheckBox("chkCreditLimitUseOtherDeductions", {
    caption: "Use Other Deductions (requires scripting)?",
    
    onChange: chkCreditLimitUseOtherDeductions_Change,
  });
  C.txtCreditLimitOtherDeductionsDescription = widget.UI.TextBox("txtCreditLimitOtherDeductionsDescription", {
    maxLength: 50,
  });
  
  C.lblCreditLimit1 = widget.UI.Label("lblCreditLimit1", {});
  C.txtCreditLimit1Description = widget.UI.TextBox("txtCreditLimit1Description", {
    blankTip: "Credit Limit",
    maxLength: 50,
  });
  C.numCreditLimit1 = widget.UI.NumberBox("numCreditLimit1", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.chkCreditLimit1Required = widget.UI.CheckBox("chkCreditLimit1Required", {
    caption: "Required?",
  });
  
  C.lblCreditLimit2 = widget.UI.Label("lblCreditLimit2", {});
  C.txtCreditLimit2Description = widget.UI.TextBox("txtCreditLimit2Description", {
    blankTip: "Credit Limit 2",
    maxLength: 50,
  });
  C.numCreditLimit2 = widget.UI.NumberBox("numCreditLimit2", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.chkCreditLimit2Required = widget.UI.CheckBox("chkCreditLimit2Required", {
    caption: "Required?",
  });
  
  C.lblCreditLimit3 = widget.UI.Label("lblCreditLimit3", {});
  C.txtCreditLimit3Description = widget.UI.TextBox("txtCreditLimit3Description", {
    blankTip: "Credit Limit 3",
    maxLength: 50,
  });
  C.numCreditLimit3 = widget.UI.NumberBox("numCreditLimit3", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  C.chkCreditLimit3Required = widget.UI.CheckBox("chkCreditLimit3Required", {
    caption: "Required?",
  });

  C.lblOverLimitDefault = widget.UI.Label("lblOverLimitDefault", {});
  C.cboOverLimitBasis = widget.UI.ComboBox("cboOverLimitBasis", {
    limitToList: true,
    
    onChange: cboOverLimitBasis_Change,
  });
  C.numOverLimitThresholdPercent = widget.UI.NumberBox("numOverLimitThresholdPercent", {
    decimals: 4,
    percentage: true,
  });
  C.numOverLimitThreshold = widget.UI.NumberBox("numOverLimitThreshold", {
    minValue: 0,
    maxValue: 999999999999999,
  });
  
  C.lblOverLimitFee = widget.UI.Label("lblOverLimitFee", {});
  C.cboOverLimitFeeChargeBasis = widget.UI.ComboBox("cboOverLimitFeeChargeBasis", {
    limitToList: true,
    
    onChange: cboOverLimitFeeChargeBasis_Change,
  });
  C.numOverLimitFeeValue = widget.UI.NumberBox("numOverLimitFeeValue", {
    allowBlank: false,
    minValue: 0,
    maxValue: 999999999999999,
  });

  //   Close Options
  C.lblClosedPending = widget.UI.Label("lblClosedPending", {});
  C.chkClosedPendingDefault = widget.UI.CheckBox("chkClosedPendingDefault", {
    caption: "Default 'Closed Pending' status?",
    captionWrap: true,
  });
  C.numClosedPendingReviewDays = widget.UI.NumberBox("numClosedPendingReviewDays", {
    decimals: 0,
    minValue: 0,
    maxValue: 100,
  });
  C.chkClosedPendingAutoClose = widget.UI.CheckBox("chkClosedPendingAutoClose", {
    caption: "Complete Close during Account Processes, if Review date passed?",
    captionWrap: true,
  });
  
  C.lblLossCalculationClosing = widget.UI.Label("lblLossCalculationClosing", {});
  C.cboCloseLossFormula = widget.UI.ComboBox("cboCloseLossFormula", {
    limitToList: true,
  });
  
  C.lblLossCalculationRefinancing = widget.UI.Label("lblLossCalculationRefinancing", {});
  C.cboRefinanceLossFormula = widget.UI.ComboBox("cboRefinanceLossFormula", {
    limitToList: true,
  });
  
  C.lblSmallBalanceWriteOff = widget.UI.Label("lblSmallBalanceWriteOff", {
    tooltipText: "Balances below these values will be included in the Automatic Close wizard. Enter all values as positive numbers.",
  });
  C.numSmallBalanceWriteOffDebit = widget.UI.NumberBox("numSmallBalanceWriteOffDebit", {
    minValue: 0,
    maxValue: 999999999,
  });
  C.numSmallBalanceWriteOffCredit = widget.UI.NumberBox("numSmallBalanceWriteOffCredit", {
    minValue: 0,
    maxValue: 999999999,
  });
  C.numSmallBalanceRefundCredit = widget.UI.NumberBox("numSmallBalanceRefundCredit", {
    minValue: 0,
    maxValue: 999999999,
  });
  
  C.lblCloseOptions = widget.UI.Label("lblCloseOptions", {});
  C.chkOptionAutomaticClose = widget.UI.CheckBox("chkOptionAutomaticClose", {
    caption: "Automatically close Accounts in Account Processes?",
    captionWrap: true,
    
    onChange: chkOptionAutomaticClose_Change,
  });
  C.chkOptionAutomaticClosePreMaturity = widget.UI.CheckBox("chkOptionAutomaticClosePreMaturity", {
    caption: "Close Accounts Pre-Maturity?",
    captionWrap: true,
  });
  C.chkOptionArchiveDeclinedUnwanted = widget.UI.CheckBox("chkOptionArchiveDeclinedUnwanted", {
    caption: "Immediately archive Declined/ Unwanted Quote Accounts?",
    captionWrap: true,
  });
  C.chkOptionAllowStatusClosedToOpen = widget.UI.CheckBox("chkOptionAllowStatusClosedToOpen", {
    caption: "Allow closed Accounts to be reopened?",
    captionWrap: true,
  });

  //   Other
  C.lblStatementOptions = widget.UI.Label("lblStatementOptions", {});
  C.chkStatementUse = widget.UI.CheckBox("chkStatementUse", {
    caption: "Use Statements?",
    captionWrap: true,
    
    onChange: chkStatementUse_Change,
  });
  C.cboStatementCycle = widget.UI.DateCycleComboBox("cboStatementCycle", {
    allowBlank: false,
    isFrequency: true,
    
    onChange: cboStatementCycle_Change,
  })
  C.dateStatementDateNext = widget.UI.DateBox("dateStatementDateNext", {});
  
  C.lblParameterSetUserDefined = widget.UI.Label("lblParameterSetUserDefined", {
    tooltipText: "Used to enter User Defined Data in the Account form and New Account wizard.",
  });
  C.cboParameterSetUserDefined = widget.UI.DBCombo("cboParameterSetUserDefined", {
    limitToList: true,
  });
  
  C.lblDebtRatioThreshold = widget.UI.Label("lblDebtRatioThreshold", {});
  C.numDebtRatioThreshold = widget.UI.NumberBox("numDebtRatioThreshold", {
    allowBlank: false,
    minValue: 0,
    maxValue: 100,
    percentage: true,
  });
  
  C.lblClientStatisticDataSource = widget.UI.Label("lblClientStatisticDataSource", {});
  C.cboClientStatisticSourceExtraAsset = widget.UI.ComboBox("cboClientStatisticSourceExtraAsset", {
    allowBlank: false,
    limitToList: true,
  });
  C.cboClientStatisticSourceExtraLiability = widget.UI.ComboBox("cboClientStatisticSourceExtraLiability", {
    allowBlank: false,
    limitToList: true,
  });
  C.cboClientStatisticSourceConsolidatedLiability = widget.UI.ComboBox("cboClientStatisticSourceConsolidatedLiability", {
    allowBlank: false,
    limitToList: true,
  });
  C.cboClientStatisticSourceConsolidatedExpense = widget.UI.ComboBox("cboClientStatisticSourceConsolidatedExpense", {
    allowBlank: false,
    limitToList: true,
  });
  
  C.lblOtherOptions = widget.UI.Label("lblOtherOptions", {});
  C.chkIncludeAccountLevelInsurance = widget.UI.CheckBox("chkIncludeAccountLevelInsurance", {
    caption: "Include Account level Insurance details?",
    captionWrap: true,
  });
  C.chkOptionAllowWithdrawals = widget.UI.CheckBox("chkOptionAllowWithdrawals", {
    caption: "Allow Withdrawals (including Transfers)?",
    captionWrap: true,
    
    onChange: chkOptionAllowWithdrawals_Change,
  });
  C.chkDepositAllowWithdrawalsNegativeBalance = widget.UI.CheckBox("chkDepositAllowWithdrawalsNegativeBalance", {
    caption: "Allow Withdrawals (including Transfers) to place Account into a negative Balance?",
    captionWrap: true,
  });
  C.chkTransferCommonClient = widget.UI.CheckBox("chkTransferCommonClient", {
    caption: "Transfers must include a common Client?",
    captionWrap: true,
  });
  C.chkOptionAllowRestructure = widget.UI.CheckBox("chkOptionAllowRestructure", {
    caption: "Allow Restructure?",
    captionWrap: true,
  });
  C.chkOptionAllowRefinanceInto = widget.UI.CheckBox("chkOptionAllowRefinanceInto", {
    caption: "Allow Refinance Into?",
    captionWrap: true,
    
    onChange: chkOptionAllowRefinanceInto_Change,
  });
  C.chkOptionAllowRefinanceRedatedForward = widget.UI.CheckBox("chkOptionAllowRefinanceRedatedForward", {
    caption: "Allow Refinance to be re-dated forward?",
    captionWrap: true,
  });
  C.chkUserFlagA = widget.UI.CheckBox("chkUserFlagA", {
    caption: "User Flag A",
    captionWrap: true,
  });
  C.chkUserFlagB = widget.UI.CheckBox("chkUserFlagB", {
    caption: "User Flag B",
    captionWrap: true,
  });
  
  C.lblSummaryPageOptions = widget.UI.Label("lblSummaryPageOptions", {});
  C.chkShowAccountIdWithCheckDigit = widget.UI.CheckBox("chkShowAccountIdWithCheckDigit", {
    caption: "Show Account Id with check digit?",
    captionWrap: true,
  });
  C.chkShowHistoryRating = widget.UI.CheckBox("chkShowHistoryRating", {
    caption: "Show History Rating information?",
    captionWrap: true,
  });
  C.chkShowTotalAdvances = widget.UI.CheckBox("chkShowTotalAdvances", {
    caption: "Show Total Advances?",
    captionWrap: true,
  });
  C.chkShowOverdue = widget.UI.CheckBox("chkShowOverdue", {
    caption: "Show Overdue?",
    captionWrap: true,
  });
  C.chkShowContractualOverdue = widget.UI.CheckBox("chkShowContractualOverdue", {
    caption: "Show Contractual Overdue?",
    captionWrap: true,
  });

  //   Promotions
  C.lblPromotionOptions = widget.UI.Label("lblPromotionOptions", {
    tooltipText: "Parameter Set is used to enter User Defined Data in the Account Type Promotion form.",
  });
  C.cboPromotionBasis = widget.UI.ComboBox("cboPromotionBasis", {
    allowBlank: false,
    limitToList: true,    
    width: "18em",
    
    onChange: cboPromotionBasis_Change,
  });
  C.cboPromotionParameterSetUserDefined = widget.UI.DBCombo("cboPromotionParameterSetUserDefined", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  
  C.lblPromotions = widget.UI.Label("lblPromotions", {});
  C.trPromotionMessage = $("#trPromotionMessage");

  //   Transactions
  C.lblNetAdvanceLimits = widget.UI.Label("lblNetAdvanceLimits", {});
  C.numNetAdvanceMinimum = widget.UI.NumberBox("numNetAdvanceMinimum", {
    blankIfZero: true,
    minValue: 0,
    maxValue: 999999999,
  });
  C.numNetAdvanceMaximum = widget.UI.NumberBox("numNetAdvanceMaximum", {
    blankIfZero: true,
    minValue: 0,
    maxValue: 999999999,
  });
  
  C.lblTransactionOptions = widget.UI.Label("lblTransactionOptions", {
    tooltipText: "This checkbox is used by High Cost loans only.",
  });
  C.chkOptionCreateAdjustedToZeroTransactions = widget.UI.CheckBox("chkOptionCreateAdjustedToZeroTransactions", {
    caption: "Create adjusted to Zero Transactions?",
    captionWrap: true,    
  });
  C.lblTransactions = widget.UI.Label("lblTransactions", {});

  //   Accounting
  C.cboControlGlAccount = widget.UI.DBCombo("cboControlGlAccount", {
    formKeyOpen: "GLAccounts",
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });
  C.cboClearingGlAccount = widget.UI.DBCombo("cboClearingGlAccount", {
    formKeyOpen: "GLAccounts",
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });

  //   User Defined
  C.phUserDefined = widget.UI.ParametersHost("phUserDefined", {});

  // Grids
  C.gridRateTables = widget.UI.Grid("gridRateTables", {
    groupByColumns: "Category",
    allowGroupingsCollapse: false,
    docked: true,
    stickyHeader: true,

    onBeforeCellUpdate: gridRateTables_BeforeCellUpdate,
    onInitialiseRow: gridRateTables_InitialiseRow,
    onRowDrilldown: gridRateTables_RowDrilldown,
  });

  C.gridDocumentLinks = widget.UI.Grid("gridDocumentLinks", {
    docked: true,
    showRowSelectors: true,
    stickyHeader: true,

    onAfterRowActivate: gridDocumentLinks_AfterRowActivate,
    onBeforeCellUpdate: gridDocumentLinks_BeforeCellUpdate,
    onInitialiseRow: gridDocumentLinks_InitialiseRow,
  });

  C.gridDocuments = widget.UI.Grid("gridDocuments", {
    groupByColumns: "Category",
    allowMultiRowSelect: true,
    allowGroupingsCollapse: false,
    docked: true,
    stickyHeader: true,

    onAction: gridDocuments_Action,
    onAfterRowActivate: gridDocuments_AfterRowActivate,
    onBeforeCellUpdate: gridDocuments_BeforeCellUpdate,
    onInitialiseRow: gridDocuments_InitialiseRow,
    onRowDrilldown: gridDocuments_RowDrilldown,
  });
  C.gridElementLinks = widget.UI.Grid("gridElementLinks", {
    groupByColumns: "Category",
    allowGroupingsCollapse: false,
    docked: true,
    showRowSelectors: true,
    stickyHeader: true,

    onAfterRowActivate: gridElementLinks_AfterRowActivate,
    onBeforeCellUpdate: gridElementLinks_BeforeCellUpdate,
    onInitialiseRow: gridElementLinks_InitialiseRow,
    onRowDrilldown: gridElementLinks_RowDrilldown,
  });  
  C.gridScriptLinks = widget.UI.Grid("gridScriptLinks", {
    docked: true,
    groupByColumns: "Category",
    showRowSelectors: true,
    stickyHeader: true,

    onAfterRowActivate: gridScriptLinks_AfterRowActivate,
    onBeforeCellUpdate: gridScriptLinks_BeforeCellUpdate,
    onInitialiseRow: gridScriptLinks_InitialiseRow,
  });
  // Create Widget form
  // NOTE: Hide by default for a cleaner startup
  frmMain = new widget.UI.Form("frmMain", { visible: false });

  // Create Tabs
  tabDetails = new widget.UI.Tabs("tabDetails", {
    style: "normal",
    onSelectedTabChanged: tabDetails_Refresh,
  });

  // Handle resize
  $(window).resize(Form_Resize);

  // Disable Close Button (this causes the 'FormClose' notification action to be invoked instead)
  widget.DisableCloseButton();
  widget.ActionNotificationHandle(Widget_NotificationHandler)

  // Handle Wizard Buttons
  cmdCancel = $("#cmdCancel");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabDetails_Cancel);
  cmdFinish.click(Form_ExecuteAction_Finish);

  // Reset
  Form_Reset();
});

// ==========
// Reset Form
// ==========
function Form_Reset() {
  // Resize
  Form_Resize();

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

// ===========
// Load Record
// ===========
function Record_Load() {
  // Initialise
  mRecord = null;
  mRecord_DocumentLinks = null;
  mRecord_Documents = null;
  mRecord_ElementLinks = null;
  mRecord_RateTables = null;
  mRecord_ScriptLinks = null;

  mRecord_AccountClassData = null;
  mRecord_ProductTypeData = null;

  // Hide content
  frmMain.Visible(false);

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

  // Load Initialisation details
  widget.GetString("GetInitialisationInfo", {},
    // Success
    Record_Load_Done,

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

function Record_Load_Done(data) {
  // Initialise
  mRecord = JSON.parse(data);
  mRecord_Documents = mRecord.DocumentsAvailable; // Named with 'Available' suffix to avoid clash with Documents Global Collection
  mRecord_RateTables = mRecord.RateTables;
  mRecord_ScriptLinks = mRecord.AccountTypeScriptLinks;

  // Global Collections
  mDocuments = mRecord.Documents;
  mElements = mRecord.Elements;
  mScripts = mRecord.Scripts;

  // Give Collections ability To lookup by code
  widget.ArrayAllowLookupById(mDocuments, "DocumentId");
  widget.ArrayAllowLookupById(mElements, "ElementId");
  widget.ArrayAllowLookupById(mScripts, "ScriptId");

  // Set Tab
  if (mRecord &amp;&amp; mRecord.PageId) {
    tabDetails.SelectedTabId(mRecord.PageId);

    // Hide other Pages
    if (mRecord.HideOtherPages) {
      tabDetails.ShowSingleTab(mRecord.PageId);
    }
  }
  else {
    tabDetails.SelectedTabId("General");
  }

  // Page Permissions
  // NOTE: Some pages will also be hidden based on Account Class
  if (!mRecord.AllowPageGeneral) tabDetails.TabVisible("General", false);
  if (!mRecord.AllowPageNewAccounts) tabDetails.TabVisible("NewAccounts", false);
  if (!mRecord.AllowPageTerm) tabDetails.TabVisible("Term", false);
  if (!mRecord.AllowPagePayments) tabDetails.TabVisible("Payments", false);
  if (!mRecord.AllowPageInterest) tabDetails.TabVisible("Interest", false);
  if (!mRecord.AllowPageInterestOptions) tabDetails.TabVisible("InterestOptions", false);
  if (!mRecord.AllowPageRateTables) tabDetails.TabVisible("RateTables", false);
  if (!mRecord.AllowPageDefaults) tabDetails.TabVisible("Defaults", false);
  if (!mRecord.AllowPageCreditLimit) tabDetails.TabVisible("CreditLimit", false);
  if (!mRecord.AllowPageCloseOptions) tabDetails.TabVisible("CloseOptions", false);
  if (!mRecord.AllowPageOther) tabDetails.TabVisible("Other", false);
  if (!mRecord.AllowPagePromotions) tabDetails.TabVisible("Promotions", false);
  if (!mRecord.AllowPageTransactions) tabDetails.TabVisible("Transactions", false);
  if (!mRecord.AllowPageDocuments) tabDetails.TabVisible("Documents", false);
  if (!mRecord.AllowPageRules) tabDetails.TabVisible("Rules", false);
  if (!mRecord.AllowPageAccounting) tabDetails.TabVisible("Accounting", false);
  if (!mRecord.AllowPageScripts) tabDetails.TabVisible("Scripts", false);
  if (!mRecord.AllowPageUserDefined) tabDetails.TabVisible("UserDefined", false);

  // Load Fields
  Fields_Load();

  // *** Moved to AccountClass_PagesRefresh to prevent asynchronous issues ***
  // Save Fields (so UserData is in correct format for mOriginalJson)
  //Fields_Save();

  // Save original JSON for Form_IsDirty
  //mOriginalJson = JSON.stringify(mRecord);
}

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // General
    C.txtAccountTypeId.Text(mRecord.AccountTypeId);
    C.chkActive.Value(mRecord.Active);
    C.txtDescription.Text(mRecord.Description);

    C.cboAccountClass.Text(mRecord.AccountClassText);
    C.cboProductType.Text(mRecord.ProductTypeId);
    C.cboCreditType.Text(mRecord.CreditTypeText);
    C.cboConsumerRegulationType.Text(mRecord.ConsumerRegulationTypeText);

    C.chkCreditSale.Value(mRecord.CreditSale);
    C.chkLaybySale.Value(mRecord.LaybySale);

    C.cboCreditReportingAccountType.Text(mRecord.CreditReportingAccountType);
    C.cboCategory.Text(mRecord.Category);
    C.cboIcon.Text(mRecord.Icon);

    C.txtNotes.Text(mRecord.Notes);

    // New Accounts
    C.txtNextAccountId.Text(mRecord.NextAccountId);
    C.txtDefaultDescription.Text(mRecord.DefaultDescription);
    C.cboDefaultLedger.Text(mRecord.DefaultLedger);

    C.chkOptionAllowLedger.Value(mRecord.OptionAllowLedger);
    C.chkOptionAllowFirstPaymentDate.Value(mRecord.OptionAllowFirstPaymentDate);
    C.chkOptionAllowRegularPayment.Value(mRecord.OptionAllowRegularPayment);
    C.chkOptionAllowBalloonPayment.Value(mRecord.OptionAllowBalloonPayment);
    C.chkOptionAllowResidualValue.Value(mRecord.OptionAllowResidualValue);
    C.chkOptionAllowMaturityDate.Value(mRecord.OptionAllowMaturityDate);
    C.chkOptionAllowMaturityInstruction.Value(mRecord.OptionAllowMaturityInstruction);
    C.chkOptionAllowMinimumPayment.Value(mRecord.OptionAllowMinimumPayment);
    C.chkOptionAllowMinimumPaymentDueDays.Value(mRecord.OptionAllowMinimumPaymentDueDays);
    C.chkOptionAllowMinimumPaymentHoldTo.Value(mRecord.OptionAllowMinimumPaymentHoldTo);
    C.chkOptionAllowTaxCategory.Value(mRecord.OptionAllowTaxCategory);
    C.chkOptionAllowInterestCycle.Value(mRecord.OptionAllowInterestCycle);
    C.chkOptionAllowInterest.Value(mRecord.OptionAllowInterest);
    C.chkOptionAllowStartupInterest.Value(mRecord.OptionAllowStartupInterest);
    C.chkOptionAllowTotalInterest.Value(mRecord.OptionAllowTotalInterest);
    C.chkOptionAllowReviewDate.Value(mRecord.OptionAllowReviewDate);
    C.cboDefaultReviewPeriod.Text(mRecord.DefaultReviewPeriod);

    C.chkShowFinancialPageOverridingPaymentsTab.Value(mRecord.OptionShowFinancialPageOverridingPaymentsTab);
    C.chkShowFinancialPageOptionsTab.Value(mRecord.OptionShowFinancialPageOptionsTab);
    C.chkShowInstalmentsDrilldown.Value(mRecord.OptionShowInstalmentsDrilldown);
    C.chkShowInstalmentsDrilldownWeb.Value(mRecord.OptionShowInstalmentsDrilldownWeb);
    C.chkShowFinancialPagePrintQuotation.Value(mRecord.OptionShowFinancialPagePrintQuotation);

    C.chkUserDefinedShowInNewAccountWizard.Value(mRecord.UserDefinedShowInNewAccountWizard);
    C.chkDisbursementsShowInNewAccountWizard.Value(mRecord.DisbursementsShowInNewAccountWizard);

    C.chkOptionDefaultQuoteStatus.Value(mRecord.OptionDefaultQuoteStatus);
    C.chkOptionDefaultResidualValueFromNetAdvance.Value(mRecord.OptionDefaultResidualValueFromNetAdvance);
    C.chkOptionDefaultResidualValueFromSecurities.Value(mRecord.OptionDefaultResidualValueFromSecurities);
    C.chkOptionDefaultPrintContractDocument.Value(mRecord.OptionDefaultPrintContractDocument);

    C.chkShowWarningInfos.Value(mRecord.ShowWarningInfos);
    C.chkShowWarningAlerts.Value(mRecord.ShowWarningAlerts);

    // Term
    C.cboTermEntryMethod.Text(mRecord.TermEntryMethodText);

    C.chkTermUse.Value(mRecord.TermUse);
    C.chkTermMandatory.Value(mRecord.TermMandatory);

    C.chkTermOnCall.Value(mRecord.TermOnCall);

    C.cboTerm.Text(mRecord.Term);
    C.dateTermOnDate.Value(mRecord.TermOnDate);
    C.txtTermList.Text(mRecord.TermList);
    C.chkTermLimitToList.Value(mRecord.TermLimitToList);

    C.numTermNumberOfPayments.Value(mRecord.TermNumberOfPayments);

    C.cboTermMinimum.Text(mRecord.TermMinimum);
    C.cboTermMaximum.Text(mRecord.TermMaximum);

    C.chkOptionAllowPayArrangeExtendTerm.Value(mRecord.OptionAllowPayArrangeExtendTerm);
    C.chkTermRollForward.Value(mRecord.TermRollForward);
    C.numMaturityGraceDays.Value(mRecord.MaturityGraceDays);
    C.chkTermCalculateSchedulePastMaturityDate.Value(mRecord.TermCalculateSchedulePastMaturityDate);

    C.lstMaturityInstructionAvailableList.Text(mRecord.MaturityAvailableInstructionsText);
    C.cboMaturityInstruction.Text(mRecord.MaturityInstructionText);

    C.cboMaturityAccountType.Text(mRecord.MaturityAccountTypeId);
    C.txtMaturityAccountTypesNew.Text(mRecord.MaturityAccountTypesNew);
    C.chkMaturityReinvestmentCommonClient.Value(mRecord.MaturityReinvestmentCommonClient);

    C.lstMaturityPaymentAvailableTypes.Text(mRecord.MaturityPaymentAvailableTypesText);
    C.cboMaturityPaymentType.Text(mRecord.MaturityPaymentTypeText);
    C.txtMaturityAccountTypesTransfer.Text(mRecord.MaturityAccountTypesTransfer);
    C.chkMaturityTransferCommonClient.Value(mRecord.MaturityTransferCommonClient);

    // Payments
    C.cboPaymentCycle.Text(mRecord.PaymentCycle);
    C.txtPaymentCycleList.Text(mRecord.PaymentCycleList);
    C.chkPaymentCycleLimitToList.Value(mRecord.PaymentCycleLimitToList);
    
    C.cboPaymentFirstPeriod.Text(mRecord.PaymentFirstPeriod);
    C.datePaymentFirstDate.Value(mRecord.PaymentFirstDate);
    C.txtPaymentFirstPeriodList.Text(mRecord.PaymentFirstPeriodList);
    C.chkPaymentFirstPeriodLimitToList.Value(mRecord.PaymentFirstPeriodLimitToList);
    C.cboPaymentFirstPeriodMaximum.Text(mRecord.PaymentFirstPeriodMaximum);
    
    C.cboMinimumPaymentBasis.Text(mRecord.MinimumPaymentBasis);
    C.numMinimumPaymentValue.Value(mRecord.MinimumPaymentValue);
    C.numMinimumPaymentPercent.Value(mRecord.MinimumPaymentPercent);
    C.numMinimumPaymentDueDays.Value(mRecord.MinimumPaymentDueDays);
    C.chkMinimumPaymentMoveToNextBusinessDay.Value(mRecord.MinimumPaymentMoveToNextBusinessDay);
    C.chkMinimumPaymentCarryForwardPrepaid.Value(mRecord.MinimumPaymentCarryForwardPrepaid);
    
    C.cboMinimumPaymentHoldToPeriod.Text(mRecord.MinimumPaymentHoldToPeriod);
    C.dateMinimumPaymentHoldToDate.Value(mRecord.MinimumPaymentHoldToDate);
    C.txtMinimumPaymentHoldToList.Text(mRecord.MinimumPaymentHoldToList);
    C.chkMinimumPaymentHoldToLimitToList.Value(mRecord.MinimumPaymentHoldToLimitToList);
    C.cboMinimumPaymentHoldToMaximum.Text(mRecord.MinimumPaymentHoldToMaximum);

    C.cboOptionPaymentAllocationMethod.Text(mRecord.OptionPaymentAllocationMethod);
    C.chkOptionPaymentsInAdvance.Value(mRecord.OptionPaymentsInAdvance);
    C.chkOptionPaymentsRound.Value(mRecord.OptionPaymentsRound);
    C.numOptionPaymentsRoundMultiple.Value(mRecord.OptionPaymentsRoundMultiple);
    C.chkOptionPaymentsFinalPlusBalloon.Value(mRecord.OptionPaymentsFinalPlusBalloon);
    C.chkOptionPaymentsAdjustFinalBeforeBalloon.Value(mRecord.OptionPaymentsAdjustFinalBeforeBalloon);
    C.chkOptionNextPaymentIncludesMinimumPayments.Value(mRecord.OptionNextPaymentIncludesMinimumPayments);
    C.chkOptionAllowCreditBalancePreMaturity.Value(mRecord.OptionAllowCreditBalancePreMaturity);
    C.chkPaymentEarlyPartialRepaymentWarning.Value(mRecord.PaymentEarlyPartialRepaymentWarning);
    C.chkPaymentArrangementDefaultPrintAdvice.Value(mRecord.PaymentArrangementDefaultPrintAdvice);
    
    C.chkOptionPaymentDirectDebitDateOpened.Value(mRecord.OptionPaymentDirectDebitDateOpened);
    C.chkOptionPaymentDirectDebitBalloon.Value(mRecord.OptionPaymentDirectDebitBalloon);
    C.chkPaymentDirectDebitLimitToBalance.Value(mRecord.PaymentDirectDebitLimitToBalance);
    C.numPaymentDirectDebitMinimumThreshold.Value(mRecord.PaymentDirectDebitMinimumThreshold);
    
    if (mRecord.NegativePaymentMatchDays == -1) {
      C.chkNegativePaymentMatch.Value(false);
      C.numNegativePaymentMatchDays.Value(0);
    }
    else {
      C.chkNegativePaymentMatch.Value(true);
      C.numNegativePaymentMatchDays.Value(mRecord.NegativePaymentMatchDays);
    }        
    
    C.chkPaymentGracePeriodUse.Value(mRecord.PaymentGracePeriodUse);
    C.numPaymentGracePeriodDays.Value(mRecord.PaymentGracePeriodDays);
    C.chkPaymentGracePeriodChargeDefault.Value(mRecord.PaymentGracePeriodChargeDefault);
    
    C.txtBankReferenceCode.Text(mRecord.BankReferenceCode);

    C.txtDefaultPayToDescription.Text(mRecord.PayToDescription);
    C.cboDefaultPayToPurpose.Text(mRecord.PayToPurpose);
    C.cboDefaultPayToAccountIdentifierType.Text(mRecord.PayToAccountIdentifierType);
    C.cboDefaultPayToPaymentTermType.Text(mRecord.PayToPaymentTermType);
    C.cboDefaultPayToPaymentTermFrequency.Text(mRecord.PayToPaymentTermFrequency);


    // Interest
    C.cboInterestCycle.Text(mRecord.InterestCycle);
    C.dateInterestCycleDateNext.Value(mRecord.InterestCycleDateNext);
    C.txtInterestCycleList.Text(mRecord.InterestCycleList);
    C.chkInterestCycleLimitToList.Value(mRecord.InterestCycleLimitToList);
    
    C.lstStartupInterestTypeAvailableList.Text(mRecord.StartupInterestAvailableTypes);
    C.cboStartupInterestType.Text(mRecord.StartupInterestType);
    C.numStartupInterestRate.Value(mRecord.StartupInterestRate);
    C.cboStartupInterestRateTable.Text(mRecord.StartupInterestRateTableId);
    C.numStartupInterestRatePremium.Value(mRecord.StartupInterestRateTablePremium);
    C.cboStartupInterestPeriod.Text(mRecord.StartupInterestPeriod);
    C.dateStartupInterestToDate.Value(mRecord.StartupInterestToDate);
    C.txtStartupInterestPeriodList.Text(mRecord.StartupInterestPeriodList);
    C.chkStartupInterestPeriodLimitToList.Value(mRecord.StartupInterestPeriodLimitToList);
    C.cboStartupInterestPeriodMaximum.Text(mRecord.StartupInterestPeriodMaximum);
    
    C.lstInterestTypeAvailableList.Text(mRecord.InterestAvailableTypes);
    C.cboInterestType.Text(mRecord.InterestType);
    C.numInterestRate.Value(mRecord.InterestRate);
    C.cboInterestRateTable.Text(mRecord.InterestRateTableId);
    C.numInterestRatePremium.Value(mRecord.InterestRateTablePremium);
    
    C.cboOtherInterestType.Text(mRecord.OtherInterestType);
    C.numOtherInterestRate.Value(mRecord.OtherInterestRate);
    C.txtOtherInterestDescription.Text(mRecord.OtherInterestDescription);

    // Interest Options
    C.cboOptionInterestAccruedMethod.Text(mRecord.OptionInterestAccruedMethod);
    C.cboOptionInterestRoundMethod.Text(mRecord.OptionInterestRoundMethod);
    C.cboOptionInterestBackdating.Text(mRecord.OptionInterestBackdating);
    C.chkOptionInterestBackdatingConvertedTransactions.Value(mRecord.OptionInterestBackdatingConvertedTransactions);

    C.chkOptionInterestOnInterest.Value(mRecord.OptionInterestOnInterest);
    C.chkOptionInterestPrecomputed.Value(mRecord.OptionInterestPrecomputed);
    C.chkOptionInterestChargedUpfront.Value(mRecord.OptionInterestChargeUpfront);
    C.chkOptionInterestChargedOriginal.Value(mRecord.OptionInterestChargeOriginal);
    C.chkOptionInterestFlatRate.Value(mRecord.OptionInterestFlatRate);
    C.cboOptionInterestPostMaturityBasis.Text(mRecord.OptionInterestPostMaturityBasis);
    C.chkInterestNegativeRateAllow.Value(mRecord.InterestNegativeRateAllow);
    C.chkInterestNegativeRateTaxNotApplicable.Value(mRecord.InterestNegativeRateTaxNotApplicable);
    C.chkTaxCertificateNotIssueAIL.Value(mRecord.TaxCertificateNotIssueAIL);
    
    C.chkInterestCycleUpdateFromPaymentCycle.Value(mRecord.InterestCycleUpdateFromPaymentCycle);
    C.chkOptionInterestAlignFirst.Value(mRecord.OptionInterestAlignFirst);
    C.chkOptionInterestFixRateTable.Value(mRecord.OptionInterestFixRateTable);
    
    C.cboInterestInstructionDown.Text(mRecord.InterestInstructionDown);
    C.cboInterestInstructionUp.Text(mRecord.InterestInstructionUp);
    
    C.chkInterestEffectiveDateOrEarliestPaymentDate.Value(mRecord.InterestEffectiveDateOrEarliestPaymentDate);
    C.cboInterestEarliestDateDefault.Text(mRecord.InterestEarliestDateDefault);
    
    C.cboComparisonRateType.Text(mRecord.ComparisonRateType);
    C.numComparisonRateRoundingDecimals.Value(mRecord.ComparisonRateRoundingDecimals);
    C.numComparisonRateMaximum.Value(mRecord.ComparisonRateMaximum);
    C.dateComparisonRateMaximumNextDate.Value(mRecord.ComparisonRateMaximumNextDate);
    C.numComparisonRateMaximumNext.Value(mRecord.ComparisonRateMaximumNext);
    
    C.lstInterestPaymentAvailableTypes.Text(mRecord.InterestPaymentAvailableTypes);
    C.cboInterestPaymentType.Text(mRecord.InterestPaymentType);
    C.chkInterestCommonClient.Value(mRecord.InterestCommonClient);
    C.chkInterestPaymentRollForward.Value(mRecord.InterestPaymentRollForward);
    C.chkInterestPaymentCompoundFinal.Value(mRecord.InterestPaymentCompoundFinal);
    C.chkReinvestmentPreserveInterestPaymentType.Value(mRecord.ReinvestmentPreserveInterestPaymentType);
    
    C.chkInterestIsFromDividends.Value(mRecord.InterestIsFromDividends);
    
    C.chkShowZeroInterestTransactions.Value(mRecord.ShowZeroInterestTransactions);

    // Rate Tables
    C.cboStandardRateTable.Text(mRecord.StandardRateTableId);
    if (mRecord_RateTables) gridRateTables_Refresh();

    // Overdue &amp; Defaults
    C.chkOverdueLimitToBalance.Value(mRecord.OverdueLimitToBalance);
    C.chkContractualOverdueLimitToBalance.Value(mRecord.ContractualOverdueLimitToBalance);
    
    C.numOverdueSmallBalanceThreshold.Value(mRecord.OverdueSmallBalanceThreshold);
    C.numContractualOverdueSmallBalanceThreshold.Value(mRecord.ContractualOverdueSmallBalanceThreshold);
    
    C.cboDefaultInterestRateBasis.Text(mRecord.DefaultInterestRateBasis);
    C.numDefaultInterestRate.Value(mRecord.DefaultInterestRate);
    
    C.chkDefaultInterestInDefault.Value(mRecord.DefaultInterestInDefault);
    C.chkDefaultInterestPostMaturity.Value(mRecord.DefaultInterestPostMaturity);
    C.chkDefaultInterestPostFinalDate.Value(mRecord.DefaultInterestPostFinalDate);
    
    C.cboDefaultInterestOverdueBasis.Text(mRecord.DefaultInterestOverdueBasis);
    C.numDefaultInterestOverdueThreshold.Value(mRecord.DefaultInterestOverdueThreshold);
    C.cboDefaultInterestOverdueChargeBasis.Text(mRecord.DefaultInterestOverdueChargeBasis);
    
    C.numDefaultInterestMinimumCharge.Value(mRecord.DefaultInterestMinimumCharge);
    
    C.cboDefaultFeeChargeBasis.Text(mRecord.DefaultFeeChargeBasis);
    C.numDefaultFeeValue.Value(mRecord.DefaultFeeValue);
    C.chkDefaultFeeIgnoreLimit.Value(mRecord.DefaultFeeIgnoreLimit);
    
    C.cboFacilityFeeChargeBasis.Text(mRecord.FacilityFeeChargeBasis);
    C.numFacilityFeeValue.Value(mRecord.FacilityFeeValue);
    C.chkFacilityFeeChargeThresholdApply.Value(mRecord.FacilityFeeChargeThresholdApply);
    C.numFacilityFeeChargeThresholdValue.Value(mRecord.FacilityFeeChargeThresholdValue);
    C.chkFacilityFeeChargeIfMovement.Value(mRecord.FacilityFeeChargeIfMovement);

    // Credit Limit
    if (mRecord.CreditLimitCount == 0) {
      C.cboCreditLimitCount.Text("Not Used");
    }
    else {
      C.cboCreditLimitCount.Text(mRecord.CreditLimitCount.toString());
    }
    C.chkCreditLimitKeepOnRefinance.Value(mRecord.CreditLimitKeepOnRefinance);
    C.chkCreditLimitUsePendingWithdrawals.Value(mRecord.CreditLimitUsePendingWithdrawals);
    C.chkCreditLimitUseUnclearedFunds.Value(mRecord.CreditLimitUseUnclearedFunds);
    C.chkCreditLimitUseOtherDeductions.Value(mRecord.CreditLimitUseOtherDeductions);
    C.txtCreditLimitOtherDeductionsDescription.Text(mRecord.CreditLimitOtherDeductionsDescription);
    
    C.txtCreditLimit1Description.Text(mRecord.CreditLimit1Description);
    C.numCreditLimit1.Value(mRecord.CreditLimit1);
    C.chkCreditLimit1Required.Value(mRecord.CreditLimit1Required);
    
    C.txtCreditLimit2Description.Text(mRecord.CreditLimit2Description);
    C.numCreditLimit2.Value(mRecord.CreditLimit2);
    C.chkCreditLimit2Required.Value(mRecord.CreditLimit2Required);
    
    C.txtCreditLimit3Description.Text(mRecord.CreditLimit3Description);
    C.numCreditLimit3.Value(mRecord.CreditLimit3);
    C.chkCreditLimit3Required.Value(mRecord.CreditLimit3Required);
    
    C.cboOverLimitBasis.Text(mRecord.OverLimitBasis);
    C.numOverLimitThresholdPercent.Value(mRecord.OverLimitThresholdPercent);
    C.numOverLimitThreshold.Value(mRecord.OverLimitThreshold);
    
    C.cboOverLimitFeeChargeBasis.Text(mRecord.OverLimitFeeChargeBasis);
    C.numOverLimitFeeValue.Value(mRecord.OverLimitFeeValue);

    // Close Options
    C.chkClosedPendingDefault.Value(mRecord.ClosedPendingDefault);
    C.numClosedPendingReviewDays.Value(mRecord.ClosedPendingReviewDays);
    C.chkClosedPendingAutoClose.Value(mRecord.ClosedPendingAutoClose);
    
    C.cboCloseLossFormula.Text(mRecord.CloseLossFormula);
    
    C.cboRefinanceLossFormula.Text(mRecord.RefinanceLossFormula);
    
    C.numSmallBalanceWriteOffDebit.Value(mRecord.SmallBalanceWriteOffDebit);
    C.numSmallBalanceWriteOffCredit.Value(mRecord.SmallBalanceWriteOffCredit);
    C.numSmallBalanceRefundCredit.Value(mRecord.SmallBalanceRefundCredit);
    
    C.chkOptionAutomaticClose.Value(mRecord.OptionAutomaticClose);
    C.chkOptionAutomaticClosePreMaturity.Value(mRecord.OptionAutomaticClosePreMaturity);
    C.chkOptionArchiveDeclinedUnwanted.Value(mRecord.OptionArchiveDeclinedUnwanted);
    C.chkOptionAllowStatusClosedToOpen.Value(mRecord.OptionAllowStatusClosedToOpen);

    // Other    
    C.chkStatementUse.Value(mRecord.StatementUse);
    C.cboStatementCycle.Text(mRecord.StatementCycle);
    C.dateStatementDateNext.Value(mRecord.StatementDateNext);
        
    C.cboParameterSetUserDefined.Text(mRecord.UserDefinedParameterSetId);
    
    C.numDebtRatioThreshold.Value(mRecord.DebtRatioThreshold);
    
    C.cboClientStatisticSourceExtraAsset.Text(mRecord.ClientStatisticSourceExtraAsset);
    C.cboClientStatisticSourceExtraLiability.Text(mRecord.ClientStatisticSourceExtraLiability);
    C.cboClientStatisticSourceConsolidatedLiability.Text(mRecord.ClientStatisticSourceConsolidatedLiability);
    C.cboClientStatisticSourceConsolidatedExpense.Text(mRecord.ClientStatisticSourceConsolidatedExpense);
    
    C.chkIncludeAccountLevelInsurance.Value(mRecord.IncludeAccountLevelInsurance);
    C.chkOptionAllowWithdrawals.Value(mRecord.OptionAllowWithdrawals);
    C.chkDepositAllowWithdrawalsNegativeBalance.Value(mRecord.DepositAllowWithdrawalsNegativeBalance);
    C.chkTransferCommonClient.Value(mRecord.TransferCommonClient);    
    C.chkOptionAllowRestructure.Value(mRecord.OptionAllowRestructure);
    C.chkOptionAllowRefinanceInto.Value(mRecord.OptionAllowRefinanceInto);
    C.chkOptionAllowRefinanceRedatedForward.Value(mRecord.OptionAllowRefinanceRedatedForward);
    C.chkUserFlagA.Value(mRecord.UserFlagA);
    C.chkUserFlagB.Value(mRecord.UserFlagB);
    
    C.chkShowAccountIdWithCheckDigit.Value(mRecord.ShowAccountIdWithCheckDigit);
    C.chkShowHistoryRating.Value(mRecord.ShowHistoryRating);
    C.chkShowTotalAdvances.Value(mRecord.ShowTotalAdvances);
    C.chkShowOverdue.Value(mRecord.ShowOverdue);
    C.chkShowContractualOverdue.Value(mRecord.ShowContractualOverdue);

    // Promotions
    C.cboPromotionBasis.Text(mRecord.PromotionBasis);
    C.cboPromotionParameterSetUserDefined.Text(mRecord.PromotionUserDefinedParameterSetId);

    // Transactions
    C.numNetAdvanceMinimum.Value(mRecord.NetAdvanceMinimum);
    C.numNetAdvanceMaximum.Value(mRecord.NetAdvanceMaximum);
    C.chkOptionCreateAdjustedToZeroTransactions.Value(mRecord.OptionCreateAdjustedToZeroTransactions);

    // Documents
    // NOTE: Handled in pageDocuments_Refresh

    // Accounting
    C.cboControlGlAccount.Text(mRecord.ControlGlAccountId);
    C.cboClearingGlAccount.Text(mRecord.ClearingGlAccountId);

    // User Defined
    if (mRecord.AllowPageUserDefined) {
      // Handled in AccountClass_PagesRefresh
    }
  }

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

  // Update Controls

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabDetails_Refresh();
  tabDetails_Resize();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  // Don't pass back global collections etc
  mRecord.Documents = null;
  mRecord.Elements = null;
  mRecord.Scripts = null;

  // General
  mRecord.AccountTypeId = C.txtAccountTypeId.Text();
  mRecord.Active = C.chkActive.Value();
  mRecord.Description = C.txtDescription.Text();

  mRecord.AccountClassText = C.cboAccountClass.Text();
  mRecord.ProductTypeId = C.cboProductType.Text();
  mRecord.CreditTypeText = C.cboCreditType.Text();
  mRecord.ConsumerRegulationTypeText = C.cboConsumerRegulationType.Text();

  mRecord.CreditSale = C.chkCreditSale.Value();
  mRecord.LaybySale = C.chkLaybySale.Value();

  mRecord.CreditReportingAccountType = C.cboCreditReportingAccountType.Text();
  mRecord.Category = C.cboCategory.Text();
  mRecord.Icon = C.cboIcon.Text();

  mRecord.Notes = C.txtNotes.Text();

  // New Accounts
  mRecord.NextAccountId = C.txtNextAccountId.Text();
  mRecord.DefaultDescription = C.txtDefaultDescription.Text();
  mRecord.DefaultLedger = C.cboDefaultLedger.Text();

  mRecord.OptionAllowLedger = C.chkOptionAllowLedger.Value();
  mRecord.OptionAllowFirstPaymentDate = C.chkOptionAllowFirstPaymentDate.Value();
  mRecord.OptionAllowRegularPayment = C.chkOptionAllowRegularPayment.Value();
  mRecord.OptionAllowBalloonPayment = C.chkOptionAllowBalloonPayment.Value();
  mRecord.OptionAllowResidualValue = C.chkOptionAllowResidualValue.Value();
  mRecord.OptionAllowMaturityDate = C.chkOptionAllowMaturityDate.Value();
  mRecord.OptionAllowMaturityInstruction = C.chkOptionAllowMaturityInstruction.Value();
  mRecord.OptionAllowMinimumPayment = C.chkOptionAllowMinimumPayment.Value();
  mRecord.OptionAllowMinimumPaymentDueDays = C.chkOptionAllowMinimumPaymentDueDays.Value();
  mRecord.OptionAllowMinimumPaymentHoldTo = C.chkOptionAllowMinimumPaymentHoldTo.Value();
  mRecord.OptionAllowTaxCategory = C.chkOptionAllowTaxCategory.Value();
  mRecord.OptionAllowInterestCycle = C.chkOptionAllowInterestCycle.Value();
  mRecord.OptionAllowInterest = C.chkOptionAllowInterest.Value();
  mRecord.OptionAllowStartupInterest = C.chkOptionAllowStartupInterest.Value();
  mRecord.OptionAllowTotalInterest = C.chkOptionAllowTotalInterest.Value();
  mRecord.OptionAllowReviewDate = C.chkOptionAllowReviewDate.Value();
  mRecord.DefaultReviewPeriod = C.cboDefaultReviewPeriod.Text();

  mRecord.OptionShowFinancialPageOverridingPaymentsTab = C.chkShowFinancialPageOverridingPaymentsTab.Value();
  mRecord.OptionShowFinancialPageOptionsTab = C.chkShowFinancialPageOptionsTab.Value();
  mRecord.OptionShowInstalmentsDrilldown = C.chkShowInstalmentsDrilldown.Value();
  mRecord.OptionShowInstalmentsDrilldownWeb = C.chkShowInstalmentsDrilldownWeb.Value();
  mRecord.OptionShowFinancialPagePrintQuotation = C.chkShowFinancialPagePrintQuotation.Value();

  mRecord.UserDefinedShowInNewAccountWizard = C.chkUserDefinedShowInNewAccountWizard.Value();
  mRecord.DisbursementsShowInNewAccountWizard = C.chkDisbursementsShowInNewAccountWizard.Value();

  mRecord.OptionDefaultQuoteStatus = C.chkOptionDefaultQuoteStatus.Value();
  mRecord.OptionDefaultResidualValueFromNetAdvance = C.chkOptionDefaultResidualValueFromNetAdvance.Value();
  mRecord.OptionDefaultResidualValueFromSecurities = C.chkOptionDefaultResidualValueFromSecurities.Value();
  mRecord.OptionDefaultPrintContractDocument = C.chkOptionDefaultPrintContractDocument.Value();

  mRecord.ShowWarningInfos = C.chkShowWarningInfos.Value();
  mRecord.ShowWarningAlerts = C.chkShowWarningAlerts.Value();

  // Term
  mRecord.TermEntryMethodText = C.cboTermEntryMethod.Text();

  mRecord.TermUse = C.chkTermUse.Value();
  mRecord.TermMandatory = C.chkTermMandatory.Value();

  mRecord.TermOnCall = C.chkTermOnCall.Value();

  mRecord.Term = C.cboTerm.Text();
  mRecord.TermOnDate = C.dateTermOnDate.Value();
  mRecord.TermList = C.txtTermList.Text();
  mRecord.TermLimitToList = C.chkTermLimitToList.Value();

  mRecord.TermNumberOfPayments = C.numTermNumberOfPayments.Value();

  mRecord.TermMinimum = C.cboTermMinimum.Text();
  mRecord.TermMaximum = C.cboTermMaximum.Text();

  mRecord.OptionAllowPayArrangeExtendTerm = C.chkOptionAllowPayArrangeExtendTerm.Value();
  mRecord.TermRollForward = C.chkTermRollForward.Value();
  mRecord.MaturityGraceDays = C.numMaturityGraceDays.Value();
  mRecord.TermCalculateSchedulePastMaturityDate = C.chkTermCalculateSchedulePastMaturityDate.Value();

  mRecord.MaturityAvailableInstructionsText = C.lstMaturityInstructionAvailableList.Text();
  mRecord.MaturityInstructionText = C.cboMaturityInstruction.Text();

  mRecord.MaturityAccountTypeId = C.cboMaturityAccountType.Text();
  mRecord.MaturityAccountTypesNew = C.txtMaturityAccountTypesNew.Text();
  mRecord.MaturityReinvestmentCommonClient = C.chkMaturityReinvestmentCommonClient.Value();

  mRecord.MaturityPaymentAvailableTypesText = C.lstMaturityPaymentAvailableTypes.Text();
  mRecord.MaturityPaymentTypeText = C.cboMaturityPaymentType.Text();
  mRecord.MaturityAccountTypesTransfer = C.txtMaturityAccountTypesTransfer.Text();
  mRecord.MaturityTransferCommonClient = C.chkMaturityTransferCommonClient.Value();

  // Transactions
  mRecord.NetAdvanceMinimum = C.numNetAdvanceMinimum.Value();
  mRecord.NetAdvanceMaximum = C.numNetAdvanceMaximum.Value();
  mRecord.OptionCreateAdjustedToZeroTransactions = C.chkOptionCreateAdjustedToZeroTransactions.Value();

  // Payments
  mRecord.PaymentCycle = C.cboPaymentCycle.Text();
  mRecord.PaymentCycleList = C.txtPaymentCycleList.Text();
  mRecord.PaymentCycleLimitToList = C.chkPaymentCycleLimitToList.Value();
  
  mRecord.PaymentFirstPeriod = C.cboPaymentFirstPeriod.Text();
  mRecord.PaymentFirstDate = C.datePaymentFirstDate.Value();
  mRecord.PaymentFirstPeriodList = C.txtPaymentFirstPeriodList.Text();
  mRecord.PaymentFirstPeriodLimitToList = C.chkPaymentFirstPeriodLimitToList.Value();
  mRecord.PaymentFirstPeriodMaximum = C.cboPaymentFirstPeriodMaximum.Text();
  
  mRecord.MinimumPaymentBasis = C.cboMinimumPaymentBasis.Text();
  mRecord.MinimumPaymentValue = C.numMinimumPaymentValue.Value();
  mRecord.MinimumPaymentPercent = C.numMinimumPaymentPercent.Value();
  mRecord.MinimumPaymentDueDays = C.numMinimumPaymentDueDays.Value();
  mRecord.MinimumPaymentMoveToNextBusinessDay = C.chkMinimumPaymentMoveToNextBusinessDay.Value();
  mRecord.MinimumPaymentCarryForwardPrepaid = C.chkMinimumPaymentCarryForwardPrepaid.Value();
  
  mRecord.MinimumPaymentHoldToPeriod = C.cboMinimumPaymentHoldToPeriod.Text();
  mRecord.MinimumPaymentHoldToDate = C.dateMinimumPaymentHoldToDate.Value();
  mRecord.MinimumPaymentHoldToList = C.txtMinimumPaymentHoldToList.Text();
  mRecord.MinimumPaymentHoldToLimitToList = C.chkMinimumPaymentHoldToLimitToList.Value();
  mRecord.MinimumPaymentHoldToMaximum = C.cboMinimumPaymentHoldToMaximum.Text();

  mRecord.OptionPaymentAllocationMethod = C.cboOptionPaymentAllocationMethod.Text();
  mRecord.OptionPaymentsInAdvance = C.chkOptionPaymentsInAdvance.Value();
  mRecord.OptionPaymentsRound = C.chkOptionPaymentsRound.Value();
  mRecord.OptionPaymentsRoundMultiple = C.numOptionPaymentsRoundMultiple.Value();
  mRecord.OptionPaymentsFinalPlusBalloon = C.chkOptionPaymentsFinalPlusBalloon.Value();
  mRecord.OptionPaymentsAdjustFinalBeforeBalloon = C.chkOptionPaymentsAdjustFinalBeforeBalloon.Value();
  mRecord.OptionNextPaymentIncludesMinimumPayments = C.chkOptionNextPaymentIncludesMinimumPayments.Value();
  mRecord.OptionAllowCreditBalancePreMaturity = C.chkOptionAllowCreditBalancePreMaturity.Value();
  mRecord.PaymentEarlyPartialRepaymentWarning = C.chkPaymentEarlyPartialRepaymentWarning.Value();
  mRecord.PaymentArrangementDefaultPrintAdvice = C.chkPaymentArrangementDefaultPrintAdvice.Value();
  
  mRecord.OptionPaymentDirectDebitDateOpened = C.chkOptionPaymentDirectDebitDateOpened.Value();
  mRecord.OptionPaymentDirectDebitBalloon = C.chkOptionPaymentDirectDebitBalloon.Value();
  mRecord.PaymentDirectDebitLimitToBalance = C.chkPaymentDirectDebitLimitToBalance.Value();
  mRecord.PaymentDirectDebitMinimumThreshold = C.numPaymentDirectDebitMinimumThreshold.Value();
  
  if (C.chkNegativePaymentMatch.Value()) {
    mRecord.NegativePaymentMatchDays = C.numNegativePaymentMatchDays.Value();
  }
  else {
    mRecord.NegativePaymentMatchDays = -1;
  }  
  
  mRecord.PaymentGracePeriodUse = C.chkPaymentGracePeriodUse.Value();
  mRecord.PaymentGracePeriodDays = C.numPaymentGracePeriodDays.Value();
  mRecord.PaymentGracePeriodChargeDefault = C.chkPaymentGracePeriodChargeDefault.Value();
  
  mRecord.BankReferenceCode = C.txtBankReferenceCode.Text();

  mRecord.PayToDescription = C.txtDefaultPayToDescription.Text();
  mRecord.PayToPurpose = C.cboDefaultPayToPurpose.Text();
  mRecord.PayToAccountIdentifierType = C.cboDefaultPayToAccountIdentifierType.Text();
  mRecord.PayToPaymentTermType = C.cboDefaultPayToPaymentTermType.Text();
  mRecord.PayToPaymentTermFrequency = C.cboDefaultPayToPaymentTermFrequency.Text();
    
  // Interest
  mRecord.InterestCycle = C.cboInterestCycle.Text();
  mRecord.InterestCycleDateNext = C.dateInterestCycleDateNext.Value();
  mRecord.InterestCycleList = C.txtInterestCycleList.Text();
  mRecord.InterestCycleLimitToList = C.chkInterestCycleLimitToList.Value();
  
  mRecord.StartupInterestAvailableTypes = C.lstStartupInterestTypeAvailableList.Text();
  mRecord.StartupInterestType = C.cboStartupInterestType.Text();
  mRecord.StartupInterestRate = C.numStartupInterestRate.Value();
  mRecord.StartupInterestRateTableId = C.cboStartupInterestRateTable.Text();
  mRecord.StartupInterestRateTablePremium = C.numStartupInterestRatePremium.Value();
  mRecord.StartupInterestPeriod = C.cboStartupInterestPeriod.Text();
  mRecord.StartupInterestToDate = C.dateStartupInterestToDate.Value();
  mRecord.StartupInterestPeriodList = C.txtStartupInterestPeriodList.Text();
  mRecord.StartupInterestPeriodLimitToList = C.chkStartupInterestPeriodLimitToList.Value();
  mRecord.StartupInterestPeriodMaximum = C.cboStartupInterestPeriodMaximum.Text();
  
  mRecord.InterestAvailableTypes = C.lstInterestTypeAvailableList.Text();
  mRecord.InterestType = C.cboInterestType.Text();
  mRecord.InterestRate = C.numInterestRate.Value();
  mRecord.InterestRateTableId = C.cboInterestRateTable.Text();
  mRecord.InterestRateTablePremium = C.numInterestRatePremium.Value();
  
  mRecord.OtherInterestType = C.cboOtherInterestType.Text();
  mRecord.OtherInterestRate = C.numOtherInterestRate.Value();
  mRecord.OtherInterestDescription = C.txtOtherInterestDescription.Text();

  // Interest Options
  mRecord.OptionInterestAccruedMethod = C.cboOptionInterestAccruedMethod.Text();
  mRecord.OptionInterestRoundMethod = C.cboOptionInterestRoundMethod.Text();
  mRecord.OptionInterestBackdating = C.cboOptionInterestBackdating.Text();
  mRecord.OptionInterestBackdatingConvertedTransactions = C.chkOptionInterestBackdatingConvertedTransactions.Value();

  mRecord.OptionInterestOnInterest = C.chkOptionInterestOnInterest.Value();
  mRecord.OptionInterestPrecomputed = C.chkOptionInterestPrecomputed.Value();
  mRecord.OptionInterestChargeUpfront = C.chkOptionInterestChargedUpfront.Value();
  mRecord.OptionInterestChargeOriginal = C.chkOptionInterestChargedOriginal.Value();
  mRecord.OptionInterestFlatRate = C.chkOptionInterestFlatRate.Value();
  mRecord.OptionInterestPostMaturityBasis = C.cboOptionInterestPostMaturityBasis.Text();
  mRecord.InterestNegativeRateAllow = C.chkInterestNegativeRateAllow.Value();
  mRecord.InterestNegativeRateTaxNotApplicable = C.chkInterestNegativeRateTaxNotApplicable.Value();
  mRecord.TaxCertificateNotIssueAIL = C.chkTaxCertificateNotIssueAIL.Value();
  
  mRecord.InterestCycleUpdateFromPaymentCycle = C.chkInterestCycleUpdateFromPaymentCycle.Value();
  mRecord.OptionInterestAlignFirst = C.chkOptionInterestAlignFirst.Value();
  mRecord.OptionInterestFixRateTable = C.chkOptionInterestFixRateTable.Value();
  
  mRecord.InterestInstructionDown = C.cboInterestInstructionDown.Text();
  mRecord.InterestInstructionUp = C.cboInterestInstructionUp.Text();
  
  mRecord.InterestEffectiveDateOrEarliestPaymentDate = C.chkInterestEffectiveDateOrEarliestPaymentDate.Value();
  mRecord.InterestEarliestDateDefault = C.cboInterestEarliestDateDefault.Text();
  
  mRecord.ComparisonRateType = C.cboComparisonRateType.Text();
  mRecord.ComparisonRateRoundingDecimals = C.numComparisonRateRoundingDecimals.Value();
  mRecord.ComparisonRateMaximum = C.numComparisonRateMaximum.Value();
  mRecord.ComparisonRateMaximumNextDate = C.dateComparisonRateMaximumNextDate.Value();
  mRecord.ComparisonRateMaximumNext = C.numComparisonRateMaximumNext.Value();
  
  mRecord.InterestPaymentAvailableTypes = C.lstInterestPaymentAvailableTypes.Text();
  mRecord.InterestPaymentType = C.cboInterestPaymentType.Text();
  mRecord.InterestCommonClient = C.chkInterestCommonClient.Value();
  mRecord.InterestPaymentRollForward = C.chkInterestPaymentRollForward.Value();
  mRecord.InterestPaymentCompoundFinal = C.chkInterestPaymentCompoundFinal.Value();
  mRecord.ReinvestmentPreserveInterestPaymentType = C.chkReinvestmentPreserveInterestPaymentType.Value();
  
  mRecord.InterestIsFromDividends = C.chkInterestIsFromDividends.Value();
  
  mRecord.ShowZeroInterestTransactions = C.chkShowZeroInterestTransactions.Value();

  // Rate Tables
  mRecord.StandardRateTableId = C.cboStandardRateTable.Text();

  // Overdue &amp; Defaults
  mRecord.OverdueLimitToBalance = C.chkOverdueLimitToBalance.Value();
  mRecord.ContractualOverdueLimitToBalance = C.chkContractualOverdueLimitToBalance.Value();
  
  mRecord.OverdueSmallBalanceThreshold = C.numOverdueSmallBalanceThreshold.Value();
  mRecord.ContractualOverdueSmallBalanceThreshold = C.numContractualOverdueSmallBalanceThreshold.Value();
  
  mRecord.DefaultInterestRateBasis = C.cboDefaultInterestRateBasis.Text();
  mRecord.DefaultInterestRate = C.numDefaultInterestRate.Value();
  
  mRecord.DefaultInterestInDefault = C.chkDefaultInterestInDefault.Value();
  mRecord.DefaultInterestPostMaturity = C.chkDefaultInterestPostMaturity.Value();
  mRecord.DefaultInterestPostFinalDate = C.chkDefaultInterestPostFinalDate.Value();
  
  mRecord.DefaultInterestOverdueBasis = C.cboDefaultInterestOverdueBasis.Text();
  mRecord.DefaultInterestOverdueThreshold = C.numDefaultInterestOverdueThreshold.Value();
  mRecord.DefaultInterestOverdueChargeBasis = C.cboDefaultInterestOverdueChargeBasis.Text();
  
  mRecord.DefaultInterestMinimumCharge = C.numDefaultInterestMinimumCharge.Value();
  
  mRecord.DefaultFeeChargeBasis = C.cboDefaultFeeChargeBasis.Text();
  mRecord.DefaultFeeValue = C.numDefaultFeeValue.Value();
  mRecord.DefaultFeeIgnoreLimit = C.chkDefaultFeeIgnoreLimit.Value();
  
  mRecord.FacilityFeeChargeBasis = C.cboFacilityFeeChargeBasis.Text();
  mRecord.FacilityFeeValue = C.numFacilityFeeValue.Value();
  mRecord.FacilityFeeChargeThresholdApply = C.chkFacilityFeeChargeThresholdApply.Value();
  mRecord.FacilityFeeChargeThresholdValue = C.numFacilityFeeChargeThresholdValue.Value();
  mRecord.FacilityFeeChargeIfMovement = C.chkFacilityFeeChargeIfMovement.Value();

  // Credit Limit
  if (!C.cboCreditLimitCount.Text() || C.cboCreditLimitCount.Text() == "Not Used") {
    mRecord.CreditLimitCount = 0;
  }
  else {
    mRecord.CreditLimitCount = Number(C.cboCreditLimitCount.Text());
  }
  mRecord.CreditLimitKeepOnRefinance = C.chkCreditLimitKeepOnRefinance.Value();
  mRecord.CreditLimitUsePendingWithdrawals = C.chkCreditLimitUsePendingWithdrawals.Value();
  mRecord.CreditLimitUseUnclearedFunds = C.chkCreditLimitUseUnclearedFunds.Value();
  mRecord.CreditLimitUseOtherDeductions = C.chkCreditLimitUseOtherDeductions.Value();
  mRecord.CreditLimitOtherDeductionsDescription = C.txtCreditLimitOtherDeductionsDescription.Text();
  
  mRecord.CreditLimit1Description = C.txtCreditLimit1Description.Text();
  mRecord.CreditLimit1 = C.numCreditLimit1.Value();
  mRecord.CreditLimit1Required = C.chkCreditLimit1Required.Value();
  
  mRecord.CreditLimit2Description = C.txtCreditLimit2Description.Text();
  mRecord.CreditLimit2 = C.numCreditLimit2.Value();
  mRecord.CreditLimit2Required = C.chkCreditLimit2Required.Value();
  
  mRecord.CreditLimit3Description = C.txtCreditLimit3Description.Text();
  mRecord.CreditLimit3 = C.numCreditLimit3.Value();
  mRecord.CreditLimit3Required = C.chkCreditLimit3Required.Value();
  
  mRecord.OverLimitBasis = C.cboOverLimitBasis.Text();
  mRecord.OverLimitThresholdPercent = C.numOverLimitThresholdPercent.Value();
  mRecord.OverLimitThreshold = C.numOverLimitThreshold.Value();
  
  mRecord.OverLimitFeeChargeBasis = C.cboOverLimitFeeChargeBasis.Text();
  mRecord.OverLimitFeeValue = C.numOverLimitFeeValue.Value();

  // Close Options
  mRecord.ClosedPendingDefault = C.chkClosedPendingDefault.Value();
  mRecord.ClosedPendingReviewDays = C.numClosedPendingReviewDays.Value();
  mRecord.ClosedPendingAutoClose = C.chkClosedPendingAutoClose.Value();
  
  mRecord.CloseLossFormula = C.cboCloseLossFormula.Text();
  
  mRecord.RefinanceLossFormula = C.cboRefinanceLossFormula.Text();
  
  mRecord.SmallBalanceWriteOffDebit = C.numSmallBalanceWriteOffDebit.Value();
  mRecord.SmallBalanceWriteOffCredit = C.numSmallBalanceWriteOffCredit.Value();
  mRecord.SmallBalanceRefundCredit = C.numSmallBalanceRefundCredit.Value();
  
  mRecord.OptionAutomaticClose = C.chkOptionAutomaticClose.Value();
  mRecord.OptionAutomaticClosePreMaturity = C.chkOptionAutomaticClosePreMaturity.Value();
  mRecord.OptionArchiveDeclinedUnwanted = C.chkOptionArchiveDeclinedUnwanted.Value();
  mRecord.OptionAllowStatusClosedToOpen = C.chkOptionAllowStatusClosedToOpen.Value();

  // Other    
  mRecord.StatementUse = C.chkStatementUse.Value();
  mRecord.StatementCycle = C.cboStatementCycle.Text();
  mRecord.StatementDateNext = C.dateStatementDateNext.Value();
      
  mRecord.UserDefinedParameterSetId = C.cboParameterSetUserDefined.Text();
  
  mRecord.DebtRatioThreshold = C.numDebtRatioThreshold.Value();
  
  mRecord.ClientStatisticSourceExtraAsset = C.cboClientStatisticSourceExtraAsset.Text();
  mRecord.ClientStatisticSourceExtraLiability = C.cboClientStatisticSourceExtraLiability.Text();
  mRecord.ClientStatisticSourceConsolidatedLiability = C.cboClientStatisticSourceConsolidatedLiability.Text();
  mRecord.ClientStatisticSourceConsolidatedExpense = C.cboClientStatisticSourceConsolidatedExpense.Text();
  
  mRecord.IncludeAccountLevelInsurance = C.chkIncludeAccountLevelInsurance.Value();
  mRecord.OptionAllowWithdrawals = C.chkOptionAllowWithdrawals.Value();
  mRecord.DepositAllowWithdrawalsNegativeBalance = C.chkDepositAllowWithdrawalsNegativeBalance.Value();
  mRecord.TransferCommonClient = C.chkTransferCommonClient.Value();    
  mRecord.OptionAllowRestructure = C.chkOptionAllowRestructure.Value();
  mRecord.OptionAllowRefinanceInto = C.chkOptionAllowRefinanceInto.Value();
  mRecord.OptionAllowRefinanceRedatedForward = C.chkOptionAllowRefinanceRedatedForward.Value();
  mRecord.UserFlagA = C.chkUserFlagA.Value();
  mRecord.UserFlagB = C.chkUserFlagB.Value();
  
  mRecord.ShowAccountIdWithCheckDigit = C.chkShowAccountIdWithCheckDigit.Value();
  mRecord.ShowHistoryRating = C.chkShowHistoryRating.Value();
  mRecord.ShowTotalAdvances = C.chkShowTotalAdvances.Value();
  mRecord.ShowOverdue = C.chkShowOverdue.Value();
  mRecord.ShowContractualOverdue = C.chkShowContractualOverdue.Value();

  mRecord.PromotionBasis = C.cboPromotionBasis.Text();
  mRecord.PromotionUserDefinedParameterSetId = C.cboPromotionParameterSetUserDefined.Text();

  // Documents
  mRecord.DocumentLinks = mRecord_DocumentLinks;
  mRecord.ElementLinks = mRecord_ElementLinks;

  // Accounting
  mRecord.ControlGlAccountId = C.cboControlGlAccount.Text();
  mRecord.ClearingGlAccountId = C.cboClearingGlAccount.Text();

  // User Defined
  if (mRecord.AllowPageUserDefined &amp;&amp; mRecord_AccountClassData &amp;&amp; mRecord_AccountClassData.UserDefinedParameters &amp;&amp; mRecord_AccountClassData.UserDefinedParameters.length != 0) {
    mRecord.UserDataJson = JSON.stringify(C.phUserDefined.GetParameterValues());
  }
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  if (mRecord) {
    if (mRecord.AccountTypeId) {
      widget.SetHeading("Account Type (" + mRecord.AccountTypeId + ")");
    }
    else {
      widget.SetHeading("New Account Type");
    }
  }

  // Information Lists
  // NOTE: Some of these are set in cboProductType_Change
  if (mRecord) {
    // New Accounts
    C.cboDefaultLedger.SetComboFromInformationList("AccountLedger", false);
    C.txtDefaultDescription.TagsListDefine([{ caption: "Dealer", value: "[Dealer]" },
                                            { caption: "Security", value: "[Security]" }]);
  }

  // Lists
  if (mRecord) {
    // General
    C.cboAccountClass.ListFromCollection(mRecord.AccountClassList, "Description");
    C.cboCreditType.ListFromCollection(mRecord.CreditTypeList, "Description");
    C.cboConsumerRegulationType.ListFromCollection(mRecord.ConsumerRegulationTypeList, "Description");
    C.cboProductType.RefreshFromStandardRange("ProductTypes");
    C.cboIcon.ListFromCsvString(mRecord.IconList);

    // New Accounts
    C.cboDefaultReviewPeriod.ListFromCsvString(mRecord.DefaultReviewPeriodList);

    // Term
    if (mRecord.AllowPageTerm) {
      C.cboTermEntryMethod.ListFromCollection(mRecord.TermEntryMethodList, "Description");

      C.cboTermMinimum.ListFromCsvString("1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
      C.cboTermMaximum.ListFromCsvString("3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years,20 Years,30 Years");

      C.lstMaturityInstructionAvailableList.ListFromCsvString(mRecord.MaturityInstructionList);
      C.cboMaturityInstruction.ListFromCsvString(mRecord.MaturityInstructionList);

      C.cboMaturityAccountType.RefreshFromStandardRange("AccountTypesDeposits");

      C.lstMaturityPaymentAvailableTypes.ListFromCsvString(mRecord.MaturityPaymentTypeList);
      C.cboMaturityPaymentType.ListFromCsvString(mRecord.MaturityPaymentTypeList);
    }

    // Payments
    if (mRecord.AllowPagePayments) {
      C.cboPaymentCycle.ListFromCsvString("Weekly,Fortnightly,Monthly,End of Month,Quarterly,Yearly");
      C.cboPaymentFirstPeriod.ListFromCsvString("Standard,Opening,On Date,At Maturity,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years");
      C.cboPaymentFirstPeriod.ListOtherFromCsvString("Standard,Opening,On Date,At Maturity");
      C.cboPaymentFirstPeriodMaximum.ListFromCsvString("1 Week,2 Weeks,4 Weeks,1 Month,2 Months,3 Months,6 Months,1 Year");
      C.cboMinimumPaymentBasis.ListFromCollection(mRecord.MinimumPaymentBasisList, "Description");
      C.cboMinimumPaymentHoldToPeriod.ListFromCsvString("None,On Date,1 Week,1 Fortnight,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years");
      C.cboMinimumPaymentHoldToPeriod.ListOtherFromCsvString("None,On Date");
      C.cboMinimumPaymentHoldToMaximum.ListFromCsvString("1 Week,2 Weeks,4 Weeks,1 Month,2 Months,3 Months,6 Months,1 Year");
      C.cboOptionPaymentAllocationMethod.ListFromCollection(mRecord.PaymentAllocationMethodList, "Description");
      C.cboDefaultPayToPurpose.ListFromCsvString(mRecord.PayToPurposeList);
      C.cboDefaultPayToAccountIdentifierType.ListFromCsvString(mRecord.PayToAccountIdentifierTypeList);
      C.cboDefaultPayToPaymentTermType.ListFromCsvString(mRecord.PayToPaymentTermTypeList);
      C.cboDefaultPayToPaymentTermFrequency.ListFromCsvString(mRecord.PayToPaymentTermFrequencyList);
    }

    // Interest
    if (mRecord.AllowPageInterest) {
      C.cboInterestCycle.ListFromCsvString("Weekly,Fortnightly,Monthly,End of Month,Quarterly,Yearly,At Maturity");
      C.cboInterestCycle.ListOtherFromCsvString("At Maturity");
      C.lstStartupInterestTypeAvailableList.ListFromCsvString(mRecord.StartupInterestTypeAvailableList);
      C.cboStartupInterestType.ListFromCollection(mRecord.AccountStartupInterestTypeList, "Description");
      C.cboStartupInterestRateTable.RefreshFromStandardRange("RateTables");
      C.cboStartupInterestPeriod.ListFromCsvString("To Date,1 Week,2 Weeks,4 Weeks,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years");
      C.cboStartupInterestPeriod.ListOtherFromCsvString("To Date");
      C.cboStartupInterestPeriodMaximum.ListFromCsvString("3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years,20 Years,30 Years");
      C.lstInterestTypeAvailableList.ListFromCsvString(mRecord.InterestTypeAvailableList);
      C.cboInterestType.ListFromCollection(mRecord.AccountInterestTypeList, "Description");
      C.cboInterestRateTable.RefreshFromStandardRange("RateTables");
      C.cboOtherInterestType.ListFromCollection(mRecord.OtherInterestTypeList, "Description");
    }

    // Interest Options
    if (mRecord.AllowPageInterestOptions) {
      C.cboOptionInterestAccruedMethod.ListFromCsvString(mRecord.InterestAccruedMethodList);
      C.cboOptionInterestRoundMethod.ListFromCsvString(mRecord.InterestRoundMethodList);
      C.cboOptionInterestBackdating.ListFromCollection(mRecord.InterestBackdatingList, "Description");
      C.cboOptionInterestPostMaturityBasis.ListFromCsvString(mRecord.InterestPostMaturityBasis);      
      C.cboInterestInstructionDown.ListFromCsvString(mRecord.AccountInterestInstructionList);
      C.cboInterestInstructionUp.ListFromCsvString(mRecord.AccountInterestInstructionList);
      C.cboInterestEarliestDateDefault.ListFromCsvString("21 Days,30 Days,1 Month");
      C.cboComparisonRateType.ListFromCsvString(mRecord.AccountCalcComparisonRateTypeList)      
      C.lstInterestPaymentAvailableTypes.ListFromCsvString(mRecord.AccountInterestPaymentTypeList);
      C.cboInterestPaymentType.ListFromCsvString(mRecord.AccountInterestPaymentTypeList);
    }

    // Rate Tables
    if (mRecord.AllowPageRateTables) {
      C.cboStandardRateTable.RefreshFromStandardRange("RateTables");
    }

    // Overdue &amp; Defaults
    if (mRecord.AllowPageDefaults) {
      C.cboDefaultInterestRateBasis.ListFromCsvString(mRecord.DefaultInterestRateBasisList);
      C.cboDefaultInterestOverdueBasis.ListFromCollection(mRecord.DefaultInterestOverdueBasisList, "Description");
      C.cboDefaultInterestOverdueChargeBasis.ListFromCsvString(mRecord.DefaultInterestOverdueChargeBasisList);
      C.cboDefaultFeeChargeBasis.ListFromCollection(mRecord.DefaultFeeChargeBasisList, "Description");  
      C.cboFacilityFeeChargeBasis.ListFromCollection(mRecord.FacilityFeeChargeBasisList, "Description");            
    }

    // Credit Limit
    if (mRecord.AllowPageCreditLimit) {
      C.cboOverLimitBasis.ListFromCollection(mRecord.OverLimitBasisList, "Description");
      C.cboOverLimitFeeChargeBasis.ListFromCollection(mRecord.OverLimitFeeBasisList, "Description");
    }

    // Close Options
    if (mRecord.AllowPageCloseOptions) {
      C.cboCloseLossFormula.ListFromCsvString(mRecord.AccountCloseLossFormulaList);    
      C.cboRefinanceLossFormula.ListFromCsvString(mRecord.AccountCloseLossFormulaList);  
    }

    // Other
    if (mRecord.AllowPageOther) {
      C.cboParameterSetUserDefined.RefreshFromStandardRange("ParameterSets", "", false, mRecord.UserDefinedParameterSetId);
      C.cboClientStatisticSourceExtraAsset.ListFromCsvString(mRecord.AccountTypeStatisticSourceList);
      C.cboClientStatisticSourceExtraLiability.ListFromCsvString(mRecord.AccountTypeStatisticSourceList);
      C.cboClientStatisticSourceConsolidatedLiability.ListFromCsvString(mRecord.AccountTypeStatisticSourceList);
      C.cboClientStatisticSourceConsolidatedExpense.ListFromCsvString(mRecord.AccountTypeStatisticSourceList);      
    }

    // Promotions
    if (mRecord.AllowPagePromotions) {
      C.cboPromotionBasis.ListFromCsvString(mRecord.AccountTypePromotionBasisList);
      C.cboPromotionParameterSetUserDefined.RefreshFromStandardRange("ParameterSets", "", false, mRecord.PromotionUserDefinedParameterSetId);
    }

    // Accounting
    if (mRecord.AllowPageAccounting) {
      C.cboControlGlAccount.RefreshFromStandardRange("GlAccounts");
      C.cboClearingGlAccount.RefreshFromStandardRange("GlAccounts");
    }

  }

  // Controls
  if (mRecord) {
    // General
    C.cboAccountClass.ReadOnly(mRecord.Pk != 0);
    cboAccountClass_Change();
    cboProductType_Change();
    cboCreditType_Change();

    // Term
    
    // Credit Limit
    cboCreditLimitCount_Change();
    
    // Other
    C.chkUserFlagA.Caption(mRecord.UserFlagACaption);
    C.chkUserFlagB.Caption(mRecord.UserFlagBCaption);
  }

  // Pages
  if (mRecord) {
    // NOTE: Even though many pages are updated in tabDetails_Refresh, we must update them here to ensure controls are hidden since this is not a wizard and all pages are validated on "Finish"
    pageGeneral_Refresh();
    pageTerm_Refresh();
    pagePayments_Refresh();
    pageInterest_Refresh();
    pageInterestOptions_Refresh();
    pageDefaults_Refresh();
    pageCloseOptions_Refresh();
    pageOther_Refresh();
    pagePromotions_Refresh();
    pageDocuments_Refresh();
    pageAccounting_Refresh();
    pageScripts_Refresh();
    pageUserDefined_Refresh();
  }

  // Read-Only?
  if (mRecord &amp;&amp; mRecord.ReadOnly) {
    cmdFinish.prop("disabled", true);
    frmMain.FormReadOnly(C, true);
  }

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

  // Resize Tab
  tabDetails_Resize();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  // Mobile Optimisations
  var el = $(".mobile-indent th.indent1, .mobile-indent th.no-indent1");
  if (window.innerWidth &lt; 500) {
    el.addClass("no-indent1").removeClass("indent1");
  }
  else {
    el.addClass("indent1").removeClass("no-indent1");
  }

  // General

  // Tab
  tabDetails_Resize();
  
  // Auto-Format page to sort out topmost headings
  tabDetails.AutoFormatPage();
}

// ========
// Is Dirty
// ========
function Form_IsDirty() {
  if (mRecord) {
    // Save Fields
    Fields_Save();

    // Is Dirty?
    return mOriginalJson != JSON.stringify(mRecord);
  }
  else {
    return false;
  }
}

// ==============
// Wizard Buttons
// ==============
function tabDetails_Cancel() {
  if (Form_IsDirty()) {
    // Confirm    
    widget.UI.MsgBoxConfirm("Are you sure you want to close this form without saving your changes?", { heading: "Close Form" }, tabDetails_Cancel_Finalise);
  }
  else {
    // Cancel immediately
    tabDetails_Cancel_Finalise();
  }
}

function tabDetails_Cancel_Finalise() {
  if (widget.CanClose()) {
    widget.Close();
  }
  else {
    widget.Reset();
  }
}

// ==========
// Resize Tab
// ==========
function tabDetails_Resize() {
  switch (tabDetails.SelectedTabId()) {
    case "General":
      // General
      C.txtDescription.WidthResizeFromParent();
      C.cboAccountClass.WidthResizeFromParent();
      C.cboCreditType.WidthResizeFromParent();
      C.cboConsumerRegulationType.WidthResizeFromParent();
      C.cboCreditReportingAccountType.WidthResizeFromParent();
      C.cboCategory.WidthResizeFromParent();
      C.txtNotes.WidthResizeFromParent();
      break;

    case "pageNewAccounts":
      // New Accounts
      C.txtNextAccountId.WidthResizeFromParent();
      C.txtDefaultDescription.WidthResizeFromParent();
      C.cboDefaultLedger.WidthResizeFromParent();
      break;

    case "pageTerm":
      // Term
      C.txtTermList.WidthResizeFromParent();
      break;

    case "UserDefined":
      // User Defined
      C.phUserDefined.ResizeFromParent();
      break;
  }
}

// ===========
// Refresh Tab
// ===========
function tabDetails_Refresh() {
   // Load details
  switch (tabDetails.SelectedTabId()) {
    case "General":
      pageGeneral_Refresh();
      break;

    case "Term":
      pageTerm_Refresh();
      break;

    case "Payments":
      pagePayments_Refresh();
      break;

    case "Interest":
      pageInterest_Refresh();
      break;

    case "InterestOptions":
      pageInterestOptions_Refresh();
      break;

    case "Defaults":
      pageDefaults_Refresh();
      break;

    case "CloseOptions":
      pageCloseOptions_Refresh();
      break;

    case "Other":
      pageOther_Refresh();
      break;

    case "Promotions":
      pagePromotions_Refresh();
      break;

    case "Documents":
      pageDocuments_Refresh();
      break;

    case "Accounting":
      pageAccounting_Refresh();
      break;

    case "Scripts":
      pageScripts_Refresh();
      break;

    case "UserDefined":
      pageUserDefined_Refresh();
      break;

    default:
      break;
  }

  // Resize
  tabDetails_Resize();

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

// =================
// Execute an Action
// =================
function Form_ExecuteAction(actionId, data) {
  switch(actionId) {
    default:
      window.alert("Unhandled action '" + actionId + "'");
  }
}

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  // Assume Success
  var Ok = true;

  // Validate
  Ok = tabDetails.Validate();

  // Prompt
  if (Ok) {
    if (mRecord.PromptOnSave) {
      // Confirm
      widget.UI.MsgBoxConfirm("Are you sure you want to save this record?",
                              { heading: "Save" },
                              Form_ExecuteAction_FinishPost);

    }
    else {
      // Save without prompting
      Form_ExecuteAction_FinishPost();
    }
  }
}

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

  // Create Parameters
  // NOTE: We will simply update mRecord, clone this and send back (less some information)
  Fields_Save();
  var params = JSON.parse(JSON.stringify(mRecord));
  //params.GendersList = null;

  // Finish
  widget.GetString("Finish", params,
    function (data) {
      // Close Form
      widget.Close();

      // Refresh Parent (to show updated details)
      // NOTE: Pass in Record Id just in case this has changed
      widget.RefreshParent(C.txtAccountTypeId.Text());
    },

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

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

// ===========
// pageGeneral
// ===========
function pageGeneral_Refresh() {
  if (!mRecord) return;

  // Controls
}

// ============
// pageInterest
// ============
function pageInterest_Refresh() {
  // Hide all
  C.dateInterestCycleDateNext.VisibleRow(false);
  C.lblOtherInterest.VisibleRow(false);
  C.cboOtherInterestType.VisibleRow(false);
  C.numOtherInterestRate.VisibleRow(false);
  C.txtOtherInterestDescription.VisibleRow(false);

  // Lists
  if (mRecord_AccountClassData) {
    C.cboStartupInterestType.ListFromCollection(mRecord_AccountClassData.AccountStartupInterestTypeList, "Description");
    C.cboInterestType.ListFromCollection(mRecord_AccountClassData.AccountInterestTypeList, "Description");
    C.lstInterestTypeAvailableList.ListFromCsvString(mRecord_AccountClassData.InterestTypeAvailableList);
    C.lstStartupInterestTypeAvailableList.ListFromCsvString(mRecord_AccountClassData.StartupInterestTypeAvailableList);
  }

  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;

  // Show controls based upon Account Class
  switch (AccountClass) {
    case "Deposit":
      C.dateInterestCycleDateNext.VisibleRow(true);
      break;
    
    default:
      C.lblOtherInterest.VisibleRow(true);
      C.cboOtherInterestType.VisibleRow(true);
      C.numOtherInterestRate.VisibleRow(true);
      C.txtOtherInterestDescription.VisibleRow(true);
      break;
  }
  
  // Update Controls
  lstStartupInterestTypeAvailableList_Change();
  cboStartupInterestRateTable_Change();
  cboStartupInterestPeriod_Change();
  lstInterestTypeAvailableList_Change();
  cboInterestRateTable_Change();
  cboOtherInterestType_Change();
}

// ===================
// pageInterestOptions
// ===================
function pageInterestOptions_Refresh() {
  // Hide all  
  C.chkOptionInterestPrecomputed.VisibleRow(false);
  C.chkOptionInterestChargedUpfront.VisibleRow(false);
  C.chkOptionInterestChargedOriginal.VisibleRow(false);
  C.chkOptionInterestFlatRate.VisibleRow(false);
  C.cboOptionInterestPostMaturityBasis.VisibleRow(false);
  C.chkInterestNegativeRateAllow.VisibleRow(false);
  C.chkInterestNegativeRateTaxNotApplicable.VisibleRow(false);
  C.chkTaxCertificateNotIssueAIL.VisibleRow(false);
  
  C.lblInterestNewAccountOptions.VisibleRow(false);
  C.chkInterestCycleUpdateFromPaymentCycle.VisibleRow(false);
  C.chkOptionInterestAlignFirst.VisibleRow(false);
  C.chkOptionInterestFixRateTable.VisibleRow(false);
  
  C.lblInterestInstructions.VisibleRow(false);
  C.cboInterestInstructionDown.VisibleRow(false);
  C.cboInterestInstructionUp.VisibleRow(false);
  
  C.lblFloatingInterestRateOptions.VisibleRow(false);
  C.chkInterestEffectiveDateOrEarliestPaymentDate.VisibleRow(false);
  C.cboInterestEarliestDateDefault.VisibleRow(false);
  
  C.lblComparisonRate.VisibleRow(false);
  C.cboComparisonRateType.VisibleRow(false);
  C.numComparisonRateRoundingDecimals.VisibleRow(false);
  C.numComparisonRateMaximum.VisibleRow(false);
  C.dateComparisonRateMaximumNextDate.VisibleRow(false);
  C.numComparisonRateMaximumNext.VisibleRow(false);
  
  C.lblInterestPayment.VisibleRow(false);
  C.lstInterestPaymentAvailableTypes.VisibleRow(false);
  C.cboInterestPaymentType.VisibleRow(false);
  C.chkInterestCommonClient.VisibleRow(false);
  C.chkInterestPaymentRollForward.VisibleRow(false);
  C.chkInterestPaymentCompoundFinal.VisibleRow(false);
  C.chkReinvestmentPreserveInterestPaymentType.VisibleRow(false);
  
  C.lblInvestmentIncomeReportingOptions.VisibleRow(false);
  C.chkInterestIsFromDividends.VisibleRow(false);

  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;

  // Show controls based upon Account Class
  switch (AccountClass) {
    case "Deposit":
      C.chkInterestNegativeRateAllow.VisibleRow(true);
      C.chkInterestNegativeRateTaxNotApplicable.VisibleRow(true);
      C.chkTaxCertificateNotIssueAIL.VisibleRow(mRecord.CountryCode == "NZ");
      
      C.lblInterestNewAccountOptions.VisibleRow(mRecord.AddOnRateTable);
      C.chkOptionInterestFixRateTable.VisibleRow(mRecord.AddOnRateTable);
      
      C.lblInterestPayment.VisibleRow(true);
      C.lstInterestPaymentAvailableTypes.VisibleRow(true);
      C.cboInterestPaymentType.VisibleRow(true);
      C.chkInterestCommonClient.VisibleRow(true);
      C.chkInterestPaymentRollForward.VisibleRow(true);
      C.chkInterestPaymentCompoundFinal.VisibleRow(true);
      C.chkReinvestmentPreserveInterestPaymentType.VisibleRow(true);
      C.lblInvestmentIncomeReportingOptions.VisibleRow(mRecord.CountryCode == "NZ");
      C.chkInterestIsFromDividends.VisibleRow(mRecord.CountryCode == "NZ");
      break;
      
    case "LoanFR":
      C.lblInterestNewAccountOptions.VisibleRow(true);
      C.chkInterestCycleUpdateFromPaymentCycle.VisibleRow(true);
      C.chkOptionInterestAlignFirst.VisibleRow(true);
      
      C.lblInterestInstructions.VisibleRow(true);
      C.cboInterestInstructionDown.VisibleRow(true);
      C.cboInterestInstructionUp.VisibleRow(true);
      
      C.lblFloatingInterestRateOptions.VisibleRow(true);
      C.chkInterestEffectiveDateOrEarliestPaymentDate.VisibleRow(true);
      C.cboInterestEarliestDateDefault.VisibleRow(true);
      
      C.lblComparisonRate.VisibleRow(true);
      C.cboComparisonRateType.VisibleRow(true);
      C.numComparisonRateRoundingDecimals.VisibleRow(true);
      C.numComparisonRateMaximum.VisibleRow(true);
      C.dateComparisonRateMaximumNextDate.VisibleRow(true);
      C.numComparisonRateMaximumNext.VisibleRow(true);
      break;
      
    case "LoanFT":
      C.chkOptionInterestPrecomputed.VisibleRow(true);
      C.chkOptionInterestChargedUpfront.VisibleRow(true);
      C.chkOptionInterestChargedOriginal.VisibleRow(true);
      C.chkOptionInterestFlatRate.VisibleRow(true);
      C.cboOptionInterestPostMaturityBasis.VisibleRow(true);
      
      C.lblInterestNewAccountOptions.VisibleRow(true);
      C.chkInterestCycleUpdateFromPaymentCycle.VisibleRow(true);
      C.chkOptionInterestAlignFirst.VisibleRow(true);
      
      C.lblComparisonRate.VisibleRow(true);
      C.cboComparisonRateType.VisibleRow(true);
      C.numComparisonRateRoundingDecimals.VisibleRow(true);
      C.numComparisonRateMaximum.VisibleRow(true);
      C.dateComparisonRateMaximumNextDate.VisibleRow(true);
      C.numComparisonRateMaximumNext.VisibleRow(true);
      break;
  }

  // Update Controls
  cboOptionInterestBackdating_Change();
  chkOptionInterestPrecomputed_Change();
  chkOptionInterestChargedUpfront_Change();
  chkOptionInterestChargedOriginal_Change();
  chkInterestNegativeRateAllow_Change();  
  dateComparisonRateMaximumNextDate_Change();
  lstInterestPaymentAvailableTypes_Change();
}

// =========
// pageOther
// =========
function pageOther_Refresh() {
  // Hide all
  C.lblDebtRatioThreshold.VisibleRow(false);
  C.numDebtRatioThreshold.VisibleRow(false);
  
  C.lblClientStatisticDataSource.VisibleRow(false);
  C.cboClientStatisticSourceExtraAsset.VisibleRow(false);
  C.cboClientStatisticSourceExtraLiability.VisibleRow(false);
  C.cboClientStatisticSourceConsolidatedLiability.VisibleRow(false);
  C.cboClientStatisticSourceConsolidatedExpense.VisibleRow(false);
  C.chkIncludeAccountLevelInsurance.VisibleRow(false);
  C.chkDepositAllowWithdrawalsNegativeBalance.VisibleRow(false);
  C.chkOptionAllowRestructure.VisibleRow(false);
  C.chkOptionAllowRefinanceInto.VisibleRow(false);
  C.chkOptionAllowRefinanceRedatedForward.VisibleRow(false);
  C.chkShowOverdue.VisibleRow(false);
  C.chkShowContractualOverdue.VisibleRow(false);
  C.chkShowTotalAdvances.VisibleRow(false);
  
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;
  
  // Statement Cycle
  switch (AccountClass) {
    case "Deposit":
    case "LoanFR":
    case "LoanFT":      
      C.cboStatementCycle.ListFromCsvString("None,On Demand,Weekly,Fortnightly,Monthly,End of Month,Quarterly,6 Monthly,Yearly");
      C.cboStatementCycle.ListOtherFromCsvString("None,On Demand");
      break;
      
    case "LoanRC":
      C.cboStatementCycle.ListFromCsvString("Weekly,Fortnightly,Monthly,End of Month,Quarterly,6 Monthly,Yearly");
      C.cboStatementCycle.ListOtherFromCsvString("");
      break;
  }
  
  // Control visibility
  switch (AccountClass) {
    case "Deposit":
      C.chkDepositAllowWithdrawalsNegativeBalance.VisibleRow(true);
      break;
      
    case "LoanFR":
      C.lblDebtRatioThreshold.VisibleRow(mRecord.AddOnClientStatistics);
      C.numDebtRatioThreshold.VisibleRow(mRecord.AddOnClientStatistics);
      
      C.lblClientStatisticDataSource.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceExtraAsset.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceExtraLiability.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceConsolidatedLiability.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceConsolidatedExpense.VisibleRow(mRecord.AddOnClientStatistics);
      C.chkIncludeAccountLevelInsurance.VisibleRow(true);      
      C.chkOptionAllowRefinanceInto.VisibleRow(true);
      C.chkOptionAllowRefinanceRedatedForward.VisibleRow(true);
      C.chkShowOverdue.VisibleRow(true);
      C.chkShowContractualOverdue.VisibleRow(true);
      C.chkShowTotalAdvances.VisibleRow(true);
      break;
    
    case "LoanFT":
      C.lblDebtRatioThreshold.VisibleRow(mRecord.AddOnClientStatistics);
      C.numDebtRatioThreshold.VisibleRow(mRecord.AddOnClientStatistics);
      
      C.lblClientStatisticDataSource.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceExtraAsset.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceExtraLiability.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceConsolidatedLiability.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceConsolidatedExpense.VisibleRow(mRecord.AddOnClientStatistics);
      C.chkIncludeAccountLevelInsurance.VisibleRow(true);
      C.chkOptionAllowRestructure.VisibleRow(true);
      C.chkOptionAllowRefinanceInto.VisibleRow(true);
      C.chkOptionAllowRefinanceRedatedForward.VisibleRow(true);
      C.chkShowOverdue.VisibleRow(true);
      C.chkShowContractualOverdue.VisibleRow(true);
      C.chkShowTotalAdvances.VisibleRow(true);
      break;
      
    case "LoanRC":
      C.lblDebtRatioThreshold.VisibleRow(mRecord.AddOnClientStatistics);
      C.numDebtRatioThreshold.VisibleRow(mRecord.AddOnClientStatistics);
      
      C.lblClientStatisticDataSource.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceExtraAsset.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceExtraLiability.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceConsolidatedLiability.VisibleRow(mRecord.AddOnClientStatistics);
      C.cboClientStatisticSourceConsolidatedExpense.VisibleRow(mRecord.AddOnClientStatistics);
      C.chkIncludeAccountLevelInsurance.VisibleRow(true);
      C.chkOptionAllowRefinanceInto.VisibleRow(true);
      C.chkOptionAllowRefinanceRedatedForward.VisibleRow(true);
      C.chkShowOverdue.VisibleRow(true);
      C.chkShowContractualOverdue.VisibleRow(true);
      break;      
  }
  
  // Update Controls
  chkStatementUse_Change();
  chkOptionAllowWithdrawals_Change();
  chkOptionAllowRefinanceInto_Change();
}

// ============
// pagePayments
// ============
function pagePayments_Refresh() {
  // Hide all
  C.lblDefaultPayments.VisibleRow(false);
  C.cboPaymentCycle.VisibleRow(false);
  C.txtPaymentCycleList.VisibleRow(false);
  C.chkPaymentCycleLimitToList.VisibleRow(false);
  
  C.lblDefaultFirstPayment.VisibleRow(false);
  C.cboPaymentFirstPeriod.VisibleRow(false);
  C.datePaymentFirstDate.VisibleRow(false);
  C.txtPaymentFirstPeriodList.VisibleRow(false);
  C.chkPaymentFirstPeriodLimitToList.VisibleRow(false);
  C.cboPaymentFirstPeriodMaximum.VisibleRow(false);
  
  C.lblMinimumPayments.VisibleRow(false);
  C.cboMinimumPaymentBasis.VisibleRow(false);
  C.numMinimumPaymentValue.VisibleRow(false);
  C.numMinimumPaymentPercent.VisibleRow(false);
  C.numMinimumPaymentDueDays.VisibleRow(false);
  C.chkMinimumPaymentMoveToNextBusinessDay.VisibleRow(false);
  C.chkMinimumPaymentCarryForwardPrepaid.VisibleRow(false);
  
  C.lblMinimumPaymentsHoldTo.VisibleRow(false);
  C.cboMinimumPaymentHoldToPeriod.VisibleRow(false);
  C.dateMinimumPaymentHoldToDate.VisibleRow(false);
  C.txtMinimumPaymentHoldToList.VisibleRow(false);
  C.chkMinimumPaymentHoldToLimitToList.VisibleRow(false);
  C.cboMinimumPaymentHoldToMaximum.VisibleRow(false);
  
  C.lblPaymentOptions.VisibleRow(false);
  C.cboOptionPaymentAllocationMethod.VisibleRow(false);
  C.chkOptionPaymentsInAdvance.VisibleRow(false);
  C.chkOptionPaymentsRound.VisibleRow(false);
  C.numOptionPaymentsRoundMultiple.VisibleRow(false);
  C.chkOptionPaymentsFinalPlusBalloon.VisibleRow(false);
  C.chkOptionPaymentsAdjustFinalBeforeBalloon.VisibleRow(false);
  C.chkOptionNextPaymentIncludesMinimumPayments.VisibleRow(false);
  C.chkOptionAllowCreditBalancePreMaturity.VisibleRow(false);
  C.chkPaymentEarlyPartialRepaymentWarning.VisibleRow(false);
  C.chkPaymentArrangementDefaultPrintAdvice.VisibleRow(false);
  
  C.lblDirectDebitOptions.VisibleRow(false);
  C.chkOptionPaymentDirectDebitDateOpened.VisibleRow(false);
  C.chkOptionPaymentDirectDebitBalloon.VisibleRow(false);
  C.chkPaymentDirectDebitLimitToBalance.VisibleRow(false);
  C.numPaymentDirectDebitMinimumThreshold.VisibleRow(false);
  
  C.lblNegativePaymentOptions.VisibleRow(false);
  C.chkNegativePaymentMatch.VisibleRow(false);
  C.numNegativePaymentMatchDays.VisibleRow(false);
  
  C.lblGracePeriod.VisibleRow(false);
  C.chkPaymentGracePeriodUse.VisibleRow(false);
  C.numPaymentGracePeriodDays.VisibleRow(false);
  C.chkPaymentGracePeriodChargeDefault.VisibleRow(false);
  
  C.lblBankReference.VisibleRow(false);
  C.txtBankReferenceCode.VisibleRow(false);
  
  C.lblPayTo.VisibleRow(false);
  C.txtDefaultPayToDescription.VisibleRow(false);
  C.cboDefaultPayToPurpose.VisibleRow(false);
  C.cboDefaultPayToAccountIdentifierType.VisibleRow(false);
  C.cboDefaultPayToPaymentTermType.VisibleRow(false);
  C.cboDefaultPayToPaymentTermFrequency.VisibleRow(false);
    
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;
  
  // Show controls based upon Account Class
  switch (AccountClass) {
    case "Disbursement":
      C.lblNegativePaymentOptions.VisibleRow(true);
      C.chkNegativePaymentMatch.VisibleRow(true);
      C.numNegativePaymentMatchDays.VisibleRow(true);
      
      C.lblBankReference.VisibleRow(true);
      C.txtBankReferenceCode.VisibleRow(true);
      
      C.lblPayTo.VisibleRow(mRecord.DisplayPayTo);
      C.txtDefaultPayToDescription.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPurpose.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToAccountIdentifierType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermFrequency.VisibleRow(mRecord.DisplayPayTo);            
      break;
    
    case "LoanFR":
      C.lblDefaultPayments.VisibleRow(true);
      C.cboPaymentCycle.VisibleRow(true);
      C.txtPaymentCycleList.VisibleRow(true);
      C.chkPaymentCycleLimitToList.VisibleRow(true);
      
      C.lblDefaultFirstPayment.VisibleRow(true);
      C.cboPaymentFirstPeriod.VisibleRow(true);      
      C.txtPaymentFirstPeriodList.VisibleRow(true);
      C.chkPaymentFirstPeriodLimitToList.VisibleRow(true);
      C.cboPaymentFirstPeriodMaximum.VisibleRow(true);
      
      C.lblPaymentOptions.VisibleRow(true);
      C.cboOptionPaymentAllocationMethod.VisibleRow(true);
      C.chkOptionPaymentsInAdvance.VisibleRow(true);
      C.chkOptionPaymentsRound.VisibleRow(true);
      C.numOptionPaymentsRoundMultiple.VisibleRow(true);
      C.chkOptionPaymentsFinalPlusBalloon.VisibleRow(true);
      C.chkOptionPaymentsAdjustFinalBeforeBalloon.VisibleRow(true);
      C.chkOptionNextPaymentIncludesMinimumPayments.VisibleRow(true);
      C.chkOptionAllowCreditBalancePreMaturity.VisibleRow(true);
      C.chkPaymentEarlyPartialRepaymentWarning.VisibleRow(true);
      C.chkPaymentArrangementDefaultPrintAdvice.VisibleRow(true);
      
      C.lblDirectDebitOptions.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.chkOptionPaymentDirectDebitDateOpened.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.chkOptionPaymentDirectDebitBalloon.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.chkPaymentDirectDebitLimitToBalance.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.numPaymentDirectDebitMinimumThreshold.VisibleRow(mRecord.AddOnBankingAdvanced);
      
      C.lblNegativePaymentOptions.VisibleRow(true);
      C.chkNegativePaymentMatch.VisibleRow(true);
      C.numNegativePaymentMatchDays.VisibleRow(true);
      
      C.lblGracePeriod.VisibleRow(true);
      C.chkPaymentGracePeriodUse.VisibleRow(true);
      C.numPaymentGracePeriodDays.VisibleRow(true);
      C.chkPaymentGracePeriodChargeDefault.VisibleRow(true);
      
      C.lblBankReference.VisibleRow(true);
      C.txtBankReferenceCode.VisibleRow(true);
      
      C.lblPayTo.VisibleRow(mRecord.DisplayPayTo);
      C.txtDefaultPayToDescription.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPurpose.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToAccountIdentifierType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermFrequency.VisibleRow(mRecord.DisplayPayTo);            
      break;
    
    case "LoanFT":
      C.lblDefaultPayments.VisibleRow(true);
      C.cboPaymentCycle.VisibleRow(true);
      C.txtPaymentCycleList.VisibleRow(true);
      C.chkPaymentCycleLimitToList.VisibleRow(true);
      
      C.lblDefaultFirstPayment.VisibleRow(true);
      C.cboPaymentFirstPeriod.VisibleRow(true);
      C.txtPaymentFirstPeriodList.VisibleRow(true);
      C.chkPaymentFirstPeriodLimitToList.VisibleRow(true);
      C.cboPaymentFirstPeriodMaximum.VisibleRow(true);
      
      C.lblPaymentOptions.VisibleRow(true);
      C.cboOptionPaymentAllocationMethod.VisibleRow(true);
      C.chkOptionPaymentsInAdvance.VisibleRow(true);
      C.chkOptionPaymentsRound.VisibleRow(true);
      C.numOptionPaymentsRoundMultiple.VisibleRow(true);
      C.chkOptionPaymentsFinalPlusBalloon.VisibleRow(true);
      C.chkOptionPaymentsAdjustFinalBeforeBalloon.VisibleRow(true);      
      C.chkOptionAllowCreditBalancePreMaturity.VisibleRow(true);
      C.chkPaymentEarlyPartialRepaymentWarning.VisibleRow(true);
      C.chkPaymentArrangementDefaultPrintAdvice.VisibleRow(true);
      
      C.lblDirectDebitOptions.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.chkOptionPaymentDirectDebitDateOpened.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.chkOptionPaymentDirectDebitBalloon.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.chkPaymentDirectDebitLimitToBalance.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.numPaymentDirectDebitMinimumThreshold.VisibleRow(mRecord.AddOnBankingAdvanced);
      
      C.lblNegativePaymentOptions.VisibleRow(true);
      C.chkNegativePaymentMatch.VisibleRow(true);
      C.numNegativePaymentMatchDays.VisibleRow(true);
      
      C.lblGracePeriod.VisibleRow(true);
      C.chkPaymentGracePeriodUse.VisibleRow(true);
      C.numPaymentGracePeriodDays.VisibleRow(true);
      C.chkPaymentGracePeriodChargeDefault.VisibleRow(true);
      
      C.lblBankReference.VisibleRow(true);
      C.txtBankReferenceCode.VisibleRow(true);

      C.lblPayTo.VisibleRow(mRecord.DisplayPayTo);
      C.txtDefaultPayToDescription.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPurpose.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToAccountIdentifierType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermFrequency.VisibleRow(mRecord.DisplayPayTo);      
      break;
    
    case "LoanRC":
      C.lblMinimumPayments.VisibleRow(true);
      C.cboMinimumPaymentBasis.VisibleRow(true);
      C.numMinimumPaymentValue.VisibleRow(true);
      C.numMinimumPaymentPercent.VisibleRow(true);
      C.numMinimumPaymentDueDays.VisibleRow(true);
      C.chkMinimumPaymentMoveToNextBusinessDay.VisibleRow(true);
      C.chkMinimumPaymentCarryForwardPrepaid.VisibleRow(true);
      
      C.lblMinimumPaymentsHoldTo.VisibleRow(true);
      C.cboMinimumPaymentHoldToPeriod.VisibleRow(true);
      C.txtMinimumPaymentHoldToList.VisibleRow(true);
      C.chkMinimumPaymentHoldToLimitToList.VisibleRow(true);
      C.cboMinimumPaymentHoldToMaximum.VisibleRow(true);
      
      C.lblPaymentOptions.VisibleRow(true);
      C.chkOptionNextPaymentIncludesMinimumPayments.VisibleRow(true);
      C.chkPaymentArrangementDefaultPrintAdvice.VisibleRow(true);
      
      C.lblDirectDebitOptions.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.chkOptionPaymentDirectDebitDateOpened.VisibleRow(mRecord.AddOnBankingAdvanced);      
      C.chkPaymentDirectDebitLimitToBalance.VisibleRow(mRecord.AddOnBankingAdvanced);
      C.numPaymentDirectDebitMinimumThreshold.VisibleRow(mRecord.AddOnBankingAdvanced);
      
      C.lblNegativePaymentOptions.VisibleRow(true);
      C.chkNegativePaymentMatch.VisibleRow(true);
      C.numNegativePaymentMatchDays.VisibleRow(true);
      
      C.lblGracePeriod.VisibleRow(true);
      C.chkPaymentGracePeriodUse.VisibleRow(true);
      C.numPaymentGracePeriodDays.VisibleRow(true);
      C.chkPaymentGracePeriodChargeDefault.VisibleRow(true);
      
      C.lblBankReference.VisibleRow(true);
      C.txtBankReferenceCode.VisibleRow(true);
      
      C.lblPayTo.VisibleRow(mRecord.DisplayPayTo);
      C.txtDefaultPayToDescription.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPurpose.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToAccountIdentifierType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermType.VisibleRow(mRecord.DisplayPayTo);
      C.cboDefaultPayToPaymentTermFrequency.VisibleRow(mRecord.DisplayPayTo);           
      break;
  }
  
  // Update Controls
  cboPaymentFirstPeriod_Change();
  cboMinimumPaymentBasis_Change();
  cboMinimumPaymentHoldToPeriod_Change();
  chkOptionPaymentsRound_Change();
  chkNegativePaymentMatch_Change();
  chkPaymentGracePeriodUse_Change();
}

// ==============
// pagePromotions
// ==============
function pagePromotions_Refresh() {
  // Update Controls
  cboPromotionBasis_Change();
}

// ===========
// pageScripts
// ===========
function pageScripts_Refresh() {
  // Refresh Scripts
  gridScriptLinks_Refresh();
}

// ========
// pageTerm
// ========
function pageTerm_Refresh(sender, e) {
  // Handled (just in case this is called direction from a Change event)
  if (e) e.ChangeHandled = true;

  // No record?
  if (!mRecord) return;

  // Get Term Entry Method
  var TermEntryMethod = "";
  if (C.cboTermEntryMethod.ListIndex() != -1) TermEntryMethod = mRecord.TermEntryMethodList[C.cboTermEntryMethod.ListIndex()].Code;

  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;

  // Controls (Account Class)
  switch (AccountClass) {
    case "Deposit":
      // =======
      // Deposit
      // =======
      TermEntryMethod = "Term"; // Keeps things easier in the next block

      C.lblTermEntryMethod.VisibleRow(false);
      C.cboTermEntryMethod.VisibleRow(false);

      C.lblTermUse.VisibleRow(false);
      C.chkTermUse.VisibleRow(false);
      C.chkTermMandatory.VisibleRow(false);

      C.lblTermOnCall.VisibleRow(true);
      C.chkTermOnCall.VisibleRow(true);

      C.lblTermDefault.VisibleRow(!C.chkTermOnCall.Value());
      C.cboTerm.VisibleRow(!C.chkTermOnCall.Value());
      C.dateTermOnDate.VisibleRow((C.cboTerm.Text() == "On Date" || C.chkTermOnCall.Value()) &amp;&amp; !C.chkTermOnCall.Value());
      C.txtTermList.VisibleRow(!C.chkTermOnCall.Value());
      C.chkTermLimitToList.VisibleRow(!C.chkTermOnCall.Value());

      C.lblTermLimits.VisibleRow(!C.chkTermOnCall.Value());
      C.cboTermMinimum.VisibleRow(!C.chkTermOnCall.Value());
      C.cboTermMaximum.VisibleRow(!C.chkTermOnCall.Value());

      C.lblTermOptions.VisibleRow(!C.chkTermOnCall.Value());
      C.chkOptionAllowPayArrangeExtendTerm.VisibleRow(false);
      C.chkTermRollForward.VisibleRow(!C.chkTermOnCall.Value());
      C.numMaturityGraceDays.VisibleRow(!C.chkTermOnCall.Value());
      C.chkTermCalculateSchedulePastMaturityDate.VisibleRow(false);

      C.lblMaturityInstructions.VisibleRow(!C.chkTermOnCall.Value());
      C.lstMaturityInstructionAvailableList.VisibleRow(!C.chkTermOnCall.Value());
      C.cboMaturityInstruction.VisibleRow(!C.chkTermOnCall.Value());

      var reinvest = C.lstMaturityInstructionAvailableList.Text().indexOf("Reinvest") != -1; // Text comparison is for convenience
      C.lblMaturityReinvestmentDetails.VisibleRow(reinvest &amp;&amp; !C.chkTermOnCall.Value());
      C.cboMaturityAccountType.VisibleRow(reinvest &amp;&amp; !C.chkTermOnCall.Value());
      C.txtMaturityAccountTypesNew.VisibleRow(reinvest&amp;&amp; !C.chkTermOnCall.Value());
      C.chkMaturityReinvestmentCommonClient.VisibleRow(reinvest &amp;&amp; !C.chkTermOnCall.Value());

      var repayment = C.lstMaturityInstructionAvailableList.Text().indexOf("Payout") != -1; // Text comparison is for convenience
      var transfer = C.lstMaturityPaymentAvailableTypes.Text().indexOf("Transfer") != -1; // Text comparison is for convenience
      C.lblMaturityRepaymentDetails.VisibleRow(repayment &amp;&amp; !C.chkTermOnCall.Value());
      C.lstMaturityPaymentAvailableTypes.VisibleRow(repayment &amp;&amp; !C.chkTermOnCall.Value());
      C.cboMaturityPaymentType.VisibleRow(repayment &amp;&amp; !C.chkTermOnCall.Value());
      C.txtMaturityAccountTypesTransfer.VisibleRow(repayment &amp;&amp; transfer &amp;&amp; !C.chkTermOnCall.Value());
      C.chkMaturityTransferCommonClient.VisibleRow(repayment &amp;&amp; transfer &amp;&amp; !C.chkTermOnCall.Value());
      break;

    case "LoanFR":
      // ==================
      // Floating Rate Loan
      // ==================
      C.lblTermEntryMethod.VisibleRow(true);
      C.cboTermEntryMethod.VisibleRow(true);

      C.lblTermUse.VisibleRow(false);
      C.chkTermUse.VisibleRow(false);
      C.chkTermMandatory.VisibleRow(false);

      C.lblTermOnCall.VisibleRow(false);
      C.chkTermOnCall.VisibleRow(false);

      C.lblTermLimits.VisibleRow(true);
      C.cboTermMinimum.VisibleRow(true);
      C.cboTermMaximum.VisibleRow(true);

      C.lblTermOptions.VisibleRow(true);
      C.chkOptionAllowPayArrangeExtendTerm.VisibleRow(true);
      C.chkTermRollForward.VisibleRow(false);
      C.numMaturityGraceDays.VisibleRow(false);
      C.chkTermCalculateSchedulePastMaturityDate.VisibleRow(false);

      C.lblMaturityInstructions.VisibleRow(false);
      C.lstMaturityInstructionAvailableList.VisibleRow(false);
      C.cboMaturityInstruction.VisibleRow(false);

      C.lblMaturityReinvestmentDetails.VisibleRow(false);
      C.cboMaturityAccountType.VisibleRow(false);
      C.txtMaturityAccountTypesNew.VisibleRow(false);
      C.chkMaturityReinvestmentCommonClient.VisibleRow(false);

      C.lblMaturityRepaymentDetails.VisibleRow(false);
      C.lstMaturityPaymentAvailableTypes.VisibleRow(false);
      C.cboMaturityPaymentType.VisibleRow(false);
      C.txtMaturityAccountTypesTransfer.VisibleRow(false);
      C.chkMaturityTransferCommonClient.VisibleRow(false);
      break;

    case "LoanFT":
      // ===============
      // Fixed Term Loan
      // ===============
      C.lblTermEntryMethod.VisibleRow(true);
      C.cboTermEntryMethod.VisibleRow(true);

      C.lblTermUse.VisibleRow(false);
      C.chkTermUse.VisibleRow(false);
      C.chkTermMandatory.VisibleRow(false);

      C.lblTermOnCall.VisibleRow(false);
      C.chkTermOnCall.VisibleRow(false);

      C.lblTermLimits.VisibleRow(true);
      C.cboTermMinimum.VisibleRow(true);
      C.cboTermMaximum.VisibleRow(true);

      C.lblTermOptions.VisibleRow(true);
      C.chkOptionAllowPayArrangeExtendTerm.VisibleRow(true);
      C.chkTermRollForward.VisibleRow(false);
      C.numMaturityGraceDays.VisibleRow(false);
      C.chkTermCalculateSchedulePastMaturityDate.VisibleRow(false);

      C.lblMaturityInstructions.VisibleRow(false);
      C.lstMaturityInstructionAvailableList.VisibleRow(false);
      C.cboMaturityInstruction.VisibleRow(false);

      C.lblMaturityReinvestmentDetails.VisibleRow(false);
      C.cboMaturityAccountType.VisibleRow(false);
      C.txtMaturityAccountTypesNew.VisibleRow(false);
      C.chkMaturityReinvestmentCommonClient.VisibleRow(false);

      C.lblMaturityRepaymentDetails.VisibleRow(false);
      C.lstMaturityPaymentAvailableTypes.VisibleRow(false);
      C.cboMaturityPaymentType.VisibleRow(false);
      C.txtMaturityAccountTypesTransfer.VisibleRow(false);
      C.chkMaturityTransferCommonClient.VisibleRow(false);
      break;

    case "LoanRC":
      // =====================
      // Revolving Credit Loan
      // =====================
      TermEntryMethod = "Term"; // Keeps things easier in the next block

      C.lblTermEntryMethod.VisibleRow(false);
      C.cboTermEntryMethod.VisibleRow(false);

      C.lblTermUse.VisibleRow(true);
      C.chkTermUse.VisibleRow(true);
      C.chkTermMandatory.VisibleRow(C.chkTermUse.Value());

      C.lblTermOnCall.VisibleRow(false);
      C.chkTermOnCall.VisibleRow(false);

      C.lblTermDefault.VisibleRow(C.chkTermUse.Value());
      C.cboTerm.VisibleRow(C.chkTermUse.Value());
      C.dateTermOnDate.VisibleRow(C.chkTermUse.Value() &amp;&amp; C.cboTerm.Text() == "On Date");
      C.txtTermList.VisibleRow(C.chkTermUse.Value());
      C.chkTermLimitToList.VisibleRow(C.chkTermUse.Value());

      C.lblTermLimits.VisibleRow(C.chkTermUse.Value());
      C.cboTermMinimum.VisibleRow(C.chkTermUse.Value());
      C.cboTermMaximum.VisibleRow(C.chkTermUse.Value());

      C.lblTermOptions.VisibleRow(true);
      C.chkOptionAllowPayArrangeExtendTerm.VisibleRow(false);
      C.chkTermRollForward.VisibleRow(false);
      C.numMaturityGraceDays.VisibleRow(false);
      C.chkTermCalculateSchedulePastMaturityDate.VisibleRow(true);

      C.lblMaturityInstructions.VisibleRow(false);
      C.lstMaturityInstructionAvailableList.VisibleRow(false);
      C.cboMaturityInstruction.VisibleRow(false);

      C.lblMaturityReinvestmentDetails.VisibleRow(false);
      C.cboMaturityAccountType.VisibleRow(false);
      C.txtMaturityAccountTypesNew.VisibleRow(false);
      C.chkMaturityReinvestmentCommonClient.VisibleRow(false);

      C.lblMaturityRepaymentDetails.VisibleRow(false);
      C.lstMaturityPaymentAvailableTypes.VisibleRow(false);
      C.cboMaturityPaymentType.VisibleRow(false);
      C.txtMaturityAccountTypesTransfer.VisibleRow(false);
      C.chkMaturityTransferCommonClient.VisibleRow(false);
      break;
  }

  // Controls (Term Entry Method)
  switch(TermEntryMethod) {
    case "NumberOfPayments":
      // ==================
      // Number of Payments
      // ==================
      C.lblTermDefault.VisibleRow(false);
      C.cboTerm.VisibleRow(false);
      C.dateTermOnDate.VisibleRow(false);
      C.txtTermList.VisibleRow(false);
      C.chkTermLimitToList.VisibleRow(false);

      C.lblTermNumberOfPayments.VisibleRow(true);
      C.numTermNumberOfPayments.VisibleRow(true);
      break;

    case "Term":
      // ====
      // Term
      // ====
      C.lblTermNumberOfPayments.VisibleRow(false);
      C.numTermNumberOfPayments.VisibleRow(false);

      switch (AccountClass) {
        case "Deposit":
          // Deposits
          if(C.chkTermOnCall.Value()) {
            // On Call
            //C.cboTerm.ListFromCsvString("On Call,On Date,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
            //C.cboTerm.ListOtherFromCsvString("On Call,On Date"); // For validation
            //C.txtTermList.BlankTip("On Date,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
          }
          else {
            // Other
            C.cboTerm.ListFromCsvString("On Date,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
            C.cboTerm.ListOtherFromCsvString("On Date"); // For validation
            C.txtTermList.BlankTip("On Date,1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
          }
          break;

        case "LoanFR":
        case "LoanFT":
          // Fixed Term Loan/ Floating Rate Loan
          C.lblTermDefault.VisibleRow(true);
          C.cboTerm.VisibleRow(true);
          C.dateTermOnDate.VisibleRow(C.cboTerm.Text() == "On Date");
          C.txtTermList.VisibleRow(true);
          C.chkTermLimitToList.VisibleRow(true);

          C.cboTerm.ListFromCsvString("1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
          C.txtTermList.BlankTip("1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
          break;

        case "LoanRC":
          // Revolving Credit Loan
          C.cboTerm.ListFromCsvString("1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
          C.txtTermList.BlankTip("1 Month,2 Months,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
          break;
      }
      break;
  }

  // Controls

}

// ==============
// pageAccounting
// ==============
function pageAccounting_Refresh() {
  // Accounting
  if (mRecord_ElementLinks) {
    // Certain Documents need to be mandatory based on other properties
    for (var i = 0; i &lt; mRecord_ElementLinks.length; i++) {
      var item = mRecord_ElementLinks[i];

      switch(item.ElementLinkType) {
        case "DefaultFee":
          // Get Default Fee Charge Basis
          var FeeChargeBasis = "";
          if (C.cboDefaultFeeChargeBasis.ListIndex() != -1) FeeChargeBasis = mRecord.DefaultFeeChargeBasisList[C.cboDefaultFeeChargeBasis.ListIndex()].Code;
          if (!FeeChargeBasis) FeeChargeBasis = "None";
        
          // Default Fee      
          item.Mandatory = (FeeChargeBasis != "None");
          break;
          
        case "FacilityFee":
          // Get Facility Fee Charge Basis
          var FeeChargeBasis = "";
          if (C.cboFacilityFeeChargeBasis.ListIndex() != -1) FeeChargeBasis = mRecord.FacilityFeeChargeBasisList[C.cboFacilityFeeChargeBasis.ListIndex()].Code;
          if (!FeeChargeBasis) FeeChargeBasis = "None";
          
          item.Mandatory = (FeeChargeBasis != "None");
          break;
      }
    }

    // Refresh Grid
    gridElementLinks_Refresh();
  }  
}

// ================
// pageCloseOptions
// ================
function pageCloseOptions_Refresh() {
  // Hide all
  C.lblClosedPending.VisibleRow(false);
  C.chkClosedPendingDefault.VisibleRow(false);
  C.numClosedPendingReviewDays.VisibleRow(false);
  C.chkClosedPendingAutoClose.VisibleRow(false);
  
  C.lblLossCalculationClosing.VisibleRow(false);
  C.cboCloseLossFormula.VisibleRow(false);
  
  C.lblLossCalculationRefinancing.VisibleRow(false);
  C.cboRefinanceLossFormula.VisibleRow(false);
  
  C.lblSmallBalanceWriteOff.VisibleRow(false);
  C.numSmallBalanceWriteOffDebit.VisibleRow(false);
  C.numSmallBalanceWriteOffCredit.VisibleRow(false);
  C.numSmallBalanceRefundCredit.VisibleRow(false);
  C.chkOptionAutomaticClose.VisibleRow(false);
  C.chkOptionAutomaticClosePreMaturity.VisibleRow(false);

  // Lists
  if (mRecord_AccountClassData) {
    C.cboCloseLossFormula.ListFromCsvString(mRecord_AccountClassData.AccountCloseLossFormulaList);
    C.cboRefinanceLossFormula.ListFromCsvString(mRecord_AccountClassData.AccountCloseLossFormulaList);
  }
  
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;
  
  // Show controls based upon Account Class
  switch (AccountClass) {
    case "Disbursement":
      C.lblClosedPending.VisibleRow(true);
      C.chkClosedPendingDefault.VisibleRow(true);
      C.numClosedPendingReviewDays.VisibleRow(true);
      break;
      
    case "Deposit":
      C.lblClosedPending.VisibleRow(true);
      C.chkClosedPendingDefault.VisibleRow(true);
      C.numClosedPendingReviewDays.VisibleRow(true);
      C.chkClosedPendingAutoClose.VisibleRow(true);
      break;  
      
    case "LoanFR":
    case "LoanFT":
      C.lblClosedPending.VisibleRow(true);
      C.chkClosedPendingDefault.VisibleRow(true);
      C.numClosedPendingReviewDays.VisibleRow(true);
      C.chkClosedPendingAutoClose.VisibleRow(true);
      
      C.lblLossCalculationClosing.VisibleRow(true);
      C.cboCloseLossFormula.VisibleRow(true);
      
      C.lblLossCalculationRefinancing.VisibleRow(true);
      C.cboRefinanceLossFormula.VisibleRow(true);
      
      C.lblSmallBalanceWriteOff.VisibleRow(true);
      C.numSmallBalanceWriteOffDebit.VisibleRow(true);
      C.numSmallBalanceWriteOffCredit.VisibleRow(true);
      C.numSmallBalanceRefundCredit.VisibleRow(true);
      C.chkOptionAutomaticClose.VisibleRow(true);
      C.chkOptionAutomaticClosePreMaturity.VisibleRow(true);
      break;
      
    case "LoanRC":
      C.lblClosedPending.VisibleRow(true);
      C.chkClosedPendingDefault.VisibleRow(true);
      C.numClosedPendingReviewDays.VisibleRow(true);
      C.chkClosedPendingAutoClose.VisibleRow(true);
      
      C.lblLossCalculationClosing.VisibleRow(true);
      C.cboCloseLossFormula.VisibleRow(true);
      
      C.lblLossCalculationRefinancing.VisibleRow(true);
      C.cboRefinanceLossFormula.VisibleRow(true);
      break;
  }
  
  // Update Controls
  chkOptionAutomaticClose_Change();
}

// ============
// pageDefaults
// ============
function pageDefaults_Refresh() {  
  // Default Fee Ignore Limit Visibility
  // Get Credit Type
  var CreditType = "";
  if (C.cboCreditType.ListIndex() != -1) CreditType = mRecord.CreditTypeList[C.cboCreditType.ListIndex()].Code;
  
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;
  
  // Get Account Consumer Regulation Type
  var AccountConsumerRegulationType = "";
  if (C.cboConsumerRegulationType.ListIndex() != -1) AccountConsumerRegulationType = mRecord.ConsumerRegulationTypeList[C.cboConsumerRegulationType.ListIndex()].Code;
    
  C.chkDefaultFeeIgnoreLimit.VisibleRow(CreditType == "Consumer" &amp;&amp; AccountClass == "LoanFT" &amp;&amp; AccountConsumerRegulationType == "NZ_HighCostConsumerCreditContract");
  
  // Update Controls
  chkDefaultInterestPostMaturity_Change();
  cboDefaultInterestOverdueBasis_Change();
  cboDefaultInterestOverdueChargeBasis_Change();
  cboDefaultFeeChargeBasis_Change();
  cboFacilityFeeChargeBasis_Change();
}

// =============
// pageDocuments
// =============
function pageDocuments_Refresh() {
  if (!mRecord) return;

  // Document Links
  if (mRecord_DocumentLinks) {
    // Certain Documents need to be mandatory based on other properties
    for (var i = 0; i &lt; mRecord_DocumentLinks.length; i++) {
      var item = mRecord_DocumentLinks[i];

      switch(item.DocumentLinkType) {
        case "Statement":
          // Statement          
          item.Mandatory = C.chkStatementUse.Value();
          break;
      }
    }

    gridDocumentLinks_Refresh();
  }

  // Available Documents
  if (mRecord_Documents) {
    gridDocuments_Refresh();
  }
}

// ===============
// pageUserDefined
// ===============
function pageUserDefined_Refresh() {
  if (!mRecord) return;

  // Controls
}

// ===============
// cboAccountClass
// ===============
function cboAccountClass_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Get Account Class-specific information
  if (C.cboAccountClass.Text()) {
    widget.GetString("GetAccountClassDetails", { accountClassText: C.cboAccountClass.Text() },
      function (data) {
        // Parse
        mRecord_AccountClassData = JSON.parse(data);
        
        // Document Links - only update if its changed
        if (JSON.stringify(mRecord_DocumentLinks) != JSON.stringify(mRecord_AccountClassData.AccountTypeDocumentLinks)) {
          mRecord_DocumentLinks = mRecord_AccountClassData.AccountTypeDocumentLinks;

          // Refresh Grid (even if only for validation)
          pageDocuments_Refresh();
        }        

        // Element Links
        if (JSON.stringify(mRecord_ElementLinks) != JSON.stringify(mRecord_AccountClassData.ElementLinks)) {
          mRecord_ElementLinks = mRecord_AccountClassData.ElementLinks

          // Refresh Grid (even if only for validation)
          pageAccounting_Refresh();
        }

        // Refresh Pages and Controls based on the selected Account Class
        AccountClass_PagesRefresh();
        AccountClass_ControlsUpdate();
      },

      function (error) {
        widget.UI.MsgBoxAlert(error);
      }
    );
  }
}

// ================================
// Account Class Pages and Controls
// ================================
function AccountClass_PagesRefresh() {
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;

  // Enable/ disable pages
  if (!mRecord.HideOtherPages) {
    switch (AccountClass) {
      case "Current":
        tabDetails.TabVisible("Term", false);
        tabDetails.TabVisible("Payments", false);
        tabDetails.TabVisible("Interest", mRecord.AllowPageInterest);
        tabDetails.TabVisible("InterestOptions", mRecord.AllowPageInterestOptions);
        tabDetails.TabVisible("RateTables", mRecord.AllowPageRateTables);
        tabDetails.TabVisible("Defaults", mRecord.AllowPageDefaults);
        tabDetails.TabVisible("CreditLimit", false);
        tabDetails.TabVisible("Promotions", mRecord.AllowPagePromotions);            
        break;
  
      case "Deposit":
        tabDetails.TabVisible("Term", mRecord.AllowPageTerm);
        tabDetails.TabVisible("Payments", false);
        tabDetails.TabVisible("Interest", mRecord.AllowPageInterest);
        tabDetails.TabVisible("InterestOptions", mRecord.AllowPageInterestOptions);
        tabDetails.TabVisible("RateTables", mRecord.AllowPageRateTables);
        tabDetails.TabVisible("Defaults", false);
        tabDetails.TabVisible("CreditLimit", false);
        tabDetails.TabVisible("Promotions", mRecord.AllowPagePromotions);
        break;
  
      case "Disbursement":
        tabDetails.TabVisible("Term", false);
        tabDetails.TabVisible("Payments", mRecord.AllowPagePayments);
        tabDetails.TabVisible("Interest", false);
        tabDetails.TabVisible("InterestOptions", false);
        tabDetails.TabVisible("RateTables", false);
        tabDetails.TabVisible("Defaults", false);
        tabDetails.TabVisible("CreditLimit", false);
        tabDetails.TabVisible("Promotions", false);
        break;
  
      case "LoanFR":
        tabDetails.TabVisible("Term", mRecord.AllowPageTerm);
        tabDetails.TabVisible("Payments", mRecord.AllowPagePayments);
        tabDetails.TabVisible("Interest", mRecord.AllowPageInterest);
        tabDetails.TabVisible("InterestOptions", mRecord.AllowPageInterestOptions);
        tabDetails.TabVisible("RateTables", mRecord.AllowPageRateTables);
        tabDetails.TabVisible("Defaults", mRecord.AllowPageDefaults);
        tabDetails.TabVisible("CreditLimit", mRecord.AllowPageCreditLimit);
        tabDetails.TabVisible("Promotions", mRecord.AllowPagePromotions);
        break;
  
      case "LoanFT":
        tabDetails.TabVisible("Term", mRecord.AllowPageTerm);
        tabDetails.TabVisible("Payments", mRecord.AllowPagePayments);
        tabDetails.TabVisible("Interest", mRecord.AllowPageInterest);
        tabDetails.TabVisible("InterestOptions", mRecord.AllowPageInterestOptions);
        tabDetails.TabVisible("RateTables", false);
        tabDetails.TabVisible("Defaults", mRecord.AllowPageDefaults);
        tabDetails.TabVisible("CreditLimit", mRecord.AllowPageCreditLimit);
        tabDetails.TabVisible("Promotions", mRecord.AllowPagePromotions);
        break;
  
      case "LoanRC":
        tabDetails.TabVisible("Term", mRecord.AllowPageTerm);
        tabDetails.TabVisible("Payments", mRecord.AllowPagePayments);
        tabDetails.TabVisible("Interest", mRecord.AllowPageInterest);
        tabDetails.TabVisible("InterestOptions", mRecord.AllowPageInterestOptions);
        tabDetails.TabVisible("RateTables", mRecord.AllowPageRateTables);
        tabDetails.TabVisible("Defaults", mRecord.AllowPageDefaults);
        tabDetails.TabVisible("CreditLimit", mRecord.AllowPageCreditLimit);
        tabDetails.TabVisible("Promotions", mRecord.AllowPagePromotions);
        break;
  
      default:
        tabDetails.TabVisible("Term", false);
        tabDetails.TabVisible("Payments", false);
        tabDetails.TabVisible("Interest", false);
        tabDetails.TabVisible("InterestOptions", false);
        tabDetails.TabVisible("RateTables", false);
        tabDetails.TabVisible("Defaults", false);
        tabDetails.TabVisible("CreditLimit", false);
        tabDetails.TabVisible("Promotions", false);
        break;
    }
  }  
  
  // User Defined special handling
  var showUserDefined = true;
  if (showUserDefined &amp;&amp; !mRecord.AllowPageUserDefined) showUserDefined = false;
  if (showUserDefined &amp;&amp; mRecord.HideOtherPages &amp;&amp; mRecord.PageId &amp;&amp; mRecord.PageId != "UserDefined") showUserDefined = false;
  if (showUserDefined &amp;&amp; !mRecord_AccountClassData) showUserDefined = false;
  if (showUserDefined &amp;&amp; !mRecord_AccountClassData.UserDefinedParameters) showUserDefined = false;
  if (showUserDefined &amp;&amp; mRecord_AccountClassData.UserDefinedParameters.length == 0) showUserDefined = false;
  
  // Update Page
  if (showUserDefined) {
    tabDetails.TabVisible("UserDefined", true);
    
    // Update Controls
    C.phUserDefined.Initialise(mRecord_AccountClassData.UserDefinedParameters);
    C.phUserDefined.UpdateParameterValues(JSON.parse(mRecord.UserDataJson));
  }
  else {
    tabDetails.TabVisible("UserDefined", false);
  }    
  
  // *** Moved here from Record_Load_Done ***
  if (!mOriginalJson) {
    // Save Fields (so UserData is in correct format for mOriginalJson)
    Fields_Save();
  
    // Save original JSON for Form_IsDirty
    mOriginalJson = JSON.stringify(mRecord);
  }  
}

function AccountClass_ControlsUpdate() {
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;

  // Show/ Hide controls
  switch (AccountClass) {
    case "Deposit":
      // =======
      // Deposit
      // =======
      // General
      C.lblGeneralOtherOptions.VisibleRow(false);
      C.chkCreditSale.VisibleRow(false);
      C.chkLaybySale.VisibleRow(false);

      // New Accounts
      C.chkOptionAllowFirstPaymentDate.VisibleRow(false);
      C.chkOptionAllowRegularPayment.VisibleRow(false);
      C.chkOptionAllowBalloonPayment.VisibleRow(false);
      C.chkOptionAllowResidualValue.VisibleRow(false);
      C.chkOptionAllowMaturityDate.VisibleRow(false);
      C.chkOptionAllowMaturityInstruction.VisibleRow(true);
      C.chkOptionAllowMinimumPayment.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentDueDays.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentHoldTo.VisibleRow(false);
      C.chkOptionAllowTaxCategory.VisibleRow(true);
      C.chkOptionAllowInterestCycle.VisibleRow(true);
      C.chkOptionAllowInterest.VisibleRow(true);
      C.chkOptionAllowStartupInterest.VisibleRow(true);
      C.chkOptionAllowTotalInterest.VisibleRow(false);
      C.chkOptionAllowReviewDate.VisibleRow(true);
      chkOptionAllowReviewDate_Change();

      C.trFinancialPageOptions.hide();
      C.chkShowFinancialPageOverridingPaymentsTab.VisibleRow(false);
      C.chkShowFinancialPageOptionsTab.VisibleRow(false);
      C.chkShowInstalmentsDrilldown.VisibleRow(false);
      C.chkShowInstalmentsDrilldownWeb.VisibleRow(false);

      C.chkShowFinancialPagePrintQuotation.VisibleRow(false);
      C.chkDisbursementsShowInNewAccountWizard.VisibleRow(mRecord.AddOnDisbursements);

      C.chkOptionDefaultResidualValueFromNetAdvance.VisibleRow(false);
      C.chkOptionDefaultResidualValueFromSecurities.VisibleRow(false);
      C.chkOptionDefaultPrintContractDocument.Caption("Print Deposit Certificate Document");
      C.chkOptionDefaultPrintContractDocument.VisibleRow(true);

      C.lblNetAdvanceLimits.VisibleRow(false);
      C.numNetAdvanceMinimum.VisibleRow(false);
      C.numNetAdvanceMaximum.VisibleRow(false);

      // Term
      // NOTE: Updated in pageTerm_Refresh
      break;

    case "Disbursement":
      // ============
      // Disbursement
      // ============
      // General
      C.lblGeneralOtherOptions.VisibleRow(false);
      C.chkCreditSale.VisibleRow(false);
      C.chkLaybySale.VisibleRow(false);

      // New Accounts
      C.chkOptionAllowFirstPaymentDate.VisibleRow(false);
      C.chkOptionAllowRegularPayment.VisibleRow(false);
      C.chkOptionAllowBalloonPayment.VisibleRow(false);
      C.chkOptionAllowResidualValue.VisibleRow(false);
      C.chkOptionAllowMaturityDate.VisibleRow(false);
      C.chkOptionAllowMaturityInstruction.VisibleRow(false);
      C.chkOptionAllowMinimumPayment.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentDueDays.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentHoldTo.VisibleRow(false);
      C.chkOptionAllowTaxCategory.VisibleRow(false);
      C.chkOptionAllowInterestCycle.VisibleRow(false);
      C.chkOptionAllowInterest.VisibleRow(false);
      C.chkOptionAllowStartupInterest.VisibleRow(false);
      C.chkOptionAllowTotalInterest.VisibleRow(false);
      C.chkOptionAllowReviewDate.VisibleRow(true);
      chkOptionAllowReviewDate_Change();

      C.trFinancialPageOptions.hide();
      C.chkShowFinancialPageOverridingPaymentsTab.VisibleRow(false);
      C.chkShowFinancialPageOptionsTab.VisibleRow(false);
      C.chkShowInstalmentsDrilldown.VisibleRow(false);
      C.chkShowInstalmentsDrilldownWeb.VisibleRow(false);

      C.chkShowFinancialPagePrintQuotation.VisibleRow(false);
      C.chkDisbursementsShowInNewAccountWizard.VisibleRow(false);

      C.chkOptionDefaultResidualValueFromNetAdvance.VisibleRow(false);
      C.chkOptionDefaultResidualValueFromSecurities.VisibleRow(false);
      C.chkOptionDefaultPrintContractDocument.Caption("Print Contract Document");
      C.chkOptionDefaultPrintContractDocument.VisibleRow(false);

      C.lblNetAdvanceLimits.VisibleRow(false);
      C.numNetAdvanceMinimum.VisibleRow(false);
      C.numNetAdvanceMaximum.VisibleRow(false);

      // Term
      // NOTE: page not displayed
      break;

    case "LoanFR":
      // ==================
      // Floating Rate Loan
      // ==================
      // General
      C.lblGeneralOtherOptions.VisibleRow(true);
      C.chkCreditSale.VisibleRow(true);
      C.chkLaybySale.VisibleRow(true);

      // New Accounts
      C.chkOptionAllowFirstPaymentDate.VisibleRow(true);
      C.chkOptionAllowRegularPayment.VisibleRow(true);
      C.chkOptionAllowBalloonPayment.VisibleRow(true);
      C.chkOptionAllowResidualValue.VisibleRow(true);
      C.chkOptionAllowMaturityDate.VisibleRow(false);
      C.chkOptionAllowMaturityInstruction.VisibleRow(false);
      C.chkOptionAllowMinimumPayment.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentDueDays.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentHoldTo.VisibleRow(false);
      C.chkOptionAllowTaxCategory.VisibleRow(false);
      C.chkOptionAllowInterestCycle.VisibleRow(true);
      C.chkOptionAllowInterest.VisibleRow(true);
      C.chkOptionAllowStartupInterest.VisibleRow(true);
      C.chkOptionAllowTotalInterest.VisibleRow(true);
      C.chkOptionAllowReviewDate.VisibleRow(true);
      chkOptionAllowReviewDate_Change();

      C.trFinancialPageOptions.show();
      C.chkShowFinancialPageOverridingPaymentsTab.VisibleRow(true);
      C.chkShowFinancialPageOptionsTab.VisibleRow(true);
      C.chkShowInstalmentsDrilldown.VisibleRow(true);
      chkShowInstalmentsDrilldown_Change();

      C.chkShowFinancialPagePrintQuotation.VisibleRow(true);
      C.chkDisbursementsShowInNewAccountWizard.VisibleRow(mRecord.AddOnDisbursements);

      C.chkOptionDefaultResidualValueFromNetAdvance.VisibleRow(true);
      C.chkOptionDefaultResidualValueFromSecurities.VisibleRow(mRecord.AddOnSecurityRegister);
      C.chkOptionDefaultPrintContractDocument.Caption("Print Contract Document");
      C.chkOptionDefaultPrintContractDocument.VisibleRow(true);

      C.lblNetAdvanceLimits.VisibleRow(true);
      C.numNetAdvanceMinimum.VisibleRow(true);
      C.numNetAdvanceMaximum.VisibleRow(true);

      // Term
      // NOTE: Updated in pageTerm_Refresh
      break;

    case "LoanFT":
      // ===============
      // Fixed Term Loan
      // ===============
      // General
      C.lblGeneralOtherOptions.VisibleRow(true);
      C.chkCreditSale.VisibleRow(true);
      C.chkLaybySale.VisibleRow(true);

      // New Accounts
      C.chkOptionAllowFirstPaymentDate.VisibleRow(true);
      C.chkOptionAllowRegularPayment.VisibleRow(true);
      C.chkOptionAllowBalloonPayment.VisibleRow(true);
      C.chkOptionAllowResidualValue.VisibleRow(true);
      C.chkOptionAllowMaturityDate.VisibleRow(false);
      C.chkOptionAllowMaturityInstruction.VisibleRow(false);
      C.chkOptionAllowMinimumPayment.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentDueDays.VisibleRow(false);
      C.chkOptionAllowMinimumPaymentHoldTo.VisibleRow(false);
      C.chkOptionAllowTaxCategory.VisibleRow(false);
      C.chkOptionAllowInterestCycle.VisibleRow(true);
      C.chkOptionAllowInterest.VisibleRow(true);
      C.chkOptionAllowStartupInterest.VisibleRow(true);
      C.chkOptionAllowTotalInterest.VisibleRow(true);
      C.chkOptionAllowReviewDate.VisibleRow(true);
      chkOptionAllowReviewDate_Change();

      C.trFinancialPageOptions.show();
      C.chkShowFinancialPageOverridingPaymentsTab.VisibleRow(true);
      C.chkShowFinancialPageOptionsTab.VisibleRow(true);
      C.chkShowInstalmentsDrilldown.VisibleRow(true);
      chkShowInstalmentsDrilldown_Change();

      C.chkShowFinancialPagePrintQuotation.VisibleRow(true);
      C.chkDisbursementsShowInNewAccountWizard.VisibleRow(mRecord.AddOnDisbursements);

      C.chkOptionDefaultResidualValueFromNetAdvance.VisibleRow(true);
      C.chkOptionDefaultResidualValueFromSecurities.VisibleRow(mRecord.AddOnSecurityRegister);
      C.chkOptionDefaultPrintContractDocument.Caption("Print Contract Document");
      C.chkOptionDefaultPrintContractDocument.VisibleRow(true);

      C.lblNetAdvanceLimits.VisibleRow(true);
      C.numNetAdvanceMinimum.VisibleRow(true);
      C.numNetAdvanceMaximum.VisibleRow(true);

      // Term
      // NOTE: Updated in pageTerm_Refresh
      break;

    case "LoanRC":
      // =====================
      // Revolving Credit Loan
      // =====================
      // General
      C.lblGeneralOtherOptions.VisibleRow(true);
      C.chkCreditSale.VisibleRow(true);
      C.chkLaybySale.VisibleRow(true);

      // New Accounts
      C.chkOptionAllowFirstPaymentDate.VisibleRow(false);
      C.chkOptionAllowRegularPayment.VisibleRow(false);
      C.chkOptionAllowBalloonPayment.VisibleRow(false);
      C.chkOptionAllowResidualValue.VisibleRow(false);
      C.chkOptionAllowMaturityDate.VisibleRow(true);
      C.chkOptionAllowMaturityInstruction.VisibleRow(false);
      C.chkOptionAllowMinimumPayment.VisibleRow(true);
      C.chkOptionAllowMinimumPaymentDueDays.VisibleRow(true);
      C.chkOptionAllowMinimumPaymentHoldTo.VisibleRow(true);
      C.chkOptionAllowTaxCategory.VisibleRow(false);
      C.chkOptionAllowInterestCycle.VisibleRow(true);
      C.chkOptionAllowInterest.VisibleRow(true);
      C.chkOptionAllowStartupInterest.VisibleRow(true);
      C.chkOptionAllowTotalInterest.VisibleRow(false);
      C.chkOptionAllowReviewDate.VisibleRow(true);
      chkOptionAllowReviewDate_Change();

      C.trFinancialPageOptions.show();
      C.chkShowFinancialPageOverridingPaymentsTab.VisibleRow(false);
      C.chkShowFinancialPageOptionsTab.VisibleRow(true);
      C.chkShowInstalmentsDrilldown.VisibleRow(false);
      C.chkShowInstalmentsDrilldownWeb.VisibleRow(false);

      C.chkShowFinancialPagePrintQuotation.VisibleRow(false);
      C.chkDisbursementsShowInNewAccountWizard.VisibleRow(mRecord.AddOnDisbursements);

      C.chkOptionDefaultResidualValueFromNetAdvance.VisibleRow(false);
      C.chkOptionDefaultResidualValueFromSecurities.VisibleRow(false);
      C.chkOptionDefaultPrintContractDocument.Caption("Print Contract Document");
      C.chkOptionDefaultPrintContractDocument.VisibleRow(true);

      C.lblNetAdvanceLimits.VisibleRow(false);
      C.numNetAdvanceMinimum.VisibleRow(false);
      C.numNetAdvanceMaximum.VisibleRow(false);

      // Term
      // NOTE: Updated in pageTerm_Refresh
      break;

    default:
      break;
  }
}

// ===================
// cboCreditLimitCount
// ===================
function cboCreditLimitCount_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Credit Limit Count
  var CreditLimitCount = GetCreditLimitCount();
  
  // Update Controls
  C.chkCreditLimitKeepOnRefinance.VisibleRow(CreditLimitCount &gt; 0);
  C.chkCreditLimitUsePendingWithdrawals.VisibleRow(CreditLimitCount &gt; 0);
  C.chkCreditLimitUseUnclearedFunds.VisibleRow(CreditLimitCount &gt; 0);
  C.chkCreditLimitUseOtherDeductions.VisibleRow(CreditLimitCount &gt; 0);  
  
  C.lblCreditLimit1.VisibleRow(CreditLimitCount &gt; 0);
  C.txtCreditLimit1Description.VisibleRow(CreditLimitCount &gt; 0);
  C.numCreditLimit1.VisibleRow(CreditLimitCount &gt; 0);
  
  C.lblCreditLimit2.VisibleRow(CreditLimitCount &gt; 1);
  C.txtCreditLimit2Description.VisibleRow(CreditLimitCount &gt; 1);
  C.numCreditLimit2.VisibleRow(CreditLimitCount &gt; 1);
  
  C.lblCreditLimit3.VisibleRow(CreditLimitCount &gt; 2);
  C.txtCreditLimit3Description.VisibleRow(CreditLimitCount &gt; 2);
  C.numCreditLimit3.VisibleRow(CreditLimitCount &gt; 2);
  
  C.lblOverLimitDefault.VisibleRow(CreditLimitCount &gt; 0);
  C.cboOverLimitBasis.VisibleRow(CreditLimitCount &gt; 0);
  C.numOverLimitThresholdPercent.VisibleRow(CreditLimitCount &gt; 0);
  C.numOverLimitThreshold.VisibleRow(CreditLimitCount &gt; 0);
  
  C.lblOverLimitFee.VisibleRow(CreditLimitCount &gt; 0);
  C.cboOverLimitFeeChargeBasis.VisibleRow(CreditLimitCount &gt; 0);
  
  chkCreditLimitUseOtherDeductions_Change();
  cboOverLimitBasis_Change();
}

// ================================
// chkCreditLimitUseOtherDeductions
// ================================
function chkCreditLimitUseOtherDeductions_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Update Controls
  if (GetCreditLimitCount() &gt; 0 &amp;&amp; C.chkCreditLimitUseOtherDeductions.Value()) {
    C.txtCreditLimitOtherDeductionsDescription.VisibleRow(true);
  }
  else {
    C.txtCreditLimitOtherDeductionsDescription.VisibleRow(false);
  }
}

// ==============================
// chkDefaultInterestPostMaturity
// ==============================
function chkDefaultInterestPostMaturity_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  C.chkDefaultInterestPostFinalDate.VisibleRow(C.chkDefaultInterestPostMaturity.Value());
}

// ======================
// cboMinimumPaymentBasis
// ======================
function cboMinimumPaymentBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Get Over Limit Basis
  var MinimumPaymentBasis = "";
  if (C.cboMinimumPaymentBasis.ListIndex() != -1) MinimumPaymentBasis = mRecord.MinimumPaymentBasisList[C.cboMinimumPaymentBasis.ListIndex()].Code;
  if (!MinimumPaymentBasis) MinimumPaymentBasis = "None";
  
  // Update Controls
  switch (MinimumPaymentBasis) {
    case "Instalment":
    case "InterestAndFeesBalance":
    case "InterestAndFeesOnly":
    case "InterestBalance":
    case "InterestOnly":
    case "None":
      C.numMinimumPaymentValue.VisibleRow(false);
      C.numMinimumPaymentPercent.VisibleRow(false);
      break;
      
    case "OngoingSetValue":
    case "SetValue":
      C.numMinimumPaymentValue.VisibleRow(true);
      C.numMinimumPaymentPercent.VisibleRow(false);
      break;
      
    case "PercentOfBalance":
      C.numMinimumPaymentValue.VisibleRow(false);
      C.numMinimumPaymentPercent.VisibleRow(true);
      break;
      
    default:
      C.numMinimumPaymentValue.VisibleRow(true);
      C.numMinimumPaymentPercent.VisibleRow(true);
      break;
  }
}

// =============================
// cboMinimumPaymentHoldToPeriod
// =============================
function cboMinimumPaymentHoldToPeriod_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  C.dateMinimumPaymentHoldToDate.Visible(C.cboMinimumPaymentHoldToPeriod.Text() == "On Date");
}

// ===========================
// cboOptionInterestBackdating
// ===========================
function cboOptionInterestBackdating_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Get Backdating Setting
  var Backdating = "";
  if (C.cboOptionInterestBackdating.ListIndex() != -1) Backdating = mRecord.InterestBackdatingList[C.cboOptionInterestBackdating.ListIndex()].Code;
  if (!Backdating) Backdating = "None";
  
  // Update Controls
  C.chkOptionInterestBackdatingConvertedTransactions.Visible(Backdating == "Reverse");
}

// ====================
// cboOtherInterestType
// ====================
function cboOtherInterestType_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;  
  
  // Get Other Interest Type
  var OtherInterestType = "";
  if (C.cboOtherInterestType.ListIndex() != -1) OtherInterestType = mRecord.OtherInterestTypeList[C.cboOtherInterestType.ListIndex()].Code;
  if (!OtherInterestType) OtherInterestType = "NotApplicable";
  
  // Update Controls
  C.numOtherInterestRate.VisibleRow(OtherInterestType != "NotApplicable");
  C.txtOtherInterestDescription.VisibleRow(OtherInterestType != "NotApplicable");
}

// =================
// cboOverLimitBasis
// =================
function cboOverLimitBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Credit Limit Count
  var CreditLimitCount = GetCreditLimitCount();
  
  // Get Over Limit Basis
  var OverLimitBasis = "";
  if (C.cboOverLimitBasis.ListIndex() != -1) OverLimitBasis = mRecord.OverLimitBasisList[C.cboOverLimitBasis.ListIndex()].Code;
  if (!OverLimitBasis) OverLimitBasis = "None";
  
  // Update Controls
  C.numOverLimitThresholdPercent.VisibleRow(CreditLimitCount &gt; 0 &amp;&amp; OverLimitBasis != "None");
  C.numOverLimitThreshold.VisibleRow(CreditLimitCount &gt; 0 &amp;&amp; OverLimitBasis != "None");
  C.lblOverLimitFee.VisibleRow(CreditLimitCount &gt; 0 &amp;&amp; OverLimitBasis != "None");
  C.cboOverLimitFeeChargeBasis.VisibleRow(CreditLimitCount &gt; 0 &amp;&amp; OverLimitBasis != "None");
  C.numOverLimitFeeValue.VisibleRow(CreditLimitCount &gt; 0 &amp;&amp; OverLimitBasis != "None");
  
  cboOverLimitFeeChargeBasis_Change();
}

// ====================
// cboOverLimitFeeChargeBasis
// ====================
function cboOverLimitFeeChargeBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Get Over Limit Basis
  var OverLimitBasis = "";
  if (C.cboOverLimitBasis.ListIndex() != -1) OverLimitBasis = mRecord.OverLimitBasisList[C.cboOverLimitBasis.ListIndex()].Code;
  if (!OverLimitBasis) OverLimitBasis = "None";
  
  // Get Over Limit Fee Charge Basis
  var OverLimitFeeChargeBasis = "";
  if (C.cboOverLimitFeeChargeBasis.ListIndex() != -1) OverLimitFeeChargeBasis = mRecord.OverLimitFeeBasisList[C.cboOverLimitFeeChargeBasis.ListIndex()].Code;
  if (!OverLimitFeeChargeBasis) OverLimitFeeChargeBasis = "None";
  
  // Update Controls
  if (OverLimitBasis == "None" || OverLimitFeeChargeBasis == "None" || GetCreditLimitCount() == 0) {
    C.numOverLimitFeeValue.VisibleRow(false);
  }
  else {
    C.numOverLimitFeeValue.VisibleRow(true);
  }
}

function GetCreditLimitCount() {
  var CreditLimitCount = 0;
  switch (C.cboCreditLimitCount.Text()) {
    case "1":
    case "2":
    case "3":
      CreditLimitCount = Number(C.cboCreditLimitCount.Text());
      break;
  }
  
  return CreditLimitCount;
}

// =============
// cboCreditType
// =============
function cboCreditType_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;    
  
  // Get Credit Type
  var CreditType = "";
  if (C.cboCreditType.ListIndex() != -1) CreditType = mRecord.CreditTypeList[C.cboCreditType.ListIndex()].Code;
  
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;
  
  // Update Controls
  C.cboConsumerRegulationType.VisibleRow(CreditType == "Consumer" &amp;&amp; AccountClass == "LoanFT");
}

// ====================================
// cboDefaultInterestOverdueChargeBasis
// ====================================
function cboDefaultInterestOverdueChargeBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Mandatory Element Links
  pageAccounting_Refresh();
}

// ========================
// cboDefaultFeeChargeBasis
// ========================
function cboDefaultFeeChargeBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Get Default Fee Charge Basis
  var FeeChargeBasis = "";
  if (C.cboDefaultFeeChargeBasis.ListIndex() != -1) FeeChargeBasis = mRecord.DefaultFeeChargeBasisList[C.cboDefaultFeeChargeBasis.ListIndex()].Code;
  if (!FeeChargeBasis) FeeChargeBasis = "None";
  
  // Update Controls
  C.numDefaultFeeValue.VisibleRow(FeeChargeBasis != "None");
  
  // Update Mandatory Element Links
  pageAccounting_Refresh();
}

// ==============================
// cboDefaultInterestOverdueBasis
// ==============================
function cboDefaultInterestOverdueBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Get initial values
  var defaultInterestOverdueChargeBasis = C.cboDefaultInterestOverdueChargeBasis.Text();
  
  // Get Default Interest Overdue Basis
  var DefaultOverdueBasis = "";
  if (C.cboDefaultInterestOverdueBasis.ListIndex() != -1) DefaultOverdueBasis = mRecord.DefaultInterestOverdueBasisList[C.cboDefaultInterestOverdueBasis.ListIndex()].Code;
  
  // Update Controls
  switch (DefaultOverdueBasis) {
    case "ContractualOverdue":
      C.numDefaultInterestOverdueThreshold.VisibleRow(true);
      C.cboDefaultInterestOverdueChargeBasis.VisibleRow(true);
      C.cboDefaultInterestOverdueChargeBasis.ListFromCsvString("Balance,Contractual Overdue");
      if (defaultInterestOverdueChargeBasis != "Balance") C.cboDefaultInterestOverdueChargeBasis.Text("Contractual Overdue");
      break;
    
    case "None":
      C.numDefaultInterestOverdueThreshold.VisibleRow(false);
      C.cboDefaultInterestOverdueChargeBasis.VisibleRow(false);
      break;
      
    case "Overdue":
      C.numDefaultInterestOverdueThreshold.VisibleRow(true);
      C.cboDefaultInterestOverdueChargeBasis.VisibleRow(true);
      C.cboDefaultInterestOverdueChargeBasis.ListFromCsvString("Balance,Overdue");
      if (defaultInterestOverdueChargeBasis != "Balance") C.cboDefaultInterestOverdueChargeBasis.Text("Overdue");
      break;
  }
}

// =========================
// cboFacilityFeeChargeBasis
// =========================
function cboFacilityFeeChargeBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Get Facility Fee Charge Basis
  var FeeChargeBasis = "";
  if (C.cboFacilityFeeChargeBasis.ListIndex() != -1) FeeChargeBasis = mRecord.FacilityFeeChargeBasisList[C.cboFacilityFeeChargeBasis.ListIndex()].Code;
  if (!FeeChargeBasis) FeeChargeBasis = "None";
  
  // Update Controls
  C.numFacilityFeeValue.VisibleRow(FeeChargeBasis != "None");
  C.chkFacilityFeeChargeThresholdApply.VisibleRow(FeeChargeBasis != "None");
  C.numFacilityFeeChargeThresholdValue.VisibleRow(FeeChargeBasis != "None");
  C.chkFacilityFeeChargeIfMovement.VisibleRow(FeeChargeBasis != "None");
}

// =====================
// cboPaymentFirstPeriod
// =====================
function cboPaymentFirstPeriod_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  C.datePaymentFirstDate.Visible(C.cboPaymentFirstPeriod.Text() == "On Date");
}

// ==============
// cboProductType
// ==============
function cboProductType_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Get Product Type-specific information
  if (C.cboProductType.Text()) {
    widget.GetString("GetProductTypeDetails", { productTypeId: C.cboProductType.Text() },
      function (data) {
        // Parse
        mRecord_ProductTypeData = JSON.parse(data);

        // Controls
        C.cboCreditReportingAccountType.SetComboFromInformationList(mRecord_ProductTypeData.CreditReportAccountTypeInformationListId);
        C.cboCategory.SetComboFromInformationList(mRecord_ProductTypeData.CategoryInformationListId);

        // Defaults
        if (mRecord.Pk == 0) {
          if (mRecord_ProductTypeData.DefaultCreditReportAccountType) C.cboCreditReportingAccountType.Text(mRecord_ProductTypeData.DefaultCreditReportAccountType);
          if (mRecord_ProductTypeData.DefaultCategory) C.cboCategory.Text(mRecord_ProductTypeData.DefaultCategory);
        }
      },

      function (error) {
        widget.UI.MsgBoxAlert(error);
      }
    );
  }
}

// =================
// cboPromotionBasis
// =================
function cboPromotionBasis_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  if (C.cboPromotionBasis.Text() == "Does not use Promotions") {
    C.cboPromotionParameterSetUserDefined.VisibleRow(false);
    C.lblPromotions.VisibleRow(false);
    C.trPromotionMessage.hide();
  }
  else {
    C.cboPromotionParameterSetUserDefined.VisibleRow(true);
    C.lblPromotions.VisibleRow(true);
    C.trPromotionMessage.show();
  }
}

// ======================
// chkNegativePaymentMatch
// =======================
function chkNegativePaymentMatch_Change(sender, e) {
  C.numNegativePaymentMatchDays.VisibleRow(C.chkNegativePaymentMatch.Value());
}

// ===========================
// chkOptionAllowRefinanceInto
// ===========================
function chkOptionAllowRefinanceInto_Change(sender, e) {
  C.chkOptionAllowRefinanceRedatedForward.VisibleRow(C.chkOptionAllowRefinanceInto.Value());
}

// ========================
// chkOptionAllowReviewDate
// ========================
function chkOptionAllowReviewDate_Change(sender, e) {
  C.cboDefaultReviewPeriod.VisibleRow(C.chkOptionAllowReviewDate.Value());
}

// =========================
// chkOptionAllowWithdrawals
// =========================
function chkOptionAllowWithdrawals_Change(sender, e) {
  // Get Account Class
  var AccountClass = "";
  if (C.cboAccountClass.ListIndex() != -1) AccountClass = mRecord.AccountClassList[C.cboAccountClass.ListIndex()].Code;

  // Update Controls
  C.chkDepositAllowWithdrawalsNegativeBalance.VisibleRow(C.chkOptionAllowWithdrawals.Value() &amp;&amp; AccountClass == "Deposit");
}

// =======================
// chkOptionAutomaticClose
// =======================
function chkOptionAutomaticClose_Change(sender, e) {
  C.chkOptionAutomaticClosePreMaturity.VisibleRow(C.chkOptionAutomaticClose.Value());
}

// ===========================================
// chkOptionDefaultResidualValueFromNetAdvance
// ===========================================
function chkOptionDefaultResidualValueFromNetAdvance_Change(sender, e) {
  if (e) C.chkOptionDefaultResidualValueFromSecurities.Value(false);
}

// ===========================================
// chkOptionDefaultResidualValueFromSecurities
// ===========================================
function chkOptionDefaultResidualValueFromSecurities_Change(sender, e) {
  if (e) C.chkOptionDefaultResidualValueFromNetAdvance.Value(false);
}

// ================================
// chkOptionInterestChargedOriginal
// ================================
function chkOptionInterestChargedOriginal_Change(sender, e) {
  if (C.chkOptionInterestChargedOriginal.Value()) {
    C.chkOptionInterestChargedUpfront.Value(false);
  }
}

// ===============================
// chkOptionInterestChargedUpfront
// ===============================
function chkOptionInterestChargedUpfront_Change(sender, e) {
  if (C.chkOptionInterestChargedUpfront.Value()) {
    C.chkOptionInterestChargedOriginal.Value(false);
  }
}

// ============================
// chkInterestNegativeRateAllow
// ============================
function chkInterestNegativeRateAllow_Change(sender, e) {
  C.chkInterestNegativeRateTaxNotApplicable.VisibleRow(C.chkInterestNegativeRateAllow.Value());
}

// ============================
// chkOptionInterestPrecomputed
// ============================
function chkOptionInterestPrecomputed_Change(sender, e) {
  C.chkOptionInterestChargedUpfront.ReadOnly(!C.chkOptionInterestPrecomputed.Value());
  C.chkOptionInterestChargedOriginal.ReadOnly(!C.chkOptionInterestPrecomputed.Value());
  C.chkOptionInterestFlatRate.ReadOnly(!C.chkOptionInterestPrecomputed.Value());
  
  // Default Interest Charged Upfront
  if (C.chkOptionInterestPrecomputed.Value()) C.chkOptionInterestChargedUpfront.Value(!C.chkOptionInterestChargedOriginal.Value());
}

// ======================
// chkOptionPaymentsRound
// ======================
function chkOptionPaymentsRound_Change(sender, e) {
  C.numOptionPaymentsRoundMultiple.VisibleRow(C.chkOptionPaymentsRound.Value());
}

// ========================
// chkPaymentGracePeriodUse
// ========================
function chkPaymentGracePeriodUse_Change(sender, e) {
  if (C.chkPaymentGracePeriodUse.Value()) {
    C.numPaymentGracePeriodDays.VisibleRow(true);
    C.chkPaymentGracePeriodChargeDefault.VisibleRow(true);
  }
  else {
    C.numPaymentGracePeriodDays.VisibleRow(false);
    C.chkPaymentGracePeriodChargeDefault.VisibleRow(false);
  }
}

// ===========================
// chkShowInstalmentsDrilldown
// ===========================
function chkShowInstalmentsDrilldown_Change(sender, e) {
  C.chkShowInstalmentsDrilldownWeb.VisibleRow(C.chkShowInstalmentsDrilldown.Value());
}

// ===============
// chkStatementUse
// ===============
function chkStatementUse_Change(sender, e) {
  C.cboStatementCycle.VisibleRow(C.chkStatementUse.Value());
  C.dateStatementDateNext.VisibleRow(C.chkStatementUse.Value());
    
  cboStatementCycle_Change();
}

// =================================
// dateComparisonRateMaximumNextDate
// =================================
function dateComparisonRateMaximumNextDate_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  C.numComparisonRateMaximumNext.Visible(C.dateComparisonRateMaximumNextDate.Value());
}

// ================================
// lstInterestPaymentAvailableTypes
// ================================
function lstInterestPaymentAvailableTypes_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  C.chkInterestCommonClient.VisibleRow(C.lstInterestPaymentAvailableTypes.ListExistsChecked("Transfer", true));
}

// ============================
// lstInterestTypeAvailableList
// ============================
function lstInterestTypeAvailableList_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  C.numInterestRate.VisibleRow(C.lstInterestTypeAvailableList.ListExistsChecked("Fixed Rate", true) || C.lstInterestTypeAvailableList.ListExistsChecked("Floating Rate", true));
  if (C.lstInterestTypeAvailableList.ListExistsChecked("Rate Table", true)) {
    C.cboInterestRateTable.VisibleRow(true);
    C.numInterestRatePremium.VisibleRow(true);
  }
  else {
    C.cboInterestRateTable.VisibleRow(false);
    C.numInterestRatePremium.VisibleRow(false);
  } 
}

// ===================================
// lstStartupInterestTypeAvailableList
// ===================================
function lstStartupInterestTypeAvailableList_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  C.numStartupInterestRate.VisibleRow(C.lstStartupInterestTypeAvailableList.ListExistsChecked("Fixed Rate", true) || C.lstStartupInterestTypeAvailableList.ListExistsChecked("Floating Rate", true));
  if (C.lstStartupInterestTypeAvailableList.ListExistsChecked("Rate Table", true)) {
    C.cboStartupInterestRateTable.VisibleRow(true);
    C.numStartupInterestRatePremium.VisibleRow(true);
  }
  else {
    C.cboStartupInterestRateTable.VisibleRow(false);
    C.numStartupInterestRatePremium.VisibleRow(false);
  }  
}

// ==========================
// txtMaturityAccountTypesNew
// ==========================
function txtMaturityAccountTypesNew_ButtonClick(sender, e) {
  widget.UI.Forms.ShowRangeLookupFromStandardRange("AccountTypesDeposits", sender.Text(), { caption: "Lookup Account Types" },
     function (newRange) {
       sender.Text(newRange);
       sender.Focus();
     });
}

// =============
// gridDocuments
// =============
function gridDocuments_Refresh() {
  var showWarning = false;

  // Show Warning?
  for (var i = 0; i &lt; mRecord_Documents.length; i++) {
    var item = mRecord_Documents[i];

    if (item.Message) showWarning = true;
  }

  // Add Columns
  C.gridDocuments.ClearColumns();
  C.gridDocuments.AddColumnIcon("Warning", { visible: showWarning, allowDrilldown: true });
  C.gridDocuments.AddColumnString("Category", { caption: "Category", visible: false });
  C.gridDocuments.AddColumnBoolean("Available", { caption: "Available", allowEdit: !mRecord.ReadOnly });
  C.gridDocuments.AddColumnCode("DocumentId", { caption: "Document", width: widget.UI.FIELD_WIDTH_CODE_10 });
  C.gridDocuments.AddColumnString("Description", { caption: "Description" });

  // Actions
  if (!mRecord.ReadOnly) {
    C.gridDocuments.Actions().Define([{ actionId: "SelectAll", tooltipText:"Select all valid rows", icon: "Select_All" },
                                      { actionId: "SelectNone", tooltipText:"Select no rows", icon: "Select_None" },
                                      { actionId: "SelectUp", tooltipText:"Select all rows above and including the current row", icon: "Select_Up" },
                                      { actionId: "SelectDown", tooltipText:"Select all rows below and including the current row", icon: "Select_Down" },
                                      { actionId: "SelectGroup", tooltipText:"Select all rows in the current Group", icon: "Select_Same" },
                                      {},
                                      { actionId: "Check", tooltipText: "Check selected row(s)", icon: "Checkbox_Checked" },
                                      { actionId: "Uncheck", tooltipText: "Uncheck selected row(s)", icon: "Checkbox_Unchecked" }
                                     ]);
  }

  // Refresh
  C.gridDocuments.VirtualDataRefresh(mRecord_Documents);

  // Activate First Row
  C.gridDocuments.ActivateFirstDataRow();
}

function gridDocuments_InitialiseRow(e) {
  var item = mRecord_Documents[e.row.listIndex];

  // Update cells
  e.row.AutoBind(item);
  
  // Warning Icon
  if (item.Message) {
    e.row.cells.Warning.value = "Warning";
    e.row.cells.Warning.tooltipText = item.Message;
  }
  else {
    e.row.cells.Warning.value = null;
  }

  // Styling
  e.row.cells.DocumentId.readOnly = true;
  e.row.cells.Description.readOnly = true;
  e.row.inactive = !item.Active;

  // Hide
  //e.row.hidden = !item.Active &amp;&amp; !item.Available;

  // Cell hyperlinks
  e.row.cells.DocumentId.hyperlink = "app://formshow?form=Documents&amp;id=" + encodeURIComponent(item.DocumentId);
}

function gridDocuments_BeforeCellUpdate(e) {
  var item = mRecord_Documents[e.row.listIndex];

  switch(e.columnKey) {
    case "Available":
      item.Available = e.newValue;
      break;
  }

  // Refresh row to update styles (e.g., inactive made available will no longer be hidden by default)
  e.refreshRow = true;
}

function gridDocuments_RowDrilldown(e) {
  var item = mRecord_Documents[e.row.listIndex];
  
  switch (e.columnKey) {
    case "Warning":
      if (item.Message) {
        var message = "&lt;b&gt;" + widget.UI.HtmlEncode(item.DocumentId) + "&lt;/b&gt; (&lt;i&gt;" + widget.UI.HtmlEncode(item.Description) + "&lt;/i&gt;)&lt;/br&gt;&lt;/br&gt;";
        message += widget.UI.HtmlEncode(item.Message);

        widget.UI.MsgBoxAlert(message, { messageIsHtml: true, title: "Document Warning" });
      }
      break;
  }
}

function gridDocuments_Action(actionId) {
  switch (actionId.toUpperCase()) {
    case "SELECTUP":
    case "SELECTDOWN":
      var activeRowIndex = C.gridDocuments.ActiveDataRowListIndex();
      var indexes = [];

      for(var i = 0; i &lt; mRecord_Documents.length; i++) {        
        if(actionId.toUpperCase() == "SELECTUP" &amp;&amp; i &lt;= activeRowIndex) {
          indexes.push(i);
        }
        else if(actionId.toUpperCase() == "SELECTDOWN" &amp;&amp; i &gt;= activeRowIndex) {
          indexes.push(i);
        }
      }
      C.gridDocuments.SetSelectedRowIndexes(indexes, true);
      break;

    case "SELECTALL":
      var indexes = [];
      for(var i = 0; i &lt; mRecord_Documents.length; i++) {
        indexes.push(i);
      }
      C.gridDocuments.SetSelectedRowIndexes(indexes, true);
      break;

    case "SELECTNONE":
      C.gridDocuments.SetSelectedRowIndexes([], true);
      break;

    case "SELECTGROUP":
      var i = C.gridDocuments.ActiveDataRowListIndex();
      
      if (i != -1) {
        var item = mRecord_Documents[i];
        
        if (item.Category) {
          var indexes = [];
          
          for(var j = 0; j &lt; mRecord_Documents.length; j++) {        
            var item2 = mRecord_Documents[j];
            
            if (item2.Category == item.Category) indexes.push(j);
          }          
          C.gridDocuments.SetSelectedRowIndexes(indexes, true);
        }
      }
      break;

    case "CHECK":
    case "UNCHECK":
      var selectedItems = C.gridDocuments.GetSelectedRowIndexes(true, true);

      for(var i = 0; i &lt; selectedItems.length; i++) {
        var item = mRecord_Documents[selectedItems[i]];
        item.Available = (actionId.toUpperCase() == "CHECK")
      }
      C.gridDocuments.VirtualDataRefresh(mRecord_Documents, true, { retainSelectedRows: true });
      break;
  }
}

function gridDocuments_AfterRowActivate(e) {
  // Refresh Buttons
  gridDocuments_RefreshButtons();
}

function gridDocuments_RefreshButtons() {
  if (C.gridDocuments.ActiveDataRowListIndex() == -1) {
    C.gridDocuments.Actions().SetEnabled("SelectGroup", false);
  }
  else {
    C.gridDocuments.Actions().SetEnabled("SelectGroup", true);
  }

  C.gridDocuments.RefreshButtons();
}

// ==============
// gridRateTables
// ==============
function gridRateTables_Refresh() {
  // Add Columns
  C.gridRateTables.ClearColumns();
  if (!mRecord.ReadOnly) C.gridRateTables.AddColumnDrilldown("Drilldown_Standard", { icon: "Copy" });
  C.gridRateTables.AddColumnString("Category", { caption: "Category", visible: false });
  C.gridRateTables.AddColumnBoolean("Available", { caption: "Available", allowEdit: !mRecord.ReadOnly });
  C.gridRateTables.AddColumnBoolean("AvailableStartup", { caption: "Startup", allowEdit: !mRecord.ReadOnly });
  C.gridRateTables.AddColumnCode("RateTableId", { caption: "Rate Table", width: widget.UI.FIELD_WIDTH_CODE_10 });
  C.gridRateTables.AddColumnString("Description", { caption: "Description" });
  C.gridRateTables.AddColumnString("CurrentRate", { caption: "Current", width: "8em", align: "right" });

  // Refresh
  C.gridRateTables.VirtualDataRefresh(mRecord_RateTables);

  // Activate First Row
  C.gridRateTables.ActivateFirstDataRow();
}

function gridRateTables_InitialiseRow(e) {
  var item = mRecord_RateTables[e.row.listIndex];

  // Update cells
  e.row.AutoBind(item);
  if (!item.Category) e.row.cells.Category.value = "(none)";

  // Styling
  e.row.inactive = !item.Active;
  e.row.bold = (item.RateTableId == C.cboStandardRateTable.Text());
  e.row.cells.RateTableId.readOnly = true;
  e.row.cells.Description.readOnly = true;
  e.row.cells.CurrentRate.readOnly = true;

  // Hide
  e.row.hidden = !item.Active &amp;&amp; !item.Available &amp;&amp; item.RateTableId != C.cboStandardRateTable.Text();

  // Cell hyperlinks
  e.row.cells.RateTableId.hyperlink = "app://formshow?form=RateTables&amp;id=" + encodeURIComponent(item.RateTableId);
}

function gridRateTables_BeforeCellUpdate(e) {
  var item = mRecord_RateTables[e.row.listIndex];

  switch(e.columnKey) {
    case "Available":
      item.Available = e.newValue;
      break;

    case "AvailableStartup":
      item.AvailableStartup = e.newValue;
      break;
  }

  // Refresh row to update styles (e.g., inactive made available will no longer be hidden by default)
  e.refreshRow = true;
}

function gridRateTables_RowDrilldown(e) {
  switch(e.columnKey) {
    case "Drilldown_Standard":
      C.cboStandardRateTable.Text(mRecord_RateTables[C.gridRateTables.ActiveDataRowListIndex()].RateTableId);

      // Refresh grid
      C.gridRateTables.VirtualDataRefresh(mRecord_RateTables, true);
      break;
  }
}

// ================
// gridElementLinks
// ================
function gridElementLinks_Refresh() {
  // Add Columns
  C.gridElementLinks.ClearColumns();
  C.gridElementLinks.AddColumnString("Category", { caption: "Category", visible: false });
  C.gridElementLinks.AddColumnString("Description", { caption: "Description" });
  C.gridElementLinks.AddColumnCode("ElementId", { caption: "Element", width: widget.UI.FIELD_WIDTH_CODE_10, allowEdit: !mRecord.ReadOnly });
  C.gridElementLinks.AddColumnString("ElementDescription", { caption: "Element Description" });
  C.gridElementLinks.AddColumnCurrency("Value", { caption: "Value", width: "6em", allowEdit: !mRecord.ReadOnly });
  C.gridElementLinks.AddColumnBoolean("ValueInclusive", { caption: "Inclusive", allowEdit: !mRecord.ReadOnly });
  C.gridElementLinks.AddColumnBoolean("NormallyCharge", { caption: "Normally Charge", allowEdit: !mRecord.ReadOnly });
  C.gridElementLinks.AddColumnBoolean("AllowValueUpdates", { caption: "Allow Updates", allowEdit: !mRecord.ReadOnly });

  // Refresh
  C.gridElementLinks.VirtualDataRefresh(mRecord_ElementLinks);

  // Activate First Row
  C.gridElementLinks.ActivateFirstDataRow();
}

function gridElementLinks_InitialiseRow(e) {
  var item = mRecord_ElementLinks[e.row.listIndex];

  // Update cells
  e.row.AutoBind(item);

  // Styling
  e.row.cells.Description.readOnly = true;
  e.row.cells.ElementDescription.readOnly = true;
  e.row.cells.ElementDescription.small = true;
  if (item.Mandatory) {
    e.row.cells.Description.colour = widget.UI.MANDATORY_LABEL_COLOUR;
    e.row.cells.ElementId.backgroundColour = widget.UI.MANDATORY_CONTROL_BACKGROUNDCOLOUR;
  }

  // Read-Only
  if (item.System) {
    e.row.cells.Value.notApplicable = true;
    e.row.cells.ValueInclusive.notApplicable = true;
    e.row.cells.NormallyCharge.notApplicable = true;
    e.row.cells.AllowValueUpdates.notApplicable = true;
  }
  else {
    if (!item.AllowValue) {
      e.row.cells.Value.notApplicable = true;
    }
    if (!item.AllowValueInclusive) {
      e.row.cells.ValueInclusive.notApplicable = true;
    }
  }

  // Validate Row
  e.row.invalid = false;
  if (item.Mandatory &amp;&amp; !item.ElementId) {
    e.row.invalid = true;
    e.row.invalidMessage = "Element not specified.";
  }
  else if (item.Value &amp;&amp; !item.ElementId) {
    e.row.invalid = true;
    e.row.invalidMessage = "Value is specified but no Element is specified.";
  }
}

function gridElementLinks_BeforeCellUpdate(e) {
  var item = mRecord_ElementLinks[e.row.listIndex];

  switch(e.columnKey) {
    case "ElementId":
      item.ElementId = e.newValue;

      // Lookup Element Description
      var element = mElements.GetItem(item.ElementId);
      if (element) {
        item.ElementId = element.ElementId; // Fix up differences in upper/ lower case
        item.ElementDescription = element.Description;
      }
      else {
        item.ElementDescription = "";
      }
      break;

    case "Value":
      if (e.newValue) {
        item.Value = e.newValue;
      }
      else {
        // Just in case fee is actually blanked out
        item.Value = 0;
      }
      break;

    case "ValueInclusive":
      item.ValueInclusive = e.newValue;
      break;

    case "NormallyCharge":
      item.NormallyCharge = e.newValue;
      break;

    case "AllowValueUpdates":
      item.AllowValueUpdates = e.newValue;
      break;
  }

  // Refresh row to update styles and data (e.g., Element Description)
  e.refreshRow = true;
}

function gridElementLinks_RowDrilldown(e) {
  switch(e.columnKey) {
    case "Drilldown_Standard":
      C.cboStandardRateTable.Text(mRecord_ElementLinks[C.gridElementLinks.ActiveDataRowListIndex()].RateTableId);

      // Refresh grid
      C.gridElementLinks.VirtualDataRefresh(mRecord_ElementLinks, true);
      break;
  }
}

function gridElementLinks_AfterRowActivate(e) {
  // Element List
  if (C.gridElementLinks.ActiveDataRowListIndex() != -1) {
    var elementType = mRecord_ElementLinks[C.gridElementLinks.ActiveDataRowListIndex()].ElementType;
    var elements = [];
    for (var i = 0; i &lt; mElements.length; i++) {
      var item = mElements[i];
      if (item.ElementType == elementType) {
        elements.push(item);
      }
    }
    C.gridElementLinks.SetColumnCollection("ElementId", elements, "ElementId", "Description");
  }
}

// =================
// gridDocumentLinks
// =================
function gridDocumentLinks_Refresh() {
  // Add Columns
  C.gridDocumentLinks.ClearColumns();
  C.gridDocumentLinks.AddColumnString("Description", { caption: "Description", width: "15em" });
  C.gridDocumentLinks.AddColumnCode("DocumentId", { caption: "Document", width: widget.UI.FIELD_WIDTH_CODE_10, allowEdit: !mRecord.ReadOnly });
  C.gridDocumentLinks.AddColumnString("DocumentDescription", { caption: "Document Description" });

  // Refresh
  C.gridDocumentLinks.VirtualDataRefresh(mRecord_DocumentLinks);

  // Activate First Row
  C.gridDocumentLinks.ActivateFirstDataRow();
}

function gridDocumentLinks_InitialiseRow(e) {
  var item = mRecord_DocumentLinks[e.row.listIndex];

  // Update cells
  e.row.AutoBind(item);

  // Styling
  e.row.cells.Description.readOnly = true;
  e.row.cells.DocumentDescription.readOnly = true;
  e.row.cells.DocumentDescription.small = true;
  if (item.Mandatory) {
    e.row.cells.Description.colour = widget.UI.MANDATORY_LABEL_COLOUR;
    e.row.cells.DocumentId.backgroundColour = widget.UI.MANDATORY_CONTROL_BACKGROUNDCOLOUR;
  }

  // Validate Row
  e.row.invalid = false;
  if (item.Mandatory &amp;&amp; !item.DocumentId) {
    e.row.invalid = true;
    e.row.invalidMessage = "Document not specified.";
  }
}

function gridDocumentLinks_BeforeCellUpdate(e) {
  var item = mRecord_DocumentLinks[e.row.listIndex];

  switch(e.columnKey) {
    case "DocumentId":
      item.DocumentId = e.newValue;

      // Lookup Document Description
      var Document = mDocuments.GetItem(item.DocumentId);
      if (Document) {
        item.DocumentId = Document.DocumentId; // Fix up differences in upper/ lower case
        item.DocumentDescription = Document.Description;
      }
      else {
        item.DocumentDescription = "";
      }
      break;
  }

  // Refresh row to update styles and data (e.g., Document Description)
  e.refreshRow = true;
}

function gridDocumentLinks_AfterRowActivate(e) {
  // Document List
  if (C.gridDocumentLinks.ActiveDataRowListIndex() != -1) {
    var documentLink = mRecord_DocumentLinks[C.gridDocumentLinks.ActiveDataRowListIndex()];
    var documentLinkType = documentLink.DocumentLinkType;
    var documentType = documentLink.DocumentType;

    var documents = [];
    for (var i = 0; i &lt; mDocuments.length; i++) {
      var item = mDocuments[i];
      if (item.DocumentType == documentType) {
        switch(documentLinkType) {
          case "ClosingSummary":
          case "PaymentReceipt":
          case "Quotation":
          case "RefundAdvice":
          case "Remittance":
          case "WithdrawalAdvice":
            // Document MUST be run from a Log
            if (!item.AllowStandalone &amp;&amp; !item.AllowLog) documents.push(item);
            break;

          case "Contract":
          case "DepositCertificate":
          case "MaturityAdvice":
          case "PaymentArrange":
          case "PaymentDetailsUpdate":
          case "PaymentRevisionAdvice":
          case "Restructure":
          case "Statement":
            // Document can be run from a Log
            if (item.AllowLog) documents.push(item);
            break;

          case "TaxCertificate":
            // Client Document MUST be run from a Log
            if (!item.AllowStandalone &amp;&amp; item.AllowLog) documents.push(item);
            break;

          default:
            console.warn("Document Link Type '" + item.DocumentLinkType + "' not handled!");
        }
      }
    }
    C.gridDocumentLinks.SetColumnCollection("DocumentId", documents, "DocumentId", "Description");
  }
}

function gridDocumentLinks_RowDrilldown(e) {
  switch(e.columnKey) {
    case "Drilldown_Standard":
      C.cboStandardRateTable.Text(mRecord_DocumentLinks[C.gridDocumentLinks.ActiveDataRowListIndex()].RateTableId);

      // Refresh grid
      C.gridDocumentLinks.VirtualDataRefresh(mRecord_DocumentLinks, true);
      break;
  }
}

// ===============
// gridScriptLinks
// ===============
function gridScriptLinks_Refresh() {
  // Add Columns
  C.gridScriptLinks.ClearColumns();
  C.gridScriptLinks.AddColumnString("Category", { caption: "Category", visible: false });
  C.gridScriptLinks.AddColumnString("KeyWithPrefixRemoved", { caption: "Key", width: "15em", readOnly: true });
  C.gridScriptLinks.AddColumnString("Description", { caption: "Description" });
  C.gridScriptLinks.AddColumnCode("ScriptId", { caption: "Script", width: widget.UI.FIELD_WIDTH_CODE_10, allowEdit: !mRecord.ReadOnly });
  C.gridScriptLinks.AddColumnString("ScriptDescription", { caption: "Script Description" });

  // Refresh
  C.gridScriptLinks.VirtualDataRefresh(mRecord_ScriptLinks);

  // Activate First Row
  C.gridScriptLinks.ActivateFirstDataRow();
}

function gridScriptLinks_InitialiseRow(e) {
  var item = mRecord_ScriptLinks[e.row.listIndex];

  // Update cells
  e.row.AutoBind(item);
  
  // Styling
  e.row.cells.KeyWithPrefixRemoved.readOnly = true;
  e.row.cells.Description.readOnly = true;
  e.row.cells.ScriptDescription.readOnly = true;
  e.row.cells.ScriptDescription.small = true;  
}

function gridScriptLinks_BeforeCellUpdate(e) {
  var item = mRecord_ScriptLinks[e.row.listIndex];

  switch(e.columnKey) {
    case "ScriptId":
      item.ScriptId = e.newValue;

      // Lookup Script Description
      var script = mScripts.GetItem(item.ScriptId);
      if (script) {
        item.ScriptId = script.ScriptId; // Fix up differences in upper/ lower case
        item.ScriptDescription = script.Description;
      }
      else {
        item.ScriptDescription = "";
      }
      break;
  }

  // Refresh row to update styles and data (e.g., Script Description)
  e.refreshRow = true;
}

function gridScriptLinks_AfterRowActivate(e) {
  // Script List
  if (C.gridScriptLinks.ActiveDataRowListIndex() != -1) {
    var availableScripts = mRecord_ScriptLinks[C.gridScriptLinks.ActiveDataRowListIndex()].AvailableScripts;
    var scripts = [];
    
    if (availableScripts) {
      for (var i = 0; i &lt; availableScripts.length; i++) {
        var script = mScripts.GetItem(availableScripts[i]);
        if (script) scripts.push(script);
      }
    }    
    
    C.gridScriptLinks.SetColumnCollection("ScriptId", scripts, "ScriptId", "Description");
  }
}

// ====================
// cboStandardRateTable
// ====================
function cboStandardRateTable_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Refresh grid
  C.gridRateTables.VirtualDataRefresh();
}

// ========================
// cboStartupInterestPeriod
// ========================
function cboStartupInterestPeriod_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  if (C.cboStartupInterestPeriod.Text() == "To Date") {
    C.spanStartupInterestToDate.show();
  }
  else {
    C.spanStartupInterestToDate.hide();
  }
}

// ====================
// cboInterestRateTable
// ====================
function cboInterestRateTable_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  if (C.cboInterestRateTable.Text()) {
    C.spanInterestRatePremium.show();
  }
  else {
    C.spanInterestRatePremium.hide();
  }
}

// ===========================
// cboStartupInterestRateTable
// ===========================
function cboStartupInterestRateTable_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  if (C.cboStartupInterestRateTable.Text()) {
    C.spanStartupInterestRatePremium.show();
  }
  else {
    C.spanStartupInterestRatePremium.hide();
  }
}

// =================
// cboStatementCycle
// =================
function cboStatementCycle_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  // Update Controls
  switch (C.cboStatementCycle.Text()) {
    case "None":
    case "On Demand":
      C.dateStatementDateNext.VisibleRow(false);
      break;
    
    default:
      C.dateStatementDateNext.VisibleRow(C.chkStatementUse.Value());
      break;
  }
  
  // Statements Document requirement will need updating
  pageDocuments_Refresh();
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
   switch(actionId) {
     case "FormClose":
      // Form Close button is disabled so act as if 'Cancel' has been clicked
      tabDetails_Cancel();
      break;
   }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>iBSfM1bHA0e3dSajGNvxLQ</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption>Account Type</Caption>
    <HtmlWidgetAllowInitialEventCaching>false</HtmlWidgetAllowInitialEventCaching>
    <HtmlWidgetMaxHeight>2000</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>1400</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>AccountType</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 />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="HideOtherPages" type="Boolean">
            <BlankTip />
            <Caption>Hide pages other than the one being edited?</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>True</Value>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>Configuration options.</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>TESTING</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="AccountTypeId" type="Range">
            <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>
            <LimitToList>false</LimitToList>
            <MaxLength>10</MaxLength>
            <RangeSingle>true</RangeSingle>
            <RangeType>Standard</RangeType>
            <RangeLookupSource>AccountTypes</RangeLookupSource>
            <RangeLookupSqlWhere />
          </Parameter>
          <Parameter name="DuplicateRecordId" 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.AccountTypes</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="Page" 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>General,NewAccounts,Term,Payments,Interest,InterestOptions,RateTables,Defaults,CreditLimit,CloseOptions,Other,Promotions,Transactions,Documents,Rules,Accounting,Scripts,UserDefined,Audit</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</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>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>