<?xml version="1.0" encoding="utf-8"?>
  <finDocument version="1.00" exportedUtcDate="2024-09-05T00:02:30.0000000">
    <CreatedUserId>Admin</CreatedUserId>
    <CreatedUtcDate>2015-04-21T00:51:46.0000000</CreatedUtcDate>
    <UpdatedUserId>Admin</UpdatedUserId>
    <UpdatedUtcDate>2024-09-05T00:02:00.5970000</UpdatedUtcDate>
    <Active>true</Active>
    <AllowLog>true</AllowLog>
    <AllowStandalone>false</AllowStandalone>
    <AutoSaveDocument>true</AutoSaveDocument>
    <AutoPublishPriority>5</AutoPublishPriority>
    <Bookmarks />
    <Category />
    <CreateLog>true</CreateLog>
    <ChargeFee>false</ChargeFee>
    <CloudConnectAvailable>false</CloudConnectAvailable>
    <CloudConnectAllowPublish>false</CloudConnectAllowPublish>
    <DefaultPublishStatus>ToSend</DefaultPublishStatus>
    <Description>Account Payment Arrangement Advice</Description>
    <DocumentEmailCopyOfPrimary>false</DocumentEmailCopyOfPrimary>
    <DocumentEmailDoNotCombineForJoints>true</DocumentEmailDoNotCombineForJoints>
    <DocumentId>APA</DocumentId>
    <DocumentLogSubject />
    <DocumentType>Account</DocumentType>
    <EmailHTML>false</EmailHTML>
    <Fee>0</Fee>
    <FeeNotes />
    <FeeReference />
    <FeeElementId />
    <FileName>Account_PaymentArrangementAdvice.docx</FileName>
    <FileType>WordDocument</FileType>
    <LogConfirmPrinted>false</LogConfirmPrinted>
    <Notes>This is an example Account Payment Arrangement Advice than can only be published via an Account Log.</Notes>
    <ParameterSetId />
    <ParametersType>Standard</ParametersType>
    <PermissionKeyExecute />
    <ShowInReportExplorer>false</ShowInReportExplorer>
    <SplitDocumentByPostalZone>false</SplitDocumentByPostalZone>
    <UserFlagA>false</UserFlagA>
    <UserFlagB>false</UserFlagB>
    <AllowExternalParty>None</AllowExternalParty>
    <DocumentTypeAccountApp>false</DocumentTypeAccountApp>
    <ExternalPartyCategories />
    <SendToAccountOwners>All</SendToAccountOwners>
    <SendToAccountGuarantors>false</SendToAccountGuarantors>
    <SendToAccountOther>false</SendToAccountOther>
    <SendToAccountJoints>false</SendToAccountJoints>
    <FileCategory />
    <EmbedDocumentInLog>false</EmbedDocumentInLog>
    <EmailDocument>Prompt</EmailDocument>
    <DoNotEmailDocumentForStandalone>false</DoNotEmailDocumentForStandalone>
    <EmailClientCommunicationType>NotApplicable</EmailClientCommunicationType>
    <PrintDocumentEvenIfEmailed>false</PrintDocumentEvenIfEmailed>
    <PrintOnPublish>true</PrintOnPublish>
    <TemplateMessage />
    <TemplateSubject>Account Payment Arrangement advice from [Branch.Name] for Account [Account.AccountID]</TemplateSubject>
    <TemplateDocumentBinaryData>H4sIAAAAAAAEAO28VXQcS7Iu3GJmySKLwWJmZmZmZmZmZmZmZraYGSxmtsCSxczXe/bMmT2++zz8T/fhn69XxarMrMjq7vxiZURWZMlJgoCiAsABkAAAgAAg0Qlsbw0EAJCBAwAoAEhgTUFbGydjGyddJXc7Y0dtGjdrK/wCUGCyPAAw4L/4/zWakiYsBugQhR+C3wNnW1Yk2smKB8cKYo2xzZ6BIphkhIzFxRKXt10/c5YkEdNId9GvMD5sMRqmzRppZhjBEViYOrJMglMBUWbPucQ3xq5KeswkhPVT6GcFZ53hN4w9PlswrbuHQZVbT64iz/La4R4gSyAxHvUpFNvlo4rV6vd1xeUaAL260LXtz6mDRpKr4FpxeQQIVMGSzmg+ayWC0sWTxDobJicz7nbNKuAvPq1V4JGbJ8bFO2yjpK6NYFvovZoJKLPjfDveMmPmpxQrIdypJCuPtNWS02L/SiGent3K3v8jQkDS7C45E0FGIKrpZs7Iuhh1DfdR1kFoAzPsQ1b+xWUEhBDqGWCWxYnEQud7Eb2X6f5FbPezRqj3a/RSOwpw1Un47s5rJLdcQRr2sSFCtPMX0DmSgGf2zjRDW0eaBI7SviexVOpX/Z8DPyoWyOF+EuTx9Pxgia+izUGoqCzjwxk7fOHkff9lZh8fIAC5/7BS3His1otfZzK/WmF+Wamug7GVIy3NH/K/1vlf/IGqhL5f1gnLdxH4FjjbJb/W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KAeOVN29TtABuG+6IHvcUH7I8Rpec7qMWZV3bzlgU6N+mfSdMzFo+SdCnsEn02U2VlH3udNODyks1fVdoTmnvF6D+1T83qxycK+NxYy6eWmNrWkVXIOA0llMzLYfeZoMHtBQWHJ522z/s40RZ45oTkbiCn5vW0R+NOBS5y4xicjiR6e7BEN+PUrBIoPwL+MBQiYGvC/vRbhd/zNSxJ+7+A/d2z/FSW//MW/7N/+XfH3raz/xjD432xs/V39P7PX/wpklH+q/y+57L/39Hvi8r+hj/Z3acy/6/+eJvpvMGL8TdLo7+q/J+b9Bdj/S5re7138noXxb6gQ/E1Oxu/qvz+A+DcyKP6vxxG/K/8eHfwbHKx/Hyv83sPvPu1fiMD2dx7u7/r/6aD8FeycAMD/5a78rv6fE8Zfccz9F/V/Th9ykmDgf7TB/frw/frJaPx/lP4Psbc60WtEAAA=</TemplateDocumentBinaryData>
    <Code>Option Explicit On
Option Strict On

' #################################################################
' Account Payment Arrangement Advice
'
' Version: 1.11 (05/09/2024)
'
' Usage:
' Document can only be published via a Log.
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.01  28/07/2021  ISS
'    1.02  26/08/2021  ISS      J027240   Updated for NZ CCCFA
'    1.03  02/09/2021  ISS      J027267   Added 'Rate of Charge' for NZ HCCCC
'    1.04  04/10/2021  ISS      J027507   Removed testing code
'    1.05  08/11/2021  ISS      J027572   Added Financial Mentoring Service paragraph
'    1.06  10/03/2022  ISS      J027287   Added better support for Revolving Credit Loan Accounts
'    1.07  23/05/2022  ISS      J028729   More enhancements for NZ CCCFA
'    1.08  04/07/2022  ISS      J029100   Removed the word "current" in the Variation Summary table
'    1.09  11/03/2024  ISS      J031160   Now uses information stored on Payment Arrangement - if applicable
'    1.10  25/03/2024  ISS      J033145   Update "Length of Loan" to use Payment frequency if possible
'    1.11  05/09/2024  ISS      J034227   Fails for Restructure Logs
' #################################################################

'#Const "ShowFullPaymentSchedule",Boolean,False,"Forces a full Payment Schedule to be printed even if there are no overriding payments"
'#Const "ShowMethodOfPayment",Boolean,True,"Indicates whether to show Payment Method details"
'#Const "ShowVariationTable",Boolean,True,"Shows a Variation table of the Arrangement"
'#const "ShowVariationTableChanges",String,"None","Indicates whether to include increase/ decrease change information","None,Original,Previous"
'#Const "ShowVariationTablePreviousArrangement",Boolean,True,"Indicates whether to include a column showing the Previous Arrangement"
'#Const "ShowVariationTableRestructure",Boolean,False,"Indicates whether to include a column showing the latest Restructure information"
'#Const "ShowVariationTableRowCostOfBorrowing",Boolean,False,"Indicates whether to include a row showing Total Cost of Borrowing information"
'#Const "ShowVariationTableRowFees",Boolean,False,"Indicates whether to include a row showing Total Fee information"
'#Const "ShowVariationTableRowInterest",Boolean,True,"Indicates whether to include a row showing Total Interest information"
'#Const "ShowVariationTableRowInterestRemaining",Boolean,True,"Indicates whether to include a row showing Total Interest Remaining information"
'#Const "ShowVariationTableRowPayments",Boolean,True,"Indicates whether to include a row showing Total Payments information"
'#Const "ShowVariationTableRowPaymentsRemaining",Boolean,True,"Indicates whether to include a row showing Total Payments Remaining information"
'#Const "ShowVariationTableRowPaymentsAlreadyMade",Boolean,False,"Indicates whether to include a row showing Total Payment Already Made information"
'#Const "ShowFinancialMentoringParagraph",Boolean,False,"Include Financial Mentoring paragraph (uses Document Content 1 from Entity)"

Private ShowFinancialMentoringParagraph As Boolean = False
Private ShowFullPaymentSchedule As Boolean = False
Private ShowMethodOfPayment As Boolean = True
Private ShowVariationTable As Boolean = True
Private ShowVariationTableChanges As String = "None"
Private ShowVariationTablePreviousArrangement As Boolean = True
Private ShowVariationTableRestructure As Boolean = False
Private ShowVariationTableRowCostOfBorrowing As Boolean = False
Private ShowVariationTableRowFees As Boolean = False
Private ShowVariationTableRowInterest As Boolean = True
Private ShowVariationTableRowInterestRemaining As Boolean = True
Private ShowVariationTableRowPayments As Boolean = True
Private ShowVariationTableRowPaymentsAlreadyMade As Boolean = False
Private ShowVariationTableRowPaymentsRemaining As Boolean = True

' Objects
Private mDocument As finDocumentRO
Private mWordDocuments As List(Of ISWordDocument)
Private mWordDocumentsAccount As List(Of ISWordDocument)

Public Function Main(source As Object, eventId As String, eventArgs As ISKeyValueList, ByRef handled As Boolean, parameters As Object, ByRef returnValues As ISKeyValueList, ByRef text As String) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise
  mDocument = finBL.Documents(Mid(ScriptInfo.ScriptId, 10))
  mWordDocuments = New List(Of ISWordDocument)
  mWordDocumentsAccount = New List(Of ISWordDocument)

  ' Get Constants
  With ScriptInfo.Constants
    ShowFinancialMentoringParagraph = .GetBoolean("ShowFinancialMentoringParagraph", ShowFinancialMentoringParagraph)
    ShowFullPaymentSchedule = .GetBoolean("ShowFullPaymentSchedule", ShowFullPaymentSchedule)
    ShowMethodOfPayment = .GetBoolean("ShowMethodOfPayment", ShowMethodOfPayment)
    ShowVariationTable = .GetBoolean("ShowVariationTable", ShowVariationTable)
    ShowVariationTableChanges = .GetString("ShowVariationTableChanges", ShowVariationTableChanges)
    ShowVariationTablePreviousArrangement = .GetBoolean("ShowVariationTablePreviousArrangement", ShowVariationTablePreviousArrangement)
    ShowVariationTableRestructure = .GetBoolean("ShowVariationTableRestructure", ShowVariationTableRestructure)
    ShowVariationTableRowCostOfBorrowing = .GetBoolean("ShowVariationTableRowCostOfBorrowing", ShowVariationTableRowCostOfBorrowing)
    ShowVariationTableRowFees = .GetBoolean("ShowVariationTableRowFees", ShowVariationTableRowFees)
    ShowVariationTableRowInterest = .GetBoolean("ShowVariationTableRowInterest", ShowVariationTableRowInterest)
    ShowVariationTableRowInterestRemaining = .GetBoolean("ShowVariationTableRowInterestRemaining", ShowVariationTableRowInterestRemaining)
    ShowVariationTableRowPayments = .GetBoolean("ShowVariationTableRowInterest", ShowVariationTableRowPayments)
    ShowVariationTableRowPaymentsAlreadyMade = .GetBoolean("ShowVariationTableRowPaymentsAlreadyMade", ShowVariationTableRowPaymentsAlreadyMade)
    ShowVariationTableRowPaymentsRemaining = .GetBoolean("ShowVariationTableRowInterestRemaining", ShowVariationTableRowPaymentsRemaining)
  End With

  ' Handle Events
  Select Case eventId
    Case "Publish"
      ' Publish
      If TypeOf source Is finLogPublishBatch Then
        ' Log Publish
        Success = Publish_Log(DirectCast(source, finLogPublishBatch)(0))
      Else
        ' Standalone (Ad-Hoc)
        Success = False
        finBL.Error.ErrorBegin("This Document does not support Standalone publishing and must be published from a Log.")
      End If
  End Select

  Return Success

End Function

'#################################################################
' Publish via Log
'#################################################################
Private Function Publish_Log(logPublishBatchItem As finLogPublishBatchItem) As Boolean

  Dim dis As finDocumentRecipientDetailsItems
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Get Document Recipient Details for relevant Account Clients
  If Success Then
    Success = mDocument.GetAccountDocumentRecipientDetailsItemsFromLogPublishBatchItem(logPublishBatchItem, dis)
  End If

  ' Create Document
  If Success Then
    If Not CreateAccountDocument(dis, logPublishBatchItem, logPublishBatchItem.LogPk, Nothing) Then
      ' Ignore errors since the status of logPublishBatchitem will be updated to record this
    End If
  End If

  Return Success

End Function

'#################################################################
' Create Document for relevant Account Clients
'#################################################################
Private Function CreateAccountDocument(dis As finDocumentRecipientDetailsItems,
                                       logPublishBatchItem As finLogPublishBatchItem,
                                       parentLogPk As Integer,
                                       ByRef accountLog As finAccountLog) As Boolean

  Dim di As finDocumentRecipientDetailsItem
  Dim DocumentManagerFileName As String
  Dim DocumentManagerFileNameRelative As String
  Dim DocumentBinaryData As Byte()
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise
  mWordDocumentsAccount.Clear()

  ' Create Document for all relevant Account Clients
  For Each di In dis
    ' Create Document
    If Not CreateDocument(di) Then
      Success = False
      Exit For
    End If
  Next

  ' Standalone Publish functionality
  If Success Then
    If logPublishBatchItem Is Nothing Then
      ' Embed in Log?
      If mDocument.EmbedDocumentInLog Then
        Success = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccount, DocumentBinaryData)
      End If

      ' Create Log
      If Success AndAlso mDocument.CreateLog Then
        If finBL.AccountFunctions.LogAddDocument(dis(0).Account.Pk, mDocument.DocumentId, accountLog, mDocument.DocumentLogSubjectResolved, "", DocumentManagerFileNameRelative, "", isefinLogEmbeddedFileType.Pdf, DocumentBinaryData) Then
          ' Ensure any Email Logs are linked to this new Log
          parentLogPk = AccountLog.Pk
        Else
          Success = False
        End If
      End If
    End If
  End If

  ' Save Combined Document to Document Manager?
  ' NOTE: This is for ALL Account Clients, regardless of whether individual documents will be saved for each Account Client
  If Success AndAlso mDocument.AutoSaveDocument Then
    Success = finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccount(di.AccountId, mWordDocumentsAccount, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative)
  End If

  ' Embed Combined Document in Log?
  ' NOTE: This is for ALL Account Clients, regardless of whether individual documents will be saved for each Account Client
  If Success AndAlso mDocument.EmbedDocumentInLog Then
    Success = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccount, DocumentBinaryData)
  End If

  ' Email Account Clients?
  ' NOTE: This will create additional Account Logs (for each Account Client) where neccessary
  If Success AndAlso dis(0).EmailDetails.PublishEmail Then
    Success = dis.SendAccountEmailsPdf(parentLogPk)
  End If

  ' Update Log Publish details
  If logPublishBatchItem IsNot Nothing Then
    With logPublishBatchItem
      If Success Then
        ' Success
        .PublishSuccess = True
        .PublishDocumentFileName = DocumentManagerFileNameRelative
        .PublishDocumentBinaryDataFileType = isefinLogEmbeddedFileType.Pdf
        .PublishDocumentBinaryData = DocumentBinaryData
        .PrintStatus = dis(0).PrintStatus
      Else
        ' Failure
        .PublishSuccess = False
        .PublishError = finBL.Error.Message(True, True)
      End If
    End With
  End If

  Return Success

End Function

'#################################################################
' Create Document
'#################################################################
Private Function CreateDocument(di As finDocumentRecipientDetailsItem) As Boolean

  Dim Success As Boolean
  Dim WordDocumentBookmarks As ISWordDocumentBookmarks

  ' Assume Success
  Success = True

  ' Get Bookmarks
  WordDocumentBookmarks = di.WordDocument.GetBookmarks()

  ' Replace Standard Bookmarks
  Success = di.UpdateStandardBookmarks(WordDocumentBookmarks)

  ' Replace Custom Bookmarks
  If Success Then
    ReplaceBookmarks(di, WordDocumentBookmarks)
  End If

  ' Update Bookmarks
  If Success Then
    Success = di.WordDocument.UpdateBookmarks(WordDocumentBookmarks)
  End If

  ' Record Word Document
  If Success Then
    mWordDocuments.Add(di.WordDocument)
    mWordDocumentsAccount.Add(di.WordDocument)
  End If

  ' Update di Email details if required
  ' NOTE: By default, these are set to the Email template details defined on this Document

  Return Success

End Function

'#################################################################
' CUSTOM BOOKMARKS
'#################################################################
Private Function ReplaceBookmarks(di As finDocumentRecipientDetailsItem,
                                  wordDocumentBookmarks As ISWordDocumentBookmarks) As Boolean


  Dim Account As finAccount
  Dim AccountCalcOriginal As finAccountCalc
  Dim AccountLog As finAccountLog
  Dim DirectDebitsAwaitingProcessing As Decimal
  Dim Overdue As Decimal
  Dim PaymentArrangementCurrent As finAccountPayArrangement
  Dim PaymentFinalDate As Date
  Dim PaymentFinalDateOriginal As Date
  Dim Success As Boolean
  Dim SummaryTable As ISSummaryTable
  Dim VariationSummaryNote As String

  ' Assume Success
  Success = True

  ' Initialise
  Account = di.Account
  AccountLog = DirectCast(di.Log, finAccountLog)

  ' Get Original Account Calculation
  account.CalculationVersions.GetOpeningCalculation(0, AccountCalcOriginal)

  ' Find Current Payment Arrangement - if Log linked to a Payment Arrangement use that Arrangement
  PaymentArrangementCurrent = GetCurrentPaymentArrangement(account, di.log)
  If PaymentArrangementCurrent Is Nothing Then
    PaymentArrangementCurrent = Account.PaymentArrangementCurrent
  End If  

  ' Get Values
  PaymentFinalDateOriginal = AccountCalcOriginal.PaymentFinalDate
  PaymentFinalDate = Account.Calculation.PaymentFinalDate

  ' Payment Arrangement
  If PaymentArrangementCurrent Is Nothing Then
    wordDocumentBookmarks.DeleteParagraph("PaymentArrangement")
  ElseIf PaymentArrangementCurrent.Source = isefinAccountPaymentArrangementSource.Promise Then
    wordDocumentBookmarks.SetContentString("PaymentArrangement", String.format("The current Payment Arrangement (Promise) for your Account was made on {0}.", finBL.FormatDateDocuments(PaymentArrangementCurrent.ArrangementDate)))
  Else
    wordDocumentBookmarks.SetContentString("PaymentArrangement", String.format("The current Payment Arrangement for your Account was made on {0}.", finBL.FormatDateDocuments(PaymentArrangementCurrent.ArrangementDate)))
  End If

  ' Payments
  Select Case account.AccountClass
    Case isefinAccountClass.LoanRC
      wordDocumentBookmarks.SetContentWiki("PaymentDetails", ReplaceBookmarks_PaymentDetailsRC(Account, Account.Calculation, SummaryTable))
    Case Else
      If PaymentArrangementCurrent IsNot Nothing AndAlso PaymentArrangementCurrent.ScheduledPayments IsNot Nothing AndAlso PaymentArrangementCurrent.ScheduledPayments.HasData Then
        wordDocumentBookmarks.SetContentWiki("PaymentDetails", ReplaceBookmarks_PaymentDetailsFromPaymentArrangement(Account, PaymentArrangementCurrent, SummaryTable, ""))
      Else
        wordDocumentBookmarks.SetContentWiki("PaymentDetails", ReplaceBookmarks_PaymentDetails(Account, Account.Calculation, SummaryTable, ""))
      End If  
  End Select
  If SummaryTable Is Nothing Then
    wordDocumentBookmarks.Delete("PaymentScheduleBlock")
  Else
    wordDocumentBookmarks.SetContentSummaryTable("PaymentSchedule", SummaryTable)
  End If

  ' Payment Method
  If ShowMethodOfPayment Then
    wordDocumentBookmarks.SetContentString("PaymentMethod", ReplaceBookmarks_PaymentMethod(di.Account, Account.Calculation))
  Else
    wordDocumentBookmarks.Delete("PaymentMethodBlock")
  End If

  ' Overdue Note
  If Account.SupportsOverdue Then
    ' Find Overdue (less Direct Debits awaiting processing)
    Account.GetBalanceOverdue(Overdue, finBL.TimeZoneFunctions.GetCurrentDatabaseDate())
    Account.GetDirectDebitsAwaitingProcessing(0, DirectDebitsAwaitingProcessing, #12/31/9999#)
    Overdue -= DirectDebitsAwaitingProcessing

    If Overdue &gt; 0 Then
      wordDocumentBookmarks.SetContentString("OverdueNote", String.format("Your Account is currently {0} overdue.", finBL.FormatCurrency(Overdue, True)))
    Else
      wordDocumentBookmarks.Delete("OverdueNoteBlock")
    End If
  Else
    wordDocumentBookmarks.Delete("OverdueNoteBlock")
  End If

  ' Final Payment Date paragraph
  If ShowVariationTable Then
    ' Delete paragraph as showing full Variation table
    wordDocumentBookmarks.Delete("UpdatedFinalPaymentBlock")
  ElseIf PaymentFinalDate = Nothing Then
    ' Update wording as Payments are insufficient to pay off Loan Account
    wordDocumentBookmarks.SetContentString("UpdatedFinalPaymentBlock", "WARNING: Payments are insufficient to pay off your Loan!" &amp; vbNewLine)
  ElseIf PaymentFinalDateOriginal = PaymentFinalDate Then
    ' Delete paragraph
    wordDocumentBookmarks.Delete("UpdatedFinalPaymentBlock")
  End If

  ' Variation Table
  If ShowVariationTable Then
    Select Case Account.AccountClass
      Case isefinAccountClass.LoanFR, isefinAccountClass.LoanFT
        Me.ReplaceBookmarks_VariationTable(Account, di.log, SummaryTable, VariationSummaryNote)
        If SummaryTable Is Nothing Then
          wordDocumentBookmarks.Delete("VariationTableBlock")
        Else
          wordDocumentBookmarks.SetContentSummaryTable("VariationTable", SummaryTable)
          If Len(VariationSummaryNote) = 0 Then
            wordDocumentBookmarks.Delete("VariationSummaryNote")
          Else
            wordDocumentBookmarks.SetContentWiki("VariationSummaryNote", VariationSummaryNote)
          End If  
        End If

      Case Else
        wordDocumentBookmarks.Delete("VariationTableBlock")
    End Select
  Else
    wordDocumentBookmarks.Delete("VariationTableBlock")
  End If

  ' Financial Mentoring
  If Not ShowFinancialMentoringParagraph Then
    wordDocumentBookmarks.Delete("EntityDocumentContent1Block")
  ElseIf Len(Account.Entity.DocumentContent1) = 0 Then
    ' Financial Mentoring text not defined - so don't include
    wordDocumentBookmarks.Delete("EntityDocumentContent1Block")
  End If

  Return Success

End Function

Private Function ReplaceBookmarks_PaymentDetails(account As finAccount,
                                                 accountCalc As finAccountCalc,
                                                 ByRef summaryTable As ISSummaryTable,
                                                 ByRef paymentList As String) As String

Dim AccountCalcScheduleItem As finAccountCalcScheduleItem
Dim BalloonPaymentDate As Date
Dim BalloonPaymentValue As Decimal
Dim BookmarkText As String
Dim FullSchedule As Boolean
Dim Include As Boolean
Dim PartialSchedule As Boolean
Dim PaymentCount As Integer
Dim PaymentCountAdditional As Integer
Dim PaymentCountBalloon As Integer
Dim PaymentCountOverridden As Integer
Dim PaymentCountPromise As Integer
Dim PaymentCountRegular As Integer
Dim PaymentCountTransaction As Integer
Dim PaymentCountZero As Integer
Dim RegularPaymentFinalDate As Date
Dim RegularPaymentFinalOverridden As Boolean
Dim RegularPaymentFinalValue As Decimal
Dim RegularPaymentFirstDate As Date
Dim RegularPaymentFirstOverridden As Boolean
Dim RegularPaymentFirstValue As Decimal
Dim RegularPaymentUpfrontDate As Date
Dim RegularPaymentUpfrontOverridden As Boolean
Dim RegularPaymentUpfrontValue As Decimal
Dim strTemp As String

  ' Initialise
  BookmarkText = "Your payment schedule is as follows:" &amp; vbNewLine &amp; vbNewLine

  ' Initialise ByRef
  paymentList = ""
  summaryTable = Nothing

  If accountCalc IsNot Nothing Then
    ' Get Information
    PaymentCount = accountCalc.Schedule.CountPayments(False, PaymentCountRegular, PaymentCountZero, PaymentCountOverridden, PaymentCountBalloon, PaymentCountAdditional, PaymentCountPromise, PaymentCountTransaction)

    ' Full Schedule?
    If ShowFullPaymentSchedule Then
      FullSchedule = True
    Else
      FullSchedule = PaymentCountZero &lt;&gt; 0 Or PaymentCountOverridden &lt;&gt; 0
    End If

    ' Partial Schedule
    If FullSchedule Then
      PartialSchedule = False
    Else
      PartialSchedule = PaymentCountAdditional &lt;&gt; 0 Or PaymentCountPromise &lt;&gt; 0 Or PaymentCountTransaction &lt;&gt; 0
    End If

    ' Payment Details (logic as per built in Account Financial Details summary page so some may never be met due to the Full/ Partial Schedule flags set above)
    If FullSchedule Then
      BookmarkText &amp;= "Payments as per the schedule below." &amp; vbNewLine
    Else
      With accountCalc
        ' Get Payment Information
        .GetPaymentRegularUpfront(RegularPaymentUpfrontDate, RegularPaymentUpfrontValue, RegularPaymentUpfrontOverridden)
        .GetPaymentRegularFirst(RegularPaymentFirstDate, RegularPaymentFirstValue, RegularPaymentFirstOverridden)
        .GetPaymentRegularFinal(RegularPaymentFinalDate, RegularPaymentFinalValue, RegularPaymentFinalOverridden)
        .GetPaymentBalloon(BalloonPaymentDate, BalloonPaymentValue)

        ' Payments in Advance
        If .OptionPaymentsInAdvance Then
          BookmarkText &amp;= "Payments in Advance." &amp; vbNewLine
        End If

        ' Total Number of Payments
        If accountCalc.PaymentFinalDate &lt;&gt; Nothing AndAlso PaymentCount &lt;&gt; PaymentCountRegular Then
          BookmarkText &amp;= PaymentCount &amp; " Payment" &amp; If(PaymentCount = 1, "", "s") &amp; " in total." &amp; vbNewLine
        End If

        If PaymentCountRegular &lt;&gt; 0 Then
          If RegularPaymentFirstDate = Nothing And RegularPaymentUpfrontDate &lt;&gt; Nothing Then
            ' Only Upfront Payment
            BookmarkText &amp;= "Upfront Payment of " &amp; finBL.FormatCurrency(RegularPaymentUpfrontValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentUpfrontDate, True) &amp; "." &amp; vbNewLine
          ElseIf RegularPaymentFirstDate = RegularPaymentFinalDate Then
            ' Only one payment!
            If RegularPaymentUpfrontDate &lt;&gt; Nothing Then
              BookmarkText &amp;= "Upfront Payment of " &amp; finBL.FormatCurrency(RegularPaymentUpfrontValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentUpfrontDate, True) &amp; "." &amp; vbNewLine
            End If
            BookmarkText &amp;= "Payment of " &amp; finBL.FormatCurrency(RegularPaymentFirstValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentFirstDate, True) &amp; "." &amp; vbNewLine
          Else
            If Right(finBL.Utilities.DateCycleGetMnemonicFriendly(True, .PaymentCycle), 2) = "ly" Then
              If accountCalc.PaymentFinalDate = Nothing Then
                strTemp = "Payments due " &amp; finBL.Utilities.DateCycleGetMnemonicFriendly(True, .PaymentCycle)
              Else
                strTemp = CStr(PaymentCountRegular) &amp; " Payments due " &amp; finBL.Utilities.DateCycleGetMnemonicFriendly(True, .PaymentCycle)
              End If
            Else
              If accountCalc.PaymentFinalDate = Nothing Then
                strTemp = "Payments due " &amp; .PaymentCycleDescription
              Else
                strTemp = CStr(PaymentCountRegular) &amp; " Payments due " &amp; .PaymentCycleDescription
              End If
            End If
            If .PaymentRegular &lt;&gt; 0 And (RegularPaymentFirstValue &lt;&gt; .PaymentRegular) Then
              strTemp = strTemp &amp; " Regular Payment " &amp; finBL.FormatCurrency(.PaymentRegular, True)
            End If
            BookmarkText &amp;= strTemp &amp; "." &amp; vbNewLine
            If RegularPaymentUpfrontDate &lt;&gt; Nothing Then BookmarkText &amp;= "Upfront Payment of " &amp; finBL.FormatCurrency(RegularPaymentUpfrontValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentUpfrontDate, True) &amp; "." &amp; vbNewLine
            If accountcalc.IsCalcVersionOpening Then
              BookmarkText &amp;= "First Regular Payment of " &amp; finBL.FormatCurrency(RegularPaymentFirstValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentFirstDate, True) &amp; If(RegularPaymentFirstOverridden, " overridden", "") &amp; "." &amp; vbNewLine
            Else
              BookmarkText &amp;= "Next Regular Payment of " &amp; finBL.FormatCurrency(RegularPaymentFirstValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentFirstDate, True) &amp; If(RegularPaymentFirstOverridden, " overridden", "") &amp; "." &amp; vbNewLine
            End If
            If accountCalc.PaymentFinalDate &lt;&gt; Nothing Then
              BookmarkText &amp;= "Final Regular Payment of " &amp; finBL.FormatCurrency(RegularPaymentFinalValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentFinalDate, True) &amp; If(RegularPaymentFinalOverridden, " overridden", "") &amp; "." &amp; vbNewLine
            End If
          End If
        End If

        ' Balloon Payment
        If BalloonPaymentValue &lt;&gt; 0 Then
          BookmarkText &amp;= "Balloon payment of " &amp; finBL.FormatCurrency(BalloonPaymentValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(BalloonPaymentDate, True) &amp; "." &amp; vbNewLine
        End If

        ' Partial Schedule?
        If PartialSchedule Then
          BookmarkText &amp;= vbNewLine &amp; Format(PaymentCountAdditional + PaymentCountPromise + PaymentCountTransaction) &amp; " additional payment" &amp; If((PaymentCountAdditional + PaymentCountPromise + PaymentCountTransaction) = 1, "", "s") &amp; " as per the schedule below." &amp; vbNewLine
        End If

        ' Residual value
        If .ResidualValue &lt;&gt; 0 Then
          BookmarkText &amp;= vbNewLine &amp; "Residual Value of " &amp; finBL.FormatCurrency(.ResidualValue, True) &amp; "." &amp; vbNewLine
        End If
      End With
    End If

    ' Insufficient to pay off Loan
    If accountCalc.PaymentFinalDate = Nothing Then
      If Account.Balance &lt; 0 Then
        ' Credit Balance
        If PaymentCount = 0 Then
          BookmarkText &amp;= "**WARNING: Your Account has a Credit Balance. No scheduled payments found.**" &amp; vbNewLine
        Else
          BookmarkText &amp;= "**WARNING: Your Account has a Credit Balance.**" &amp; vbNewLine
        End If
      Else
        BookmarkText &amp;= vbNewLine &amp; "**WARNING: Payments do not pay off Loan.**" &amp; vbNewLine
      End If
    End If

    ' Remove final vbNewLine
    If Right(BookmarkText, Len(vbNewLine)) = vbNewLine Then
      BookmarkText = Left(BookmarkText, Len(BookmarkText) - Len(vbNewLine))
    End If

    ' Schedule
    If FullSchedule OrElse PartialSchedule Then
      ' Create Summary Table
      summaryTable = finBL.CreateSummaryTable()

      ' Update Summary Table
      With summaryTable
        .TableClass = iseSummaryTableClass.TabularData
        .AutoStripe = False
        .WidthHtml = "100%"

        ' Options
        With .WordDocumentOptions
          .Borders(iseWordDocumentSummaryTableBorder.All).Colour = "#000000"
          .CellVerticalAlignment = iseSummaryTableCellVerticalAlignment.Top
        End With

        ' Columns
        With .Columns
        .AddDate("Date")
        .AddCurrency("Payment")
        .AddText("Notes").WidthChars = 30
        End With
      End With

      For Each AccountCalcScheduleItem In AccountCalc.Schedule
        ' Include Schedule Item?
        If FullSchedule Then
          ' All Payment Items
          Select Case AccountCalcScheduleItem.ScheduleType
            Case isefinAccountCalcScheduleType.Payment, isefinAccountCalcScheduleType.PaymentBalloon, isefinAccountCalcScheduleType.PaymentOverridden, isefinAccountCalcScheduleType.PaymentAdditional, isefinAccountCalcScheduleType.PaymentPromise, isefinAccountCalcScheduleType.PaymentTransaction
              Include = AccountCalcScheduleItem.Overdue &lt;&gt; 0
            Case Else
              Include = False
          End Select
        Else
          ' Only Additional, Promises and Transactions
          Select Case AccountCalcScheduleItem.ScheduleType
            Case  isefinAccountCalcScheduleType.PaymentAdditional, isefinAccountCalcScheduleType.PaymentPromise, isefinAccountCalcScheduleType.PaymentTransaction
              Include = True
            Case Else
              Include = False
          End Select
        End If

        ' Insert Row
        If Include Then
          With summaryTable.Rows.Add.Cells()
            .AddDate(AccountCalcScheduleItem.Date)
            .AddCurrency(-AccountCalcScheduleItem.Value, True)
            .AddText(AccountCalcScheduleItem.NotesResolved)
          End With

          ' Add to text Payment List
          If Len(paymentList) &lt;&gt; 0 Then paymentList &amp;= vbNewLine
          paymentList &amp;= String.format("{0} {1}", finBL.FormatDateLong(AccountCalcScheduleItem.Date), finBL.FormatCurrency(-AccountCalcScheduleItem.Value, True))
        End If
      Next
    End If
  End If
  
  Return BookmarkText

End Function

Private Function ReplaceBookmarks_PaymentDetailsFromPaymentArrangement(account As finAccount,
                                                                       accountPayArrangement As finAccountPayArrangement,
                                                                       ByRef summaryTable As ISSummaryTable,
                                                                       ByRef paymentList As String) As String

Dim AccountCalcScheduledPayment As finAccountCalcScheduledPayment
Dim BalloonPaymentDate As Date
Dim BalloonPaymentValue As Decimal
Dim BookmarkText As String
Dim FullSchedule As Boolean
Dim Include As Boolean
Dim PartialSchedule As Boolean
Dim PaymentCount As Integer
Dim PaymentCountAdditional As Integer
Dim PaymentCountBalloon As Integer
Dim PaymentCountOverridden As Integer
Dim PaymentCountPromise As Integer
Dim PaymentCountRegular As Integer
Dim PaymentCountTransaction As Integer
Dim PaymentCountZero As Integer
Dim RegularPaymentFinalDate As Date
Dim RegularPaymentFinalOverridden As Boolean
Dim RegularPaymentFinalValue As Decimal
Dim RegularPaymentFirstDate As Date
Dim RegularPaymentFirstOverridden As Boolean
Dim RegularPaymentFirstValue As Decimal
Dim RegularPaymentUpfrontDate As Date
Dim RegularPaymentUpfrontOverridden As Boolean
Dim RegularPaymentUpfrontValue As Decimal
Dim strTemp As String

  ' Initialise
  BookmarkText = "Your payment schedule is as follows:" &amp; vbNewLine &amp; vbNewLine

  ' Initialise ByRef
  paymentList = ""
  summaryTable = Nothing

  If accountPayArrangement.ScheduledPayments IsNot Nothing Then
    ' Get Information
    PaymentCount = accountPayArrangement.ScheduledPayments.CountPayments(PaymentCountRegular, PaymentCountZero, PaymentCountOverridden, PaymentCountBalloon, PaymentCountAdditional, PaymentCountPromise, PaymentCountTransaction)

    ' Full Schedule?
    If ShowFullPaymentSchedule Then
      FullSchedule = True
    Else
      FullSchedule = PaymentCountZero &lt;&gt; 0 Or PaymentCountOverridden &lt;&gt; 0
    End If

    ' Partial Schedule
    If FullSchedule Then
      PartialSchedule = False
    Else
      PartialSchedule = PaymentCountAdditional &lt;&gt; 0 Or PaymentCountPromise &lt;&gt; 0 Or PaymentCountTransaction &lt;&gt; 0
    End If

    ' Payment Details (logic as per built in Account Financial Details summary page so some may never be met due to the Full/ Partial Schedule flags set above)
    If FullSchedule Then
      BookmarkText &amp;= "Payments as per the schedule below." &amp; vbNewLine
    Else
      ' Initialise
      RegularPaymentUpfrontDate = Nothing
      RegularPaymentUpfrontValue = 0
      RegularPaymentUpfrontOverridden = False
      RegularPaymentFirstDate = Nothing
      RegularPaymentFirstValue = 0
      RegularPaymentFirstOverridden = False
      RegularPaymentFinalDate = Nothing
      RegularPaymentFinalValue = 0
      RegularPaymentFinalOverridden = False
      BalloonPaymentDate = Nothing
      BalloonPaymentValue = 0

      For Each AccountCalcScheduledPayment In accountPayArrangement.ScheduledPayments
        Select Case AccountCalcScheduledPayment.ScheduleType
          Case isefinAccountCalcScheduleType.Payment
            ' Regular
            If Account.Calculation.OptionPaymentsInAdvance AndAlso AccountCalcScheduledPayment.Date = Account.Calculation.OpeningDate Then
              RegularPaymentUpfrontDate = AccountCalcScheduledPayment.Date
              RegularPaymentUpfrontValue = AccountCalcScheduledPayment.Value
              RegularPaymentUpfrontOverridden = False
            ElseIf RegularPaymentFirstDate = Nothing Then
              RegularPaymentFirstDate = AccountCalcScheduledPayment.Date
              RegularPaymentFirstValue = AccountCalcScheduledPayment.Value
              RegularPaymentFirstOverridden = False
            End If  
            RegularPaymentFinalDate = AccountCalcScheduledPayment.Date
            RegularPaymentFinalValue = AccountCalcScheduledPayment.Value
            RegularPaymentFinalOverridden = False
            
          Case isefinAccountCalcScheduleType.PaymentBalloon
            ' Balloon
            BalloonPaymentDate = AccountCalcScheduledPayment.Date
            BalloonPaymentValue = AccountCalcScheduledPayment.Value

          Case isefinAccountCalcScheduleType.PaymentOverridden
            ' Overridden
            If Account.Calculation.OptionPaymentsInAdvance AndAlso AccountCalcScheduledPayment.Date = Account.Calculation.OpeningDate Then
              RegularPaymentUpfrontDate = AccountCalcScheduledPayment.Date
              RegularPaymentUpfrontValue = AccountCalcScheduledPayment.Value
              RegularPaymentUpfrontOverridden = True
            ElseIf RegularPaymentFirstDate = Nothing Then
              RegularPaymentFirstDate = AccountCalcScheduledPayment.Date
              RegularPaymentFirstValue = AccountCalcScheduledPayment.Value
              RegularPaymentFirstOverridden = True
            End If  
            RegularPaymentFinalDate = AccountCalcScheduledPayment.Date
            RegularPaymentFinalValue = AccountCalcScheduledPayment.Value
            RegularPaymentFinalOverridden = True
        End Select  
      Next

      ' Payments in Advance
      If Account.Calculation.OptionPaymentsInAdvance Then
        BookmarkText &amp;= "Payments in Advance." &amp; vbNewLine
      End If

      ' Total Number of Payments
      If accountPayArrangement.PaymentFinalDate &lt;&gt; Nothing AndAlso PaymentCount &lt;&gt; PaymentCountRegular Then
        BookmarkText &amp;= PaymentCount &amp; " Payment" &amp; If(PaymentCount = 1, "", "s") &amp; " in total." &amp; vbNewLine
      End If

      If PaymentCountRegular &lt;&gt; 0 Then
        If RegularPaymentFirstDate = Nothing And RegularPaymentUpfrontDate &lt;&gt; Nothing Then
          ' Only Upfront Payment
          BookmarkText &amp;= "Upfront Payment of " &amp; finBL.FormatCurrency(RegularPaymentUpfrontValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentUpfrontDate, True) &amp; "." &amp; vbNewLine
        ElseIf RegularPaymentFirstDate = RegularPaymentFinalDate Then
          ' Only one payment!
          If RegularPaymentUpfrontDate &lt;&gt; Nothing Then
            BookmarkText &amp;= "Upfront Payment of " &amp; finBL.FormatCurrency(RegularPaymentUpfrontValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentUpfrontDate, True) &amp; "." &amp; vbNewLine
          End If
          BookmarkText &amp;= "Payment of " &amp; finBL.FormatCurrency(RegularPaymentFirstValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentFirstDate, True) &amp; "." &amp; vbNewLine
        Else
          If Right(finBL.Utilities.DateCycleGetMnemonicFriendly(True, accountPayArrangement.PaymentCycle), 2) = "ly" Then
            If accountPayArrangement.PaymentFinalDate = Nothing Then
              strTemp = "Payments due " &amp; finBL.Utilities.DateCycleGetMnemonicFriendly(True, accountPayArrangement.PaymentCycle)
            Else
              strTemp = CStr(PaymentCountRegular) &amp; " Payments due " &amp; finBL.Utilities.DateCycleGetMnemonicFriendly(True, accountPayArrangement.PaymentCycle)
            End If
          Else
            If accountPayArrangement.PaymentFinalDate = Nothing Then
              strTemp = "Payments due " &amp; accountPayArrangement.PaymentCycleDescription
            Else
              strTemp = CStr(PaymentCountRegular) &amp; " Payments due " &amp; accountPayArrangement.PaymentCycleDescription
            End If
          End If
          If accountPayArrangement.PaymentRegular &lt;&gt; 0 And (RegularPaymentFirstValue &lt;&gt; accountPayArrangement.PaymentRegular) Then
            strTemp = strTemp &amp; " Regular Payment " &amp; finBL.FormatCurrency(accountPayArrangement.PaymentRegular, True)
          End If
          BookmarkText &amp;= strTemp &amp; "." &amp; vbNewLine
          If RegularPaymentUpfrontDate &lt;&gt; Nothing Then BookmarkText &amp;= "Upfront Payment of " &amp; finBL.FormatCurrency(RegularPaymentUpfrontValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentUpfrontDate, True) &amp; "." &amp; vbNewLine
          BookmarkText &amp;= "Next Regular Payment of " &amp; finBL.FormatCurrency(RegularPaymentFirstValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentFirstDate, True) &amp; If(RegularPaymentFirstOverridden, " overridden", "") &amp; "." &amp; vbNewLine
          If accountPayArrangement.PaymentFinalDate &lt;&gt; Nothing Then
            BookmarkText &amp;= "Final Regular Payment of " &amp; finBL.FormatCurrency(RegularPaymentFinalValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(RegularPaymentFinalDate, True) &amp; If(RegularPaymentFinalOverridden, " overridden", "") &amp; "." &amp; vbNewLine
          End If
        End If
      End If

      ' Balloon Payment
      If BalloonPaymentValue &lt;&gt; 0 Then
        BookmarkText &amp;= "Balloon payment of " &amp; finBL.FormatCurrency(BalloonPaymentValue, True) &amp; " on " &amp; finBL.FormatDateDocuments(BalloonPaymentDate, True) &amp; "." &amp; vbNewLine
      End If

      ' Partial Schedule?
      If PartialSchedule Then
        BookmarkText &amp;= vbNewLine &amp; Format(PaymentCountAdditional + PaymentCountPromise + PaymentCountTransaction) &amp; " additional payment" &amp; If((PaymentCountAdditional + PaymentCountPromise + PaymentCountTransaction) = 1, "", "s") &amp; " as per the schedule below." &amp; vbNewLine
      End If

      ' Residual value
      If accountPayArrangement.ResidualValue &lt;&gt; 0 Then
        BookmarkText &amp;= vbNewLine &amp; "Residual Value of " &amp; finBL.FormatCurrency(accountPayArrangement.ResidualValue, True) &amp; "." &amp; vbNewLine
      End If
    End If

    ' Insufficient to pay off Loan
    If accountPayArrangement.PaymentFinalDate = Nothing Then
      If Account.Balance &lt; 0 Then
        ' Credit Balance
        If PaymentCount = 0 Then
          BookmarkText &amp;= "**WARNING: Your Account has a Credit Balance. No scheduled payments found.**" &amp; vbNewLine
        Else
          BookmarkText &amp;= "**WARNING: Your Account has a Credit Balance.**" &amp; vbNewLine
        End If
      Else
        BookmarkText &amp;= vbNewLine &amp; "**WARNING: Payments do not pay off Loan.**" &amp; vbNewLine
      End If
    End If

    ' Remove final vbNewLine
    If Right(BookmarkText, Len(vbNewLine)) = vbNewLine Then
      BookmarkText = Left(BookmarkText, Len(BookmarkText) - Len(vbNewLine))
    End If

    ' Schedule
    If FullSchedule OrElse PartialSchedule Then
      ' Create Summary Table
      summaryTable = finBL.CreateSummaryTable()

      ' Update Summary Table
      With summaryTable
        .TableClass = iseSummaryTableClass.TabularData
        .AutoStripe = False
        .WidthHtml = "100%"

        ' Options
        With .WordDocumentOptions
          .Borders(iseWordDocumentSummaryTableBorder.All).Colour = "#000000"
          .CellVerticalAlignment = iseSummaryTableCellVerticalAlignment.Top
        End With

        ' Columns
        With .Columns
        .AddDate("Date")
        .AddCurrency("Payment")
        .AddText("Notes").WidthChars = 30
        End With
      End With

      For Each AccountCalcScheduledPayment In accountPayArrangement.ScheduledPayments
        ' Include Schedule Item?
        If FullSchedule Then
          ' All Payment Items
          Select Case AccountCalcScheduledPayment.ScheduleType
            Case isefinAccountCalcScheduleType.Payment, isefinAccountCalcScheduleType.PaymentBalloon, isefinAccountCalcScheduleType.PaymentOverridden, isefinAccountCalcScheduleType.PaymentAdditional, isefinAccountCalcScheduleType.PaymentPromise, isefinAccountCalcScheduleType.PaymentTransaction
              Include = AccountCalcScheduledPayment.Value &lt;&gt; 0
            Case Else
              Include = False
          End Select
        Else
          ' Only Additional, Promises and Transactions
          Select Case AccountCalcScheduledPayment.ScheduleType
            Case  isefinAccountCalcScheduleType.PaymentAdditional, isefinAccountCalcScheduleType.PaymentPromise, isefinAccountCalcScheduleType.PaymentTransaction
              Include = True
            Case Else
              Include = False
          End Select
        End If

        ' Insert Row
        If Include Then
          With summaryTable.Rows.Add.Cells()
            .AddDate(AccountCalcScheduledPayment.Date)
            .AddCurrency(AccountCalcScheduledPayment.Value, True)
            .AddText(AccountCalcScheduledPayment.Notes)
          End With

          ' Add to text Payment List
          If Len(paymentList) &lt;&gt; 0 Then paymentList &amp;= vbNewLine
          paymentList &amp;= String.format("{0} {1}", finBL.FormatDateLong(AccountCalcScheduledPayment.Date), finBL.FormatCurrency(AccountCalcScheduledPayment.Value, True))
        End If
      Next
    End If
  End If
  
  Return BookmarkText

End Function

Private Function ReplaceBookmarks_PaymentDetailsRC(account As finAccount,
                                                   accountCalc As finAccountCalc,
                                                   ByRef summaryTable As ISSummaryTable) As String

Dim AccountCalcScheduleItem As finAccountCalcScheduleItem
Dim AccountPayArrangement As finAccountPayArrangement
Dim BookmarkText As String
Dim Include As Boolean
Dim PaymentCountAdditional As Integer
Dim PaymentCountPromise As Integer
Dim PaymentCountTransaction As Integer
Dim UseAltPaySchedule As Boolean

  ' Initialise
  BookmarkText = ""

  ' Initialise ByRef
  summaryTable = Nothing

  If AccountCalc IsNot Nothing Then
    ' Find Payment Arrangement
    AccountPayArrangement = account.PaymentArrangementCurrent

    ' Use Alternate Payment Schedule?
    If AccountPayArrangement Is Nothing Then
      UseAltPaySchedule = False
    Else
      UseAltPaySchedule = accountPayArrangement.UseAltPaySchedule
    End If

    If UseAltPaySchedule Then
      ' Alternate Payment Schedule
      BookmarkText = "Your payment schedule is as follows:" &amp; vbNewLine &amp; vbNewLine

      BookmarkText &amp;= String.Format("{0} {1}, first payment due {2}.", finBL.FormatCurrency(accountPayArrangement.PaymentRegular, True), accountPayArrangement.PaymentCycleDescription, finBL.FormatDateDocuments(AccountPayArrangement.PaymentFirstDate))
    Else
      ' Minimum Payment
      If accountcalc.MinimumPaymentDueDaysResolved = 0 Then
        BookmarkText &amp;= "You must make a Minimum Payment on the same day as the closing date of your statement."
      Else
        BookmarkText &amp;= String.Format("You must make a Minimum Payment {0} days after the closing date of your statement.", accountcalc.MinimumPaymentDueDaysResolved)
      End If
      Select Case AccountCalc.StatementCycle
        Case "", "None", "On Demand"
        Case Else
          BookmarkText &amp;= String.Format(" Your statement period is {0}.", AccountCalc.StatementCycleDescription)
      End Select
      BookmarkText &amp;= vbNewLine &amp; vbNewLine

      BookmarkText &amp;= "Your Minimum Payment is "
      Select Case accountCalc.MinimumPaymentBasis
        Case isefinAccountMinimumPaymentBasis.Higher
          BookmarkText &amp;= String.Format("the higher of {0} or {1} of the unpaid balance as at the end of each statement period.", finBL.FormatCurrency(accountCalc.MinimumPaymentValue, True), finBL.FormatPercentage(accountCalc.MinimumPaymentPercent / 100, 4))

        Case isefinAccountMinimumPaymentBasis.Instalment
          If accountCalc.MinimumPaymentInstalmentEndDate = Nothing Then
            BookmarkText &amp;= "Instalment based, with no end date"
          Else
            BookmarkText &amp;= String.Format("Instalment based, ending on {0}", finBL.FormatDateDocuments(accountCalc.MinimumPaymentInstalmentEndDate, True))
          End If
          If accountCalc.MinimumPaymentInstalmentResidualValue &lt;&gt; 0 Then
            BookmarkText &amp;= String.Format(" and a Residual Value of {0}", finBL.FormatCurrency(accountCalc.MinimumPaymentInstalmentResidualValue, True))
          End If
          BookmarkText &amp;= "."

        Case isefinAccountMinimumPaymentBasis.InterestAndFeesBalance
          BookmarkText &amp;= "the balance of Interest and Fees as at the end of each statement period."

        Case isefinAccountMinimumPaymentBasis.InterestAndFeesOnly
          BookmarkText &amp;= "the value of Interest and Fees for the statement period."

        Case isefinAccountMinimumPaymentBasis.InterestBalance
          BookmarkText &amp;= "the balance of Interest as at the end of each statement period."

        Case isefinAccountMinimumPaymentBasis.InterestOnly
          BookmarkText &amp;= "the value of Interest for the statement period."

        Case isefinAccountMinimumPaymentBasis.None
          BookmarkText &amp;= "Nil."

        Case isefinAccountMinimumPaymentBasis.OngoingSetValue
          BookmarkText &amp;= String.Format("an ongoing set value of {0}.", finBL.FormatCurrency(accountCalc.MinimumPaymentValue, True))

        Case isefinAccountMinimumPaymentBasis.PercentOfBalance
          BookmarkText &amp;= String.Format("{0} of the unpaid balance as at the end of each statement period.", finBL.FormatPercentage(accountCalc.MinimumPaymentPercent / 100, 4))

        Case isefinAccountMinimumPaymentBasis.SetValue
          BookmarkText &amp;= String.Format("a set value of {0}.", finBL.FormatCurrency(accountCalc.MinimumPaymentValue, True))

        Case Else
          BookmarkText &amp;= accountCalc.MinimumPaymentBasisText &amp; "."
      End Select

      BookmarkText &amp;= " You may pay more than the Minimum Payment." &amp; vbNewLine &amp; vbNewLine
      BookmarkText &amp;= "The date that payments are due will be specified in your statements."
    End If

    ' Additional Payments?
    accountCalc.Schedule.CountPayments(False, 0, 0, 0, 0, PaymentCountAdditional, PaymentCountPromise, PaymentCountTransaction)

    If PaymentCountAdditional &lt;&gt; 0 Or PaymentCountPromise &lt;&gt; 0 Or PaymentCountTransaction &lt;&gt; 0 Then
      ' Add heading
      BookmarkText &amp;= vbNewLine &amp; vbNewLine
      BookmarkText &amp;= "In addition you must make the following payments:" &amp; vbNewLine

      ' Create Summary Table
      summaryTable = finBL.CreateSummaryTable()

      ' Update Summary Table
      With summaryTable
        .TableClass = iseSummaryTableClass.TabularData
        .AutoStripe = False
        .WidthHtml = "100%"

        ' Options
        With .WordDocumentOptions
          .Borders(iseWordDocumentSummaryTableBorder.All).Colour = "#000000"
          .CellVerticalAlignment = iseSummaryTableCellVerticalAlignment.Top
        End With

        ' Columns
        With .Columns
        .AddDate("Date")
        .AddCurrency("Payment")
        .AddText("Notes").WidthChars = 30
        End With
      End With

      For Each AccountCalcScheduleItem In AccountCalc.Schedule
        Select Case AccountCalcScheduleItem.ScheduleType
          Case  isefinAccountCalcScheduleType.PaymentAdditional, isefinAccountCalcScheduleType.PaymentPromise, isefinAccountCalcScheduleType.PaymentTransaction
            Include = True
          Case Else
            Include = False
        End Select

        ' Insert Row
        If Include Then
          With summaryTable.Rows.Add.Cells()
            .AddDate(AccountCalcScheduleItem.Date)
            .AddCurrency(-AccountCalcScheduleItem.Value, True)
            .AddText(AccountCalcScheduleItem.NotesResolved)
          End With
        End If
      Next
    End If
  End If
  
  Return BookmarkText

End Function

Private Function ReplaceBookmarks_PaymentMethod(account As finAccount,
                                                accountCalc As finAccountCalc) As String

  Dim PaymentCountAdditional As Integer
  Dim PaymentCountPromise As Integer
  Dim PaymentCountTransaction As Integer
  Dim PaymentMethodPk As Integer

  ' Initialise
  ReplaceBookmarks_PaymentMethod = ""

  If AccountCalc IsNot Nothing Then
    ' Get Information
    If account.BankingDetails.ExistsBankingDetailsType(isefinAccountBankingDetailsType.Incoming) Then
      PaymentMethodPk = account.BankingDetails.Item(0).BankingDetails.PaymentMethodPk
    Else
      PaymentMethodPk = 0
    End If
    accountCalc.Schedule.CountPayments(False, 0, 0, 0, 0, PaymentCountAdditional, PaymentCountPromise, PaymentCountTransaction)

    If PaymentMethodPk = 0 Then
      ReplaceBookmarks_PaymentMethod = "Payments to be mailed or paid to the Creditor at the Creditor's address."
    Else
      ReplaceBookmarks_PaymentMethod = "Payments to be made by " &amp; finBL.PaymentMethods.ItemByPk(PaymentMethodPk).Description &amp; "."

       ' Add additional payments note on Payment Method?
      If PaymentCountAdditional &lt;&gt; 0 Or PaymentCountPromise &lt;&gt; 0 Or PaymentCountTransaction &lt;&gt; 0 Then
        If finBL.PaymentMethods.ItemByPk(PaymentMethodPk).IsDirectDebit Then
          ReplaceBookmarks_PaymentMethod &amp;= " Additional payments may be combined with regular payments when debiting your Bank Account."
        End If
      End If
    End If
  End If

End Function

Private Sub ReplaceBookmarks_VariationTable(account As finAccount,
                                            log As I_finLog,
                                            ByRef summaryTable As ISSummaryTable,
                                            ByRef variationSummaryNote As String)

  Dim AccountCalcCurrent As finAccountCalc
  Dim AccountCalcOriginal As finAccountCalc
  Dim AccountCalcRestructured As finAccountCalc
  Dim AccountCalcScheduleItem As finAccountCalcScheduleItem
  Dim AccountTransaction As finAccountTransaction
  Dim CurrentPaymentsInsufficient As Boolean
  Dim CurrentTotalCostOfBorrowing As Decimal
  Dim CurrentTotalFees As Decimal
  Dim CurrentTotalInterest As Decimal
  Dim CurrentTotalInterestRemaining As Decimal
  Dim CurrentTotalPayments As Decimal
  Dim CurrentTotalPaymentsRemaining As Decimal
  Dim CurrentTotalPaymentsToDate As Decimal
  Dim OriginalTotalCostOfBorrowing As Decimal
  Dim OriginalTotalFees As Decimal
  Dim OriginalTotalInterest As Decimal
  Dim OriginalTotalPayments As Decimal
  Dim PaymentArrangement As finAccountPayArrangement
  Dim PaymentArrangementCurrent As finAccountPayArrangement
  Dim PaymentArrangementFromLog As finAccountPayArrangement
  Dim PaymentArrangementPrevious As finAccountPayArrangement
  Dim PreviousPaymentsInsufficient As Boolean
  Dim PreviousTotalCostOfBorrowing As Decimal
  Dim PreviousTotalFees As Decimal
  Dim PreviousTotalInterest As Decimal
  Dim PreviousTotalPayments As Decimal
  Dim PreviousTotalPaymentsToDate As Decimal
  Dim Repayments As String
  Dim RepaymentSummaryTable As ISSummaryTable
  Dim RestructuredTotalCostOfBorrowing As Decimal
  Dim RestructuredTotalFees As Decimal
  Dim RestructuredTotalInterest As Decimal
  Dim RestructuredTotalPayments As Decimal
  Dim RestructuredTotalPaymentsToDate As Decimal
  Dim strTemp As String

  ' Initialise ByRef
  variationSummaryNote = ""
  
  ' Create Summary Table
  summaryTable = finBL.CreateSummaryTable()

  ' Get Original Account Calculation
  account.CalculationVersions.GetOpeningCalculation(0, AccountCalcOriginal)
  
  ' Get Payment Arrangement from Log
  PaymentArrangementFromLog = Me.GetCurrentPaymentArrangement(account, log)

  ' Get Original Totals
  OriginalTotalCostOfBorrowing = 0
  OriginalTotalFees = 0
  OriginalTotalInterest = 0
  OriginalTotalPayments = 0
  For Each AccountCalcScheduleItem In AccountCalcOriginal.Schedule
    Select Case AccountCalcScheduleItem.ElementType
      Case isefinElementType.Cost, isefinElementType.Journal
        OriginalTotalCostOfBorrowing += AccountCalcScheduleItem.Value
      Case isefinElementType.Fee
        OriginalTotalCostOfBorrowing += AccountCalcScheduleItem.Value
        OriginalTotalFees += AccountCalcScheduleItem.Value
      Case isefinElementType.Interest, isefinElementType.InterestDefault
        OriginalTotalCostOfBorrowing += AccountCalcScheduleItem.Value
        OriginalTotalInterest += AccountCalcScheduleItem.Value
      Case isefinElementType.PaymentReceived
        OriginalTotalPayments -= AccountCalcScheduleItem.Value
    End Select
  Next

  ' Get Restructured Account Calculation
  If ShowVariationTableRestructure Then
    account.CalculationVersions.GetLatestCalculation(-1, AccountCalcRestructured)
    If AccountCalcRestructured.AccountCalcPk = AccountCalcOriginal.AccountCalcPk Then
      AccountCalcRestructured = Nothing
    End If
  End If

  ' Get Restructured Totals
  If AccountCalcRestructured IsNot Nothing Then
    RestructuredTotalCostOfBorrowing = 0
    RestructuredTotalFees = 0
    RestructuredTotalInterest = 0
    RestructuredTotalPayments = 0
    RestructuredTotalPaymentsToDate = 0

    ' Add Transactions from prior to the Restructure
    For Each AccountTransaction In account.Transactions
      If AccountTransaction.AccountCalculationPk &lt;&gt; 0 Then
        Select Case AccountTransaction.ElementType
          Case isefinElementType.Cost, isefinElementType.Journal
            RestructuredTotalCostOfBorrowing += AccountTransaction.Value
          Case isefinElementType.Fee
            RestructuredTotalCostOfBorrowing += AccountTransaction.Value
            RestructuredTotalFees += AccountTransaction.Value
          Case isefinElementType.Interest, isefinElementType.InterestDefault
            RestructuredTotalCostOfBorrowing += AccountTransaction.Value
            RestructuredTotalInterest += AccountTransaction.Value
          Case isefinElementType.PaymentReceived
            RestructuredTotalPaymentsToDate -= AccountTransaction.Value
            RestructuredTotalPayments -= AccountTransaction.Value
        End Select
      End If
    Next

    ' Add Future Schedule
    For Each AccountCalcScheduleItem In AccountCalcRestructured.Schedule
      If AccountCalcScheduleItem.ScheduleType = isefinAccountCalcScheduleType.OpeningRestructure Then
        ' Ignore Opening Schedule Transaction
      Else
        Select Case AccountCalcScheduleItem.ElementType
          Case isefinElementType.Cost, isefinElementType.Journal
            RestructuredTotalCostOfBorrowing += AccountCalcScheduleItem.Value
          Case isefinElementType.Fee
            RestructuredTotalCostOfBorrowing += AccountCalcScheduleItem.Value
            RestructuredTotalFees += AccountCalcScheduleItem.Value
          Case isefinElementType.Interest, isefinElementType.InterestDefault
            RestructuredTotalCostOfBorrowing += AccountCalcScheduleItem.Value
            RestructuredTotalInterest += AccountCalcScheduleItem.Value
          Case isefinElementType.PaymentReceived
            RestructuredTotalPayments -= AccountCalcScheduleItem.Value
        End Select
      End If
    Next
  End If

  ' Get Current Account Calculation
  AccountCalcCurrent = Account.Calculation

  ' Get Current Totals
  If AccountCalcCurrent.PaymentFinalDate = Nothing Then
    ' Not being paid off
    CurrentTotalCostOfBorrowing = 0
    CurrentTotalFees = 0
    CurrentTotalInterest = 0
    CurrentTotalInterestRemaining = 0
    CurrentTotalPayments = 0
    CurrentTotalPaymentsRemaining = 0
    CurrentTotalPaymentsToDate = -Account.Transactions.Total(isefinElementType.PaymentReceived)
  Else
    CurrentTotalCostOfBorrowing = Account.Transactions.Total(isefinElementType.Cost) + Account.Transactions.Total(isefinElementType.Journal) + Account.Transactions.Total(isefinElementType.Fee) + Account.Transactions.Total(isefinElementType.Interest) + Account.Transactions.Total(isefinElementType.InterestDefault)
    CurrentTotalFees = Account.Transactions.Total(isefinElementType.Fee)
    CurrentTotalInterest = Account.Transactions.Total(isefinElementType.Interest) + Account.Transactions.Total(isefinElementType.InterestDefault)
    CurrentTotalInterestRemaining = 0
    CurrentTotalPayments = -Account.Transactions.Total(isefinElementType.PaymentReceived)
    CurrentTotalPaymentsRemaining = 0
    CurrentTotalPaymentsToDate = -Account.Transactions.Total(isefinElementType.PaymentReceived)
    For Each AccountCalcScheduleItem In AccountCalcCurrent.Schedule
      If AccountCalcScheduleItem.IsExisting Then
        ' Ignore as already counted
      Else
        Select Case AccountCalcScheduleItem.ElementType
          Case isefinElementType.Cost, isefinElementType.Journal
            CurrentTotalCostOfBorrowing += AccountCalcScheduleItem.Value
          Case isefinElementType.Fee
            CurrentTotalCostOfBorrowing += AccountCalcScheduleItem.Value
            CurrentTotalFees += AccountCalcScheduleItem.Value
          Case isefinElementType.Interest, isefinElementType.InterestDefault
            CurrentTotalCostOfBorrowing += AccountCalcScheduleItem.Value
            CurrentTotalInterest += AccountCalcScheduleItem.Value
            CurrentTotalInterestRemaining += AccountCalcScheduleItem.Value
          Case isefinElementType.PaymentReceived
            CurrentTotalPayments -= AccountCalcScheduleItem.Value
            CurrentTotalPaymentsRemaining -= AccountCalcScheduleItem.Value
        End Select
      End If
    Next
  End If

  ' Current Payment Arrangement - including Promises
  For Each PaymentArrangement In account.PaymentArrangements
    If AccountCalcRestructured IsNot Nothing AndAlso PaymentArrangement.CreatedUtcDate &lt; AccountCalcRestructured.CreatedUtcDate Then
      ' Ignore if prior to Restructure?
    Else
      PaymentArrangementCurrent = PaymentArrangement
    End If
  Next
  If PaymentArrangementCurrent IsNot Nothing Then
    ' Must be within the last 7 days and Total Payments, Cost of Borrowing and Payments to Date must be the same
    If PaymentArrangementCurrent.ArrangementDate &lt;= finBL.TimeZoneFunctions.GetCurrentDatabaseDate.AddDays(-7) Then
      PaymentArrangementCurrent = Nothing
    ElseIf PaymentArrangementCurrent.TotalPayments &lt;&gt; CurrentTotalPayments OrElse PaymentArrangementCurrent.TotalCostOfBorrowing &lt;&gt; CurrentTotalCostOfBorrowing Then
      PaymentArrangementCurrent = Nothing
    ElseIf PaymentArrangementCurrent.TotalPaymentsToDate &lt;&gt; CurrentTotalPaymentsToDate Then
      PaymentArrangementCurrent = Nothing
    End If
  End If

  ' Override Current Totals with Payment Arranegement
  If PaymentArrangementCurrent IsNot Nothing Then
    CurrentTotalCostOfBorrowing = PaymentArrangementCurrent.TotalCostOfBorrowing
    CurrentTotalFees = PaymentArrangementCurrent.TotalFees
    CurrentTotalInterest = PaymentArrangementCurrent.TotalInterest
    CurrentTotalPayments = PaymentArrangementCurrent.TotalPayments
    CurrentTotalPaymentsToDate = PaymentArrangementCurrent.TotalPaymentsToDate

    Select Case PaymentArrangementCurrent.Version
      Case 1
        ' Force to show Total Interest/ Payments Row only
        ShowVariationTableRowInterest = True
        ShowVariationTableRowInterestRemaining = False
        ShowVariationTableRowPayments = True
        ShowVariationTableRowPaymentsRemaining = False
      Case 2
        CurrentTotalInterestRemaining = PaymentArrangementCurrent.FutureInterest
        CurrentTotalPaymentsRemaining = PaymentArrangementCurrent.FuturePayments
    End Select
  End If

  ' Are Payment sufficient to pay off Loan?
  If PaymentArrangementCurrent Is Nothing Then
    CurrentPaymentsInsufficient = (AccountCalcCurrent.PaymentFinalDate = Nothing)
  Else
    CurrentPaymentsInsufficient = (PaymentArrangementCurrent.PaymentFinalDate = Nothing)
  End If

  ' Previous Arrangement - ignoring Promises
  If ShowVariationTablePreviousArrangement Then
    PaymentArrangementPrevious = Nothing
    For Each PaymentArrangement In account.PaymentArrangements
      Select Case PaymentArrangement.Source
        Case isefinAccountPaymentArrangementSource.Promise
        Case Else
          If AccountCalcRestructured IsNot Nothing AndAlso PaymentArrangement.CreatedUtcDate &lt; AccountCalcRestructured.CreatedUtcDate Then
            ' Ignore if prior to Restructure?
          ElseIf PaymentArrangementCurrent IsNot Nothing AndAlso PaymentArrangement.Pk = PaymentArrangementCurrent.Pk Then
            ' Ignore Current Payment Arrangement
            Exit For
          Else
            PaymentArrangementPrevious = PaymentArrangement
          End If
      End Select
    Next

    ' Get Previous Totals
    If PaymentArrangementPrevious IsNot Nothing Then
      PreviousPaymentsInsufficient = (PaymentArrangementPrevious.PaymentFinalDate = Nothing)
      PreviousTotalCostOfBorrowing = PaymentArrangementPrevious.TotalCostOfBorrowing
      PreviousTotalFees = PaymentArrangementPrevious.TotalFees
      PreviousTotalInterest = PaymentArrangementPrevious.TotalInterest
      PreviousTotalPayments = PaymentArrangementPrevious.TotalPayments
      PreviousTotalPaymentsToDate = PaymentArrangementPrevious.TotalPaymentsToDate
    End If
  End If

  ' Variation Changes
  Select Case ShowVariationTableChanges
    Case "Original"
    Case "Previous"
      ' Switch to Original if no previous values
      If PaymentArrangementPrevious Is Nothing Then
        ShowVariationTableChanges = "Original"
      End If
    Case Else
      ShowVariationTableChanges = "None"
  End Select

  ' Notes
  If PaymentArrangementCurrent IsNot Nothing AndAlso PaymentArrangementFromLog IsNot Nothing AndAlso PaymentArrangementCurrent.Pk &lt;&gt; PaymentArrangementFromLog.pk Then
    variationSummaryNote = "Note: the 'Current' column shows variations based upon the current status of the Loan, rather than at the time of the last Arrangement."
  End If  

  ' Update Summary Table
  With summaryTable
    .TableClass = iseSummaryTableClass.TabularData
    .AutoStripe = False
    .WidthHtml = "100%"
    
    ' Options
    With .WordDocumentOptions
      .Borders(iseWordDocumentSummaryTableBorder.All).Colour = "#000000"
      .CellVerticalAlignment = iseSummaryTableCellVerticalAlignment.Top
      '.FontSize = 9
    End With

    ' Columns
    With .Columns
      .AddText(" ", 13)
      .AddText("Original Contract")
      If AccountCalcRestructured IsNot Nothing Then
        .AddText("Restructured")
      End If
      If PaymentArrangementPrevious IsNot Nothing Then
        .AddText("Last Variation")
      End If

      If AccountCalcRestructured Is Nothing AndAlso PaymentArrangementPrevious Is Nothing Then
        strTemp = ""
      Else
        Select Case ShowVariationTableChanges
          Case "Original"
            strTemp = "&lt;br&gt;--Change from Original Contract--"
          Case "Previous"
            strTemp = "&lt;br&gt;--Change from Last Variation--"
        End Select
      End If
      If PaymentArrangementCurrent Is Nothing Then
        .AddWiki("**Current**" &amp; strTemp)
      ElseIf PaymentArrangementFromLog IsNot Nothing AndAlso PaymentArrangementCurrent.Pk &lt;&gt; PaymentArrangementFromLog.pk Then
        .AddWiki("**Current**" &amp; strTemp)
      ElseIf PaymentArrangementCurrent.Source = isefinAccountPaymentArrangementSource.Promise Then
        .AddWiki("**Promise**" &amp; strTemp)
      Else
        .AddWiki("**Arrangement**" &amp; strTemp)
      End If
    End With
  End With

  ' Dated
  With summaryTable.Rows.Add.Cells()
    .AddText("Dated")
    .AddDate(AccountCalcOriginal.OpeningDate, True, iseSummaryTableCellTextAlign.Left)
    If AccountCalcRestructured IsNot Nothing Then .AddDate(AccountCalcRestructured.DateRestructured, True, iseSummaryTableCellTextAlign.Left)
    If PaymentArrangementPrevious IsNot Nothing Then .AddDate(PaymentArrangementPrevious.ArrangementDate, True, iseSummaryTableCellTextAlign.Left)
    If PaymentArrangementCurrent Is Nothing Then
      .AddText("")
    Else
      .AddDate(PaymentArrangementCurrent.ArrangementDate, True, iseSummaryTableCellTextAlign.Left)
    End If
  End With

  ' Repayment
  With summaryTable.Rows.Add.Cells()
    .AddText("Repayments")

    strTemp = Me.ReplaceBookmarks_PaymentDetails(account, AccountCalcOriginal, RepaymentSummaryTable, Repayments)
    If Len(Repayments) &lt;&gt; 0 Then
      strTemp &amp;= vbNewLine &amp; Repayments
    End If
    .AddWiki("**Original Repayments:**" &amp; vbNewLine &amp; strTemp)

    If AccountCalcRestructured IsNot Nothing Then
      strTemp = Me.ReplaceBookmarks_PaymentDetails(account, AccountCalcRestructured, RepaymentSummaryTable, Repayments)
      If Len(Repayments) &lt;&gt; 0 Then
        strTemp &amp;= vbNewLine &amp; Repayments
      End If
      .AddWiki("**Repayments:**" &amp; vbNewLine &amp; strTemp)
    End If

    If PaymentArrangementPrevious IsNot Nothing Then .AddText("")

    If PaymentArrangementCurrent IsNot Nothing AndAlso PaymentArrangementCurrent.ScheduledPayments.HasData Then
      strTemp = Me.ReplaceBookmarks_PaymentDetailsFromPaymentArrangement(account, PaymentArrangementCurrent, RepaymentSummaryTable, Repayments)
    Else  
      strTemp = Me.ReplaceBookmarks_PaymentDetails(account, AccountCalcCurrent, RepaymentSummaryTable, Repayments)
    End If  
    If Len(Repayments) &lt;&gt; 0 Then
      strTemp &amp;= vbNewLine &amp; Repayments
    End If
    .AddWiki("**Remaining Repayments:**" &amp; vbNewLine &amp; strTemp)
  End With

  ' Regular Repayment
  With summaryTable.Rows.Add.Cells()
    .AddText("Regular Repayment")
    .AddText(String.Format("{0} {1}", finBL.FormatCurrency(AccountCalcOriginal.PaymentRegular, True), AccountCalcOriginal.PaymentCycleDescription))
    If AccountCalcRestructured IsNot Nothing Then .AddText(String.Format("{0} {1}", finBL.FormatCurrency(AccountCalcRestructured.PaymentRegular, True), AccountCalcRestructured.PaymentCycleDescription))
    If PaymentArrangementPrevious IsNot Nothing Then .AddText(String.Format("{0} {1}", finBL.FormatCurrency(PaymentArrangementPrevious.PaymentRegular, True), PaymentArrangementPrevious.PaymentCycleDescription))
    If PaymentArrangementCurrent Is Nothing Then
      .AddText(String.Format("{0} {1}", finBL.FormatCurrency(AccountCalcCurrent.PaymentRegular, True), AccountCalcCurrent.PaymentCycleDescription))
    Else
      .AddText(String.Format("{0} {1}", finBL.FormatCurrency(PaymentArrangementCurrent.PaymentRegular, True), PaymentArrangementCurrent.PaymentCycleDescription))
    End If
  End With

  ' Term
  With summaryTable.Rows.Add.Cells()
    .AddText("Length of Loan")
    .AddText(AccountCalcOriginal.TermCycleDescriptionResolved)
    If AccountCalcRestructured IsNot Nothing Then .AddText(AccountCalcRestructured.TermCycleDescriptionResolved)
    If PaymentArrangementPrevious IsNot Nothing Then .AddText(finBL.Runtime.DateUtilities.PeriodToWordsWithHint(AccountCalcOriginal.OpeningDate, PaymentArrangementPrevious.PaymentFinalDate, PaymentArrangementPrevious.PaymentCycleFreqPA))
    If PaymentArrangementCurrent Is Nothing Then
      .AddText(finBL.Runtime.DateUtilities.PeriodToWordsWithHint(AccountCalcOriginal.OpeningDate, AccountCalcCurrent.PaymentFinalDate, AccountCalcCurrent.PaymentCycleFreqPA))
    Else
      .AddText(finBL.Runtime.DateUtilities.PeriodToWordsWithHint(AccountCalcOriginal.OpeningDate, PaymentArrangementCurrent.PaymentFinalDate, PaymentArrangementCurrent.PaymentCycleFreqPA))
    End If
  End With

  ' Final Payment Date
  With summaryTable.Rows.Add.Cells()
    .AddText("Final Payment")
    .AddDate(AccountCalcOriginal.PaymentFinalDate, True, iseSummaryTableCellTextAlign.Left)
    If AccountCalcRestructured IsNot Nothing Then .AddDate(AccountCalcRestructured.PaymentFinalDate, True, iseSummaryTableCellTextAlign.Left)
    If PaymentArrangementPrevious IsNot Nothing Then
      If PreviousPaymentsInsufficient Then
        .AddText("")
      Else
        .AddDate(PaymentArrangementPrevious.PaymentFinalDate, True, iseSummaryTableCellTextAlign.Left)
      End If
    End If
    If CurrentPaymentsInsufficient Then
      strTemp = ""
    ElseIf PaymentArrangementCurrent Is Nothing Then
      strTemp = finBL.FormatDateLong(AccountCalcCurrent.PaymentFinalDate)

      Select Case ShowVariationTableChanges
        Case "Original"
          Select Case AccountCalcCurrent.PaymentFinalDate
            Case &lt; AccountCalcOriginal.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0} days--", DateDiff(DateInterval.Day, AccountCalcCurrent.PaymentFinalDate, AccountCalcOriginal.PaymentFinalDate))
            Case &gt; AccountCalcOriginal.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0} days--", DateDiff(DateInterval.Day, AccountCalcOriginal.PaymentFinalDate, AccountCalcCurrent.PaymentFinalDate))
          End Select
        Case "Previous"
          Select Case AccountCalcCurrent.PaymentFinalDate
            Case &lt; PaymentArrangementPrevious.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0} days--", DateDiff(DateInterval.Day, AccountCalcCurrent.PaymentFinalDate, PaymentArrangementPrevious.PaymentFinalDate))
            Case &gt; PaymentArrangementPrevious.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0} days--", DateDiff(DateInterval.Day, PaymentArrangementPrevious.PaymentFinalDate, AccountCalcCurrent.PaymentFinalDate))
          End Select
      End Select
    Else
      strTemp = finBL.FormatDateLong(PaymentArrangementCurrent.PaymentFinalDate)

      Select Case ShowVariationTableChanges
        Case "Original"
          Select Case PaymentArrangementCurrent.PaymentFinalDate
            Case &lt; AccountCalcOriginal.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0} days--", DateDiff(DateInterval.Day, PaymentArrangementCurrent.PaymentFinalDate, AccountCalcOriginal.PaymentFinalDate))
            Case &gt; AccountCalcOriginal.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0} days--", DateDiff(DateInterval.Day, AccountCalcOriginal.PaymentFinalDate, PaymentArrangementCurrent.PaymentFinalDate))
          End Select
        Case "Previous"
          Select Case PaymentArrangementCurrent.PaymentFinalDate
            Case &lt; PaymentArrangementPrevious.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0} days--", DateDiff(DateInterval.Day, PaymentArrangementCurrent.PaymentFinalDate, PaymentArrangementPrevious.PaymentFinalDate))
            Case &gt; PaymentArrangementPrevious.PaymentFinalDate
              strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0} days--", DateDiff(DateInterval.Day, PaymentArrangementPrevious.PaymentFinalDate, PaymentArrangementCurrent.PaymentFinalDate))
          End Select
      End Select
    End If
    .AddWiki(strTemp)
  End With

  ' Total Interest
  If ShowVariationTableRowInterest Then
    With summaryTable.Rows.Add.Cells()
      .AddText("Total Interest")
      .AddCurrency(OriginalTotalInterest, True,, iseSummaryTableCellTextAlign.Left)
      If AccountCalcRestructured IsNot Nothing Then .AddCurrency(RestructuredTotalInterest, True,, iseSummaryTableCellTextAlign.Left)
      If PaymentArrangementPrevious IsNot Nothing Then
        If PreviousPaymentsInsufficient Then
          .AddText("")
        Else
          .AddCurrency(PreviousTotalInterest, True,, iseSummaryTableCellTextAlign.Left)
        End If
      End If
      If CurrentPaymentsInsufficient Then
        strTemp = ""
      Else
        strTemp = finBL.FormatCurrency(CurrentTotalInterest, True)

        Select Case ShowVariationTableChanges
          Case "Original"
            Select Case CurrentTotalInterest
              Case &lt; OriginalTotalInterest
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(OriginalTotalInterest - CurrentTotalInterest, True))
              Case &gt; OriginalTotalInterest
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalInterest - OriginalTotalInterest, True))
            End Select
          Case "Previous"
            Select Case CurrentTotalInterest
              Case &lt; PreviousTotalInterest
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(PreviousTotalInterest - CurrentTotalInterest, True))
              Case &gt; OriginalTotalInterest
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalInterest - PreviousTotalInterest, True))
            End Select
        End Select
      End If
      .AddWiki(strTemp)
    End With
  End If

  ' Total Interest Remaining
  If ShowVariationTableRowInterestRemaining Then
    With summaryTable.Rows.Add.Cells()
      .AddText("Total Interest Remaining")
      .AddText("")
      If AccountCalcRestructured IsNot Nothing Then .AddText("")
      If PaymentArrangementPrevious IsNot Nothing Then         .AddText("")
      If CurrentPaymentsInsufficient Then
        .AddText("")
      Else
        .AddCurrency(CurrentTotalInterestRemaining, True,, iseSummaryTableCellTextAlign.Left)
      End If
    End With
  End If

  ' Total Fees
  If ShowVariationTableRowFees Then
    With summaryTable.Rows.Add.Cells()
      .AddText("Total Fees")
      .AddCurrency(OriginalTotalFees, True,, iseSummaryTableCellTextAlign.Left)
      If AccountCalcRestructured IsNot Nothing Then .AddCurrency(RestructuredTotalFees, True,, iseSummaryTableCellTextAlign.Left)
      If PaymentArrangementPrevious IsNot Nothing Then
        If PreviousPaymentsInsufficient Then
          .AddText("")
        Else
          .AddCurrency(PreviousTotalFees, True,, iseSummaryTableCellTextAlign.Left)
        End If
      End If
      If CurrentPaymentsInsufficient Then
        strTemp = ""
      Else
        strTemp = finBL.FormatCurrency(CurrentTotalFees, True)

        Select Case ShowVariationTableChanges
          Case "Original"
            Select Case CurrentTotalFees
              Case &lt; OriginalTotalFees
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(OriginalTotalFees - CurrentTotalFees, True))
              Case &gt; OriginalTotalFees
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalFees - OriginalTotalFees, True))
            End Select
          Case "Previous"
            Select Case CurrentTotalFees
              Case &lt; PreviousTotalFees
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(PreviousTotalFees - CurrentTotalFees, True))
              Case &gt; PreviousTotalFees
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalFees - PreviousTotalFees, True))
            End Select
        End Select
      End If
      .AddWiki(strTemp)
    End With
  End If

  ' Total Cost of Borrowing
  If ShowVariationTableRowCostOfBorrowing Then
    With summaryTable.Rows.Add.Cells()
      .AddText("Total Cost of Borrowing")
      .AddCurrency(OriginalTotalCostOfBorrowing, True,, iseSummaryTableCellTextAlign.Left)
      If AccountCalcRestructured IsNot Nothing Then .AddCurrency(RestructuredTotalCostOfBorrowing, True,, iseSummaryTableCellTextAlign.Left)
      If PaymentArrangementPrevious IsNot Nothing Then
        If PreviousPaymentsInsufficient Then
          .AddText("")
        Else
          .AddCurrency(PreviousTotalCostOfBorrowing, True,, iseSummaryTableCellTextAlign.Left)
        End If
      End If
      If CurrentPaymentsInsufficient Then
        strTemp = ""
      Else
        strTemp = finBL.FormatCurrency(CurrentTotalCostOfBorrowing, True)

        Select Case ShowVariationTableChanges
          Case "Original"
            Select Case CurrentTotalCostOfBorrowing
              Case &lt; OriginalTotalCostOfBorrowing
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(OriginalTotalCostOfBorrowing - CurrentTotalCostOfBorrowing, True))
              Case &gt; OriginalTotalCostOfBorrowing
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalCostOfBorrowing - OriginalTotalCostOfBorrowing, True))
            End Select
          Case "Previous"
            Select Case CurrentTotalCostOfBorrowing
              Case &lt; PreviousTotalCostOfBorrowing
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(PreviousTotalCostOfBorrowing - CurrentTotalCostOfBorrowing, True))
              Case &gt; PreviousTotalCostOfBorrowing
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalCostOfBorrowing - PreviousTotalCostOfBorrowing, True))
            End Select
        End Select
      End If
      .AddWiki(strTemp)
    End With
  End If

  ' Total Payments
  If ShowVariationTableRowPayments Then
    With summaryTable.Rows.Add.Cells()
      .AddText("Total Payments")
      .AddCurrency(OriginalTotalPayments, True,, iseSummaryTableCellTextAlign.Left)
      If AccountCalcRestructured IsNot Nothing Then .AddCurrency(RestructuredTotalPayments, True,, iseSummaryTableCellTextAlign.Left)
      If PaymentArrangementPrevious IsNot Nothing Then
        If PreviousPaymentsInsufficient Then
          .AddText("")
        Else
          .AddCurrency(PreviousTotalPayments, True,, iseSummaryTableCellTextAlign.Left)
        End If
      End If
      If CurrentPaymentsInsufficient Then
        strTemp = ""
      Else
        strTemp = finBL.FormatCurrency(CurrentTotalPayments, True)

        Select Case ShowVariationTableChanges
          Case "Original"
            Select Case CurrentTotalPayments
              Case &lt; OriginalTotalPayments
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(OriginalTotalPayments - CurrentTotalPayments, True))
              Case &gt; OriginalTotalPayments
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalPayments -  OriginalTotalPayments, True))
            End Select
          Case "Previous"
            Select Case CurrentTotalPayments
              Case &lt; PreviousTotalPayments
                strTemp &amp;= String.Format("&lt;br&gt;--Decrease of {0}--", finBL.FormatCurrency(PreviousTotalPayments - CurrentTotalPayments, True))
              Case &gt; PreviousTotalPayments
                strTemp &amp;= String.Format("&lt;br&gt;--Increase of {0}--", finBL.FormatCurrency(CurrentTotalPayments -  PreviousTotalPayments, True))
            End Select
        End Select
      End If
      .AddWiki(strTemp)
    End With
  End If

  ' Total Payments Remaining
  If ShowVariationTableRowPaymentsRemaining Then
    With summaryTable.Rows.Add.Cells()
      .AddText("Total Payments Remaining")
      .AddText("")
      If AccountCalcRestructured IsNot Nothing Then .AddText("")
      If PaymentArrangementPrevious IsNot Nothing Then .AddText("")
      If CurrentPaymentsInsufficient Then
        .AddText("")
      Else
        .AddCurrency(CurrentTotalPaymentsRemaining, True,, iseSummaryTableCellTextAlign.Left)
      End If
    End With
  End If

  ' Total Payments to Date
  If ShowVariationTableRowPaymentsAlreadyMade Then
    With summaryTable.Rows.Add.Cells()
      .AddText("Payments already made")
      .AddText("")
      If AccountCalcRestructured IsNot Nothing Then .AddCurrency(RestructuredTotalPaymentsToDate, True,, iseSummaryTableCellTextAlign.Left)
      If PaymentArrangementPrevious IsNot Nothing Then .AddCurrency(PreviousTotalPaymentsToDate, True,, iseSummaryTableCellTextAlign.Left)
      .AddCurrency(CurrentTotalPaymentsToDate, True,, iseSummaryTableCellTextAlign.Left)
    End With
  End If

  ' NZ HCCCC Rate of Charge
  Select Case account.ConsumerRegulationType
    Case isefinAccountConsumerRegulationType.NZ_HighCostConsumerCreditContract
      With summaryTable.Rows.Add.Cells()
        .AddText("Rate of Charge")
        If AccountCalcOriginal.ComparisonRateType = isefinAccountCalcComparisonRateType.NewZealandRateOfCharge Then
          If AccountCalcOriginal.ComparisonRate &lt; 0 Then .AddText("Error") Else .AddPercent(AccountCalcOriginal.ComparisonRate/100, 4, True, iseSummaryTableCellTextAlign.Left)
        Else
          .AddText("")
        End If
        If AccountCalcRestructured IsNot Nothing Then .AddText("")
        If PaymentArrangementPrevious IsNot Nothing Then
          If PaymentArrangementPrevious.ComparisonRate &lt; 0 Then .AddText("Error") Else .AddPercent(PaymentArrangementPrevious.ComparisonRate/100, 4, True, iseSummaryTableCellTextAlign.Left)
        End If
        If PaymentArrangementCurrent Is Nothing Then
          .AddText("")
        Else
          If PaymentArrangementCurrent.ComparisonRate &lt; 0 Then .AddText("Error") Else .AddPercent(PaymentArrangementCurrent.ComparisonRate/100, 4, True, iseSummaryTableCellTextAlign.Left)
        End If
      End With
  End Select
  
End Sub

Private Function GetCurrentPaymentArrangement(account As finAccount,
                                              log As I_finLog) As finAccountPayArrangement
  
  Dim PaymentArrangement As finAccountPayArrangement
  Dim PaymentArrangementPk As Integer

  ' If Log linked to a Payment Arrangement use that
  If log Is Nothing Then
    PaymentArrangementPk = 0
  Else  
    Select Case log.GetType() 
      Case GetType(finAccountLog)
        PaymentArrangementPk = DirectCast(log, finAccountLog).PaymentArrangementPk
      Case Else  
        PaymentArrangementPk = 0
    End Select
  End If  
  
  ' Get Payment Arrangement
  If account.PaymentArrangements.ExistsPk(PaymentArrangementPk) Then
    PaymentArrangement = Account.PaymentArrangements.ItemByPk(PaymentArrangementPk)
  End If  
    
  ' Payment Arrangement must be Version 2 or higher
  If PaymentArrangement IsNot Nothing AndAlso PaymentArrangement.Version &lt; 2 Then 
    PaymentArrangement = Nothing
  End If  
    
  Return PaymentArrangement
  
End Function</Code>
    <Language>VisualBasic</Language>
    <TimeoutSeconds>0</TimeoutSeconds>
    <ScriptReferenceReports>false</ScriptReferenceReports>
    <Constants>
      <ISScriptConstants version="1.00">
        <ScriptConstant name="ShowFullPaymentSchedule" constantType="Boolean">
          <Notes>Forces a full Payment Schedule to be printed even if there are no overriding payments</Notes>
          <Value>false</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowMethodOfPayment" constantType="Boolean">
          <Notes>Indicates whether to show Payment Method details</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTable" constantType="Boolean">
          <Notes>Shows a Variation table of the Arrangement</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableChanges" constantType="String">
          <List>None,Original,Previous</List>
          <Notes>Indicates whether to include increase/ decrease change information</Notes>
          <Value>Previous</Value>
          <Encrypt>false</Encrypt>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTablePreviousArrangement" constantType="Boolean">
          <Notes>Indicates whether to include a column showing the Previous Arrangement</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRestructure" constantType="Boolean">
          <Notes>Indicates whether to include a column showing the latest Restructure information</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRowCostOfBorrowing" constantType="Boolean">
          <Notes>Indicates whether to include a row showing Total Cost of Borrowing information</Notes>
          <Value>false</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRowFees" constantType="Boolean">
          <Notes>Indicates whether to include a row showing Total Fee information</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRowInterest" constantType="Boolean">
          <Notes>Indicates whether to include a row showing Total Interest information</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRowInterestRemaining" constantType="Boolean">
          <Notes>Indicates whether to include a row showing Total Interest Remaining information</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRowPayments" constantType="Boolean">
          <Notes>Indicates whether to include a row showing Total Payments information</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRowPaymentsRemaining" constantType="Boolean">
          <Notes>Indicates whether to include a row showing Total Payments Remaining information</Notes>
          <Value>true</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowVariationTableRowPaymentsAlreadyMade" constantType="Boolean">
          <Notes>Indicates whether to include a row showing Total Payment Already Made information</Notes>
          <Value>false</Value>
        </ScriptConstant>
        <ScriptConstant name="ShowFinancialMentoringParagraph" constantType="Boolean">
          <Notes>Include Financial Mentoring paragraph (uses Document Content 1 from Entity)</Notes>
          <Value>false</Value>
        </ScriptConstant>
      </ISScriptConstants>
    </Constants>
  </finDocument>