Skip to Content
0
Former Member
Apr 23, 2009 at 05:13 AM

Creating Multiple Invoice, First details repeat on every invoice

31 Views

Im creating a addon were in a select statement will create a multiple invoice with 2 details each ,The correct number of records were save, but we notice looping this into several invoice the first details of every invoice are the same, the second details for every invoice are ok

pls see codes

-- start of loop -


vProcess = oMatrix.Columns.Item("Include").Cells.Item(nLnDtls).Specific.checked

If vProcess = True Then

Dim sDateAsOf As String

Dim nProcAmt As Integer

oCompany.StartTransaction()

oInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service

oInvoice.CardCode = oMatrix.Columns.Item("CardCode").Cells.Item(nLnDtls).Specific.value()

oInvoice.Comments = " Data Interface = " & oMatrix.Columns.Item("LineId").Cells.Item(nLnDtls).Specific.value().ToString & " of " & oMatrix.Columns.Item("Terms").Cells.Item(nLnDtls).Specific.value().ToString

oInvoice.NumAtCard = oMatrix.Columns.Item("AcctNo").Cells.Item(nLnDtls).Specific.value()

oInvoice.DocDate = Date.Now.ToShortDateString

oInvoice.TaxDate = oMatrix.Columns.Item("DueDate").Cells.Item(nLnDtls).Specific.value()

oInvoice.DocDueDate = oMatrix.Columns.Item("DueDate").Cells.Item(nLnDtls).Specific.value()

'--


Invoice Details for Monthly Amortization--


sDateAsOf = oMatrix.Columns.Item("DueDate").Cells.Item(nLnDtls).Specific.value().ToString

nProcAmt = oMatrix.Columns.Item("PrinDue").Cells.Item(nLnDtls).Specific.value()

oInvoice.Lines.ItemDescription = "Remaining balance as of: " & sDateAsOf

oInvoice.Lines.AccountCode = "4101010"

oInvoice.Lines.LineTotal = nProcAmt

oInvoice.Lines.BaseLine = 1

oInvoice.Lines.SetCurrentLine(1)

oInvoice.Lines.Add()

prevPrinDue = prinDue + nProcAmt

prinDue = nProcAmt

'----


Deferred Interest oInvoice.Lines.ItemDescription = "Deferred Interest Income For : " & oMatrix.Columns.Item("DueDate").Cells.Item(nLnDtls).Specific.value()

oInvoice.Lines.AccountCode = "2102030"

oInvoice.Lines.LineTotal = oMatrix.Columns.Item("IntrDue").Cells.Item(nLnDtls).Specific.value()

oInvoice.Lines.BaseLine = 2

If oInvoice.Add 0 Then

MsgBox("Error " + oCompany.GetLastErrorDescription())

Else

'Update flag

oRsSave = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

strSave = "UPDATE @CPI_LOA1 SET U_flag=1 WHERE @CPI_LOA1.LineId = "

strSave = strSave & oMatrix.Columns.Item("LineId").Cells.Item(nLnDtls).Specific.value() & " AND @CPI_LOA1.DocEntry = " & oMatrix.Columns.Item("DocEntry").Cells.Item(nLnDtls).Specific.value()

oRsSave.DoQuery(strSave)

End If

oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)

End If

nLnDtls = nLnDtls + 1

Case Else

nLnDtls = nLnDtls + 1

End Select

--- end loop

I hope some could help me to solve this problem

Thanks

Loren