#Description: Example code to add a Bank Transaction Batch.
#Author: Intersoft Systems Limited
#Version: 1.02
#Last Updated: 14/05/2021

  Dim BatchBank As finBatchBank
  Dim BatchBankTransaction As finBatchBankTransaction
  Dim BatchBankTransactionItem As finBatchBankTransactionItem
  Dim Success As Boolean

  '====================================
  ' Create Bank Batch
  BatchBank = finBL.CreateBatchBank()

  With BatchBank
    ' Set Properties
    .BankAccountId = ""
    .TransactionTypeId = ""

    ' Set Source
    Success = .SourceSet(isefinTransactionSource.ExternalA)
  End With

  '====================================
  ' Create and add Transaction to Batch
  If Success Then
    ' Create Bank Transaction
    BatchBankTransaction = BatchBank.Transactions.CreateBatchBankTransaction()

    ' Update Bank Transaction properties
    With BatchBankTransaction
      .Date = finBL.TimeZoneFunctions.GetCurrentDatabaseDate()
      .Reference = ""
      .Notes = ""
      
      ' Set Payment Method and other Banking details
      With .BankingDetails
        .PaymentMethodId = ""
        .AccountName = ""
        .AccountNumber = ""
        .AccountSortCode = ""
      End With  

      ' Create Bank Transaction Item, to link Account
      BatchBankTransactionItem = .TransactionItems.CreateBatchBankTransactionItem()
      
      With BatchBankTransactionItem
        ' Set Account
        If Success Then
          ' If you have the Account's Pk this is more efficient
          '.AccountPk = 0
          Success = .AccountIdSet("")
        End If

        ' Set Element
        If Success Then
          ' Only use if different from the Transaction Type
          '.ElementPk = 0
        End If

        ' Set Properties
        If Success Then
          .Value = 0
        End If
      End With

      ' Add Bank Transaction Item
      If Success Then
        Success = .TransactionItems.Add(BatchBankTransactionItem)
      End If  
    End With

    ' Add the Transaction to the Batch
    If Success Then
      Success = BatchBank.Transactions.Add(BatchBankTransaction)
    End If
  End If

  '====================================
  ' Commit Batch
  If Success Then
    Success = BatchBank.ExecuteCommit()
  End If
  