In lieu of the Jiwa7 absence of the old Jiwa6 JiwaCashBookImport.exe utility, I am taking a stab at using the File Watcher to import a CSV into Cash Book Receipts.
I think I have most of it sussed, but I don't know how to add a new line.
I am basing the code here on the provided plugin File Watcher and using the Sub for CSVSalesOrderImport.
- Code: Select all
Private Sub CSVSalesOrderImport(ByVal FileName As String)
'SAMPLE CSV INPUT FILE
'=======================================================================
'Bank Ledger,Transaction Date,Invoice No,Invoice Amount,Debtor AccountNo,Allocated Amount
'6010-200-00,15/04/2016,000163-D01,15576.04,1002,10000
'6010-200-00,15/04/2016,100165-D01,5500.01,1149,5500.01
'6010-200-00,15/04/2016,100164-D01,606.49,1002,650
'6010-200-00,16/04/2016,100167-D01,13615.66,1001,13615.66
'6010-200-00,17/04/2016,100181-D01,-314.92,1001,-314.92
'6010-200-00,17/04/2016,100182-D01,-507.97,1001,-507.97
'
'=======================================================================
Dim CashBookRct As JiwaFinancials.Jiwa.JiwaCashBook.CashBook = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaCashBook.CashBook)(Nothing)
Using csvParser As New FileIO.TextFieldParser(FileName)
csvParser.TextFieldType = FileIO.FieldType.Delimited
csvParser.Delimiters = New String() {","}
csvParser.HasFieldsEnclosedInQuotes = False
Dim csvFields As String()
Dim previousOrderNo As String = Nothing
Dim newKey As String = ""
Dim debtor As JiwaApplication.Entities.Debtor.Debtor = New JiwaApplication.Entities.Debtor.Debtor
Dim BankLedger As JiwaApplication.Entities.GeneralLedger.Account = New JiwaApplication.Entities.GeneralLedger.Account
Do While Not csvParser.EndOfData
csvFields = csvParser.ReadFields
If Not previousOrderNo Is Nothing AndAlso csvFields(0) <> previousOrderNo Then
' The order No. has changed - save the currently assembled sales order
CashBookRct.Save()
CSVSalesOrderWatcher.LogToEventLog(String.Format("Imported Cash Book Batch No. '{0}' from File '{2}'", CashBookRct.BatchNo, FileName), System.Diagnostics.EventLogEntryType.SuccessAudit)
End If
If previousOrderNo Is Nothing OrElse csvFields(0) <> previousOrderNo Then
' Create a new order
BankLedger.ReadRecordFromAccountNo(csvFields(0))
CashBookRct.CreateNew(JiwaCashBook.CashBook.CashBookTypes.Receipt, BankLedger.GLLedgerID)
End If
previousOrderNo = csvFields(0)
Debtor.ReadRecordFromAccountNo(csvFields(4))
CashBookRct.AddNewTransaction("what are the values I need in here?")
Loop
If CashBookRct.DebtorTransactions.Count > 0 Then
CashBookRct.Save()
CSVSalesOrderWatcher.LogToEventLog(String.Format("Imported Cash Book Batch No. '{0}' from File '{1}'", salesOrder.InvoiceNo, FileName), System.Diagnostics.EventLogEntryType.SuccessAudit)
End If
End Using
End Sub
Cheers


