Hi Mike,
We are getting Error(Unable to cast object of type ''System.String'' to type ''JiwaFinancials.Jiwa.JiwaCRBatchTX.CRBatchTranLine') in the JIWA 7 in "CreditorBatchTrans" module.
we follow the existing (Jiwa 3) code to write the new code for jiwa 7 in the "CreditorBatchTrans" module
kindly advice .
The existing Jiwa 3 Code
oBatchTx = New JiwaCRBatchTX.clsCreditorBatchTrans()
With oBatchTx
.Database = jwDatabase
.BatchType = 1 'Creditor Purchase
.SetUp()
.ReadyNewBatch()
.BatchDate = jwDatabase.SysDate
iNum = 1
oTranLine = New clsTranLine
For Each oTranLine In g_TranLines
sSQL = "SELECT AccountNo FROM CR_MAIN WHERE AccountNo = " & jwDatabase.FormatChar(oTranLine.AccountNo)
If jwDatabase.ExecuteSelect(hwndRead, sSQL) = True Then
If jwDatabase.FetchRow(hwndRead) = True Then
bNewCreditor = False
Else
bNewCreditor = True
End If
End If
jwDatabase.StatementRenew(hwndRead)
If bNewCreditor = False Then
If .AddTranLine(oTranLine.AccountNo, 1) = False Then
LogMessage(AccountNo, " Line No:" & iNum & "- AddTranLine() " & .ErrorString)
Else
.TransLines(.TransLines.Count).HomeTransAmount = oTranLine.Amount + oTranLine.GST
.TransLines(.TransLines.Count).RemitNo = oTranLine.InvoiceNo
.TransLines(.TransLines.Count).Dispersals(1).Remark = oTranLine.InvoiceRef
.TransLines(.TransLines.Count).Dispersals(1).HomeDispersedAmount = oTranLine.Amount
.TransLines(.TransLines.Count).Dispersals(1).TaxAmount = oTranLine.GST
End If
End If
iNum = iNum + 1
Next oTranLine
.SaveRecord()
If .ErrorString <> "" Then
'g_ErrCollection.Add("Line No:" & iNum & "- " & .ErrorString)
End If
.CleanUp()
oTranLine = Nothing
End With
The current Jiwa 7 Code which we are getting the Error the error which we are getting the line highlighting in red
oBatchTx = New JiwaCRBatchTX.CreditorBatchTrans()
With oBatchTx
'$ssn
'.Database = jwDatabase
.BatchType = 1 'Creditor Purchase
.Setup()
'$ssn
' .ReadyNewBatch()
.CreateNew()
.BatchDate = jwDatabase.SysDateTime
iNum = 1
oTranLine = New clsTranLine
For Each oTranLine In g_TranLines
sSQL = "SELECT AccountNo FROM CR_MAIN WHERE AccountNo = " & jwDatabase.FormatChar(oTranLine.AccountNo)
If jwDatabase.ExecuteSelect(hwndRead, sSQL) = True Then
If jwDatabase.FetchRow(hwndRead) = True Then
bNewCreditor = False
Else
bNewCreditor = True
End If
End If
jwDatabase.StatementRenew(hwndRead)
If bNewCreditor = False Then
.TransLines.Add(oTranLine.AccountNo)
If .TransLines.IsAdding() = False Then
Else
.TransLines(.TransLines.Count).HomeTransAmount = oTranLine.Amount + oTranLine.GST
.TransLines(.TransLines.Count).RemitNo = oTranLine.InvoiceNo
.TransLines(.TransLines.Count).Dispersals(1).Remark = oTranLine.InvoiceRef
.TransLines(.TransLines.Count).Dispersals(1).HomeDispersedAmount = oTranLine.Amount
.TransLines(.TransLines.Count).Dispersals(1).TaxAmount = oTranLine.GST
End If
End If
iNum = iNum + 1
Next oTranLine
.Save()
.CleanUp()
oTranLine = Nothing
End With
Thanks & Regards
Senthilnathan