cancel
Showing results for 
Search instead for 
Did you mean: 

Service Layer Invoices

carloscespedesh
Discoverer
0 Kudos

When using the Service layer, i need to create an invoice from a delivery, but placed within the line 0 sends me the error, but the other lines work fine:

"{

   "error" : {

      "code" : -10,

      "message" : {

         "lang" : "en-us",

         "value" : "No matching records found (ODBC -2028)"

      }

   }

}

"

Part of my code is this.

Dim NewLine as New DocumentLine

newLine.BaseEntry= order1.DocEntry

newLine.BaseLine= lin.LineNum

newLine.BaseType= 15 ' Object delivery


The order1 is the Document to delivery.

Accepted Solutions (0)

Answers (1)

Answers (1)

andy_bai
Advisor
Advisor
0 Kudos

I guess you may miss the CardCode or something else.

A complete payload to create an invoice based on a delivery should be like this:

POST /b1s/v1/Invoices

{

  "DocDate": "2016-02-23",

  "DocDueDate": "2016-02-23",

  "CardCode": "bp004",

  "DocumentLines": [

    {

      "BaseType": 15,

      "BaseEntry": 14,

      "BaseLine": 0,

      "TaxCode": "x1"

    },

    {

      "BaseType": 15,

      "BaseEntry": 14,

      "BaseLine": 1,

      "TaxCode": "x1"

    }

  ]

}

By the way, why use VB? Personally, C# with WCF is preferred. Sample code:


public static void AddInvoice(ServiceLayer slContext)

        {

            try

            {

                Document oInvoice = new Document();

                oInvoice.DocDate = DateTime.Today;

                oInvoice.DocDueDate = DateTime.Today;

                oInvoice.CardCode = "bp004";

                for (int i = 0; i < DOCUMENT_LINES_COUNT; ++i)

                {

                    DocumentLine line = new DocumentLine();

                    line.BaseType = 15;

                    line.BaseEntry = 14;

                    line.BaseLine = i;

                    line.TaxCode = "X1";

                    oInvoice.DocumentLines.Add(line);

                }

                slContext.AddToInvoices(oInvoice);

                slContext.SaveChanges();

            }

            catch (Exception ex)

            {

                Console.WriteLine(ex);

            }

        }