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

How to make the connection between a sale order and an invoice in SDK

Hi,

Im trying to make the connection between a sales order and an invoice using the SDK.

Here is how i create each of them:

Invoice:

public int SalesInvoiceInternalSave(string buisnesspartnerCardCode, DateTime dueDate, double discountPercent, string id, IList<InternalItem> items, ref int invoiceId)

{

int res = 0;

SAPbobsCOM.Documents invoice_entry = (SAPbobsCOM.Documents)Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

invoice_entry.CardCode = buisnesspartnerCardCode;

invoice_entry.DocDueDate = dueDate;

invoice_entry.DiscountPercent = discountPercent;

invoice_entry.Reference2 = id;

foreach (InternalItem item in items)

{

invoice_entry.Lines.WarehouseCode = item.Shopid;

invoice_entry.Lines.ItemCode = item.Code;

invoice_entry.Lines.ItemDescription = item.Name;

invoice_entry.Lines.Quantity = item.Quantity;

invoice_entry.Lines.UnitPrice = item.Price;

invoice_entry.Lines.Add();

}

res = invoice_entry.Add();

return res;

}

Sales order:

public Boolean SalesOrderInternalSave(string orderId, string buisnesspartnerCardCode, DateTime dueDate, IList<InternalItem> items)

{

SAPbobsCOM.Documents order_entry = (SAPbobsCOM.Documents)Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);

order_entry.CardCode = buisnesspartnerCardCode;

order_entry.DocDueDate = dueDate;

foreach (InternalItem item in items)

{

order_entry.Lines.WarehouseCode = item.Shopid;

order_entry.Lines.ItemCode = item.Code;

order_entry.Lines.ItemDescription = item.Name;

order_entry.Lines.Quantity = item.Quantity;

order_entry.Lines.UnitPrice = item.Price;

order_entry.Lines.Add();

}

int res = order_entry.Add();

return res == 0;

}

What do i need to change to get the connection between the two of them?

And how do you insert a amount (not percent) discount into an invoice?

Regards,

Torben

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 10:19 AM

    Hi,

    Add the sale order, then add the invoice. and while adding the invoice please add the following details to the invoce documen

    invoice_entry.Lines.BaseEntry = 'Doc entry of the newly created SO
    invoice_entry.Lines.BaseLine = 'Line No of the SO
    invoice_entry.Lines.BaseType = 17 'For sales order document type.

    Hope it helps,

    Vasu Natari.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 12:12 PM

    Q: And how do you insert a amount (not percent) discount into an invoice?

    There is no way now how to achieve it - this field doesnt works in DI for no document object. There 3 ways how to achieve it:

    - create invoice through UI

    or

    - add as a row one discount item with the price you want

    or

    - calculate the discount to each row in invoice lines

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 12:19 PM

    That was it, thanks a lot.

    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.