📚 SAP Business One SDK Help

Create Invoice with Down Payment
See Also
Private Sub CreateInvoice()
    Dim oInvoice As SAPbobsCOM.Documents

    ' Add invoice
    oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
    oInvoice.CardCode = Card Code With DownPayment Invoice
    oInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
    oInvoice.DocDate = Document Date
    oInvoice.Lines.ItemCode = Some Item Code
    oInvoice.Lines.Price = Item Price
    oInvoice.Lines.Quantity = Quantity
    oInvoice.Lines.TaxCode = Tax Code If needed
    oInvoice.Lines.VatGroup = Vat Code If needed

    ' Add the Invoice with Down Payment
    Dim dpToDraw As SAPbobsCOM.DownPaymentsToDraw

    dpToDraw = oInvoice.DownPaymentsToDraw

    'oDPM is an object that contains an existing DownPayment Invoice
    dpToDraw.AmountToDraw = oDPM.DownPaymentAmount

    lRetCode = oInvoice.Add()

    If lRetCode <> 0 Then
            oCompany.GetLastError(lErrCode, sErrMsg)
            MsgBox(lErrCode & " " & sErrMsg) ' Display error message
    Else

            MsgBox("Invoice with Downpayment created, the process of using a downpayment invoice succeeded", MsgBoxStyle.Information, "Invoice Paid")

            cmdInv.Enabled = False

     End If

End Sub