Skip to Content
author's profile photo Former Member
Former Member

Linking Invoices to Payments

I am creating invoices and payments using the DI API. I now wish to link the payment to the invoice but cannot figure this one out. Can anyone give me a pointer in the right direction? Thanks.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2005 at 05:48 AM

    Hi Greg,

    Herewith a sample where I create an invoice, then do a payment for the invoice and link them together.

    'Create the invoice: Dim oDoc As SAPbobsCOM.Documents Dim sNum As String

    'Create the invoice:        
    Dim oDoc As SAPbobsCOM.Documents        
    Dim sNum As String        
    Dim oPmt As SAPbobsCOM.Payments        
    oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices) 
    oDoc.CardCode = "C1000"    
    oDoc.DocDate = Now       
    oDoc.Lines.ItemCode = "A1000"      
    oDoc.Lines.Quantity = 6      
    oDoc.Lines.Price = 66       
    If oDoc.Add <> 0 Then         
      MessageBox.Show(oCompany.GetLastErrorDescription)     
    Else        
      MessageBox.Show("Added invoice")      
    End If    
    'Get the invoice again for reference to amounts and docnum  
    oCompany.GetNewObjectCode(sNum)    
    oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)   
    oDoc.GetByKey(sNum)     
    'Create the payment object and set properties  
    oPmt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments)   
    oPmt.Invoices.DocEntry = sNum    
    oPmt.CardCode = oDoc.CardCode   
    oPmt.DocDate = Now    
    oPmt.DocTypte = SAPbobsCOM.BoRcptTypes.rCustomer   
    oPmt.CashSum = oDoc.DocTotal     
    If oPmt.Add() <> 0 Then       
      MessageBox.Show(oCompany.GetLastErrorDescription)  
    Else           
      MessageBox.Show("Add Payment") 
    End If
    

    Hope it helps,

    Adele

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.