Creating a Cash Book Batch using code

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

Creating a Cash Book Batch using code

Postby Mike.Sheen » Tue Apr 14, 2009 10:42 am

The attached sample is a VB6 project which uses the Jiwa objects to create a simple cash book receipt batch, with a single transaction on it.

The guts of the code is as follows :
Code: Select all
Private Function CreateCashBookBatch(ByRef NewBatchNo As String) As Boolean
Dim lNewKey As String
Dim SampleBankAccountID As String
Dim SampleDebtorID As String

    On Error GoTo ErrorHandler

    CreateCashBookBatch = True
   
    SampleBankAccountID = "00000000O0000000006P"    ' This is the "Cash At Bank NSW" ledger in Demo data
    SampleDebtorID = "0000000061000000001V" ' This is debtor 1001 in demo data
   
    If CreateCashBookBatch = True Then
        Set CashBook = New clsCashBook
        Set CashBook.Database = Database
        Set CashBook.JiwaCommLib = JiwaCommLib
        Set CashBook.JLib = JLib
        Set CashBook.SystemProfile = SystemProfile
    End If
   
    If CreateCashBookBatch = True Then
        If CashBook.Setup = e_CashbookReturnCodeFailure Then
            CreateCashBookBatch = False
            ErrorString = CashBook.ErrorString
            ErrorModule = CashBook.ErrorModule
        End If
    End If
   
    If CreateCashBookBatch = True Then
        If CashBook.PrepareNewRecord = e_CashbookReturnCodeFailure Then
            CreateCashBookBatch = False
            ErrorString = CashBook.ErrorString
            ErrorModule = CashBook.ErrorModule
        End If
    End If
   
    If CreateCashBookBatch = True Then
        CashBook.BankLedgerID = SampleBankAccountID
        CashBook.BatchDate = Now
        CashBook.CashBookType = e_CashBookReceipt
        CashBook.Description = "Imported Batch"
    End If
   
    If CreateCashBookBatch = True Then
        'Add a new debtor transaction
        If CashBook.AddNewTransaction(e_CashBookTransactionTypeDebtorTransaction, SampleDebtorID, lNewKey) = e_CashbookReturnCodeFailure Then
            CreateCashBookBatch = False
            ErrorString = CashBook.ErrorString
            ErrorModule = CashBook.ErrorModule
        Else
            CashBook.CashBookTransactions(lNewKey).RemitNo = "test"
            CashBook.CashBookTransactions(lNewKey).HomeAmount = 100
            CashBook.CashBookTransactions(lNewKey).Remark = "remark"
            CashBook.CashBookTransactions(lNewKey).Reference = "reference"
            CashBook.CashBookTransactions(lNewKey).TranDate = Now
        End If
    End If
   
    If CreateCashBookBatch = True Then
   
        ' CashBook.Activated = True     ' Uncomment this line if you want the batch activated on save
   
        If CashBook.SaveRecord = e_CashbookReturnCodeFailure Then
            CreateCashBookBatch = False
            ErrorString = CashBook.ErrorString
            ErrorModule = CashBook.ErrorModule
        Else
            NewBatchNo = CashBook.BatchNo
        End If
    End If
       
    On Error GoTo 0
    Exit Function

ErrorHandler:
    CreateCashBookBatch = False
    ErrorString = Err.Description
    ErrorModule = "Form1.CreateCashBookBatch"
    Resume Next
End Function
Attachments
Cash Book.rar
(3.5 KiB) Downloaded 158 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 3 guests