Hi,
I tried to post A/R invoice + Payement. At the time of payment posting I am getting the Error "Invoice is already closed or blocked".
The code is below
' A/R INVOICE POSTING
Dim oInvoice As SAPbobsCOM.Documents
oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
oInvoice.CardCode = "Test"
For i As Integer = 1 To oMatrix1.VisualRowCount
oInvoice.Lines.ItemCode = "Itm0001"
oInvoice.Lines.Quantity = 5
oInvoice.Lines.TaxCode = "VAT5"
oInvoice.Lines.UnitPrice = 100.00
oInvoice.Lines.WarehouseCode = "01"
oInvoice.Lines.Add()
Next
If oInvoice.Add() <> 0 Then
Return False
End If
'PAYEMENTS POSTING
Dim oPayment As SAPbobsCOM.Payments
oPayment = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)
Dim strInvNo As String = getSingleValue("select DocNum from [OINV] where U_Code='" & frmSalesInvoice.Items.Item("t_DocNo").Specific.Value.ToString.Trim & "'")
oPayment.CardCode = "POS"
oPayment.Invoices.DocEntry = UInt64.Parse(strInvNo.ToString.Trim)
oPayment.CashSum =
If oPayment.Add() <> 0 Then
LogInfo("Payments posting Failed : " & oCompany.GetLastErrorDescription, "E")
Return False
Else
Return True
End If
End If
Please help me to solve the issue
Thanks in advance