Sub Process_Globals
Private fx As JFX
Private frmDetail As Form
Private B4XTableD As B4XTable
Private btnNext As Button
Private btnPrev As Button
Private su As StringUtils
Private qfxData As String
End Sub
Sub ImportTransactions
Dim qfxFile As TextReader
qfxFile.Initialize(File.OpenInput(Main.dirDownloads, "Checking1.qfx") )
qfxData = qfxFile.ReadAll
Dim ORG As String = ParseQFX(Array As String("/SONRS","/FI","ORG"))
Dim FID As String = ParseQFX(Array As String("/SONRS","/FI","FID"))
Dim INTU_BID As String = ParseQFX(Array As String("/SONRS","INTU.BID"))
Dim INTU_USERID As String = ParseQFX(Array As String("/SONRS","INTU.USERID"))
Dim BANKID As String = ParseQFX(Array As String("/BANKACCTFROM","BANKID"))
Dim ACCTID As String = ParseQFX(Array As String("/BANKACCTFROM","ACCTID"))
Dim DTSTART As String = ParseQFX(Array As String("DTSTART"))
Dim DTEND As String = ParseQFX(Array As String("DTEND"))
Dim BALAMT_L As String = ParseQFX(Array As String("/LEDGERBAL","BALAMT"))
Dim BALAMT_A As String = ParseQFX(Array As String("/AVAILBAL","BALAMT"))
Dim DTASOF_L As String = ParseQFX(Array As String("/LEDGERBAL","DTASOF"))
Dim DTASOF_A As String = ParseQFX(Array As String("/AVAILBAL","DTASOF"))
Dim sI As Int = 1
Dim bI, eI, LineCount As Int
Dim eT As Int
Do While sI=sI
Dim QD() As String = Array As String ("<STMTTRN><TRNTYPE>","<DTPOSTED>","<TRNAMT>","<FITID>","CHECKNUM>","<NAME>","<MEMO>")
For I = 0 To QD.Length-1
If I = 0 Then
eT = qfxData.IndexOf2("</STMTTRN>",sI)
End If
bI=qfxData.indexof2(QD(I),sI)
eI=qfxData.indexof2("<",bI+QD(I).Length+1)
If (eI > bI ) And (bI > 0) And (bI < eT)Then
QD(I) = qfxData.SubString2(bI+QD(I).Length,eI)
Else
QD(I) = ""
End If
Next
sI=eT +1
LineCount=LineCount+1
Log ("SI=" & sI & " ET=" & eT & " T=" & QD(0) & " D=" & QD(1) & " A=" & QD(2) & " F=" & QD(3) & " C=" & QD(4) & " N=" & QD(5) & " M=" & QD(6) )
'This is the part that actually does the update ===========================================
Dim params As List
params.Initialize
params.AddAll(Array( QD(0), QD(1), QD(2), QD(3), QD(4), QD(5), QD(6) ))
If QD(0)="" Then
Exit
End If
B4XTableD.sql1.ExecNonQuery2($"INSERT INTO data VALUES("D", ?, ?, ?, ?, ?, ?, ?)"$,params)
'This is the part that actually does the update ===========================================
Loop
B4XTableD.Refresh
End Sub