Hi All !
I have function to Add Invoice and payment as follows:
Private Function Add_Invoice_Payment(ByVal TransCode As Double) As Boolean
Dim strShop As String = "C570004"
Dim oInv As SAPbobsCOM.Documents
oInv = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
oInv.CardCode = strShop
oInv.DocDate = Now.Date
oInv.DocDueDate = Now.Date
oInv.Comments = "From POS System - With Transaction Code " & TransCode
Dim disc As Double = 0
Dim WarehouseCode As String = "HCI001"
Dim VATGroup As String = "S10_CM"
For i_row As Integer = 0 To jsgxDetails.RowCount - 1
jsgxDetails.Row = i_row
oInv.Lines.SetCurrentLine(i_row)
oInv.Lines.ItemCode = jsgxDetails.GetValue("Item_Code")
oInv.Lines.ItemDescription = jsgxDetails.GetValue("Item_Name")
oInv.Lines.UnitPrice = jsgxDetails.GetValue("Item_Price")
oInv.Lines.Quantity = jsgxDetails.GetValue("Item_Quantity")
oInv.Lines.DiscountPercent = disc
oInv.Lines.WarehouseCode = WarehouseCode
oInv.Lines.VatGroup = VATGroup
oInv.Lines.Add()
Next
lRetCode = oInv.Add()
If lRetCode = 0 Then
oCompany.GetLastError(lErrCode, sErrMsg)
MessageBox.Show(sErrMsg)
Return False
else
'''''''''''''''''Add Payment from Invoice have Added
Dim oPayment As SAPbobsCOM.Payments
oPayment = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
oPayment.CardCode = strShop
oPayment.DocDate = Now.Date
oPayment.DocCurrency = "VND"
oPayment.CashAccount = "111100"
oPayment.CashSum = oInv.DocTotal
oPayment.Series = 0
oPayment.Remarks = "Remarks"
oPayment.Invoices.DocEntry = oInv.DocEntry
oPayment.Invoices.DocLine = 0
oPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice
oPayment.Invoices.SumApplied = oInv.DocTotal
lRetCode = oPayment.Add
If lRetCode 0 Then
oCompany.GetLastError(lErrCode, sErrMsg)
MessageBox.Show(sErrMsg)
Return False
End If
end if
end function
Add Invoice is OK! but when Add Payment it appears Error: "No matching records found (ODBC -2028)" . Help me to fix it. Thanks