Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Failed to update invoice through econenct

Posted on by 285

I and unable to update the invoice through eocnnect, the following exception occurs  :

Error Number = 8329  Stored Procedure taSopHdrRecalc  Error Description = Tax table detail does not equal the tax amount - manual tax changes are not supported on Updates in econnect

 private static void SerializeUpdateInvoiceWithDetailsLevelTaxes(string filename)
        {
            // Create a datetime format object
            System.Globalization.DateTimeFormatInfo dateFormat = new System.Globalization.CultureInfo("en-US").DateTimeFormat;

            try
            {
                // Create an array that can hold two taSopLineIvcInsert_ItemsTaSopLineIvcInsert objects
                taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] LineItems = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[2];

                // Create a taSopLineIvcInsert_ItemsTaSopLineIvcInsert object and populate its fields
                taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();


                //Added
                salesLine.SOPNUMBE = "IVC00000000000153";
                //Added
                salesLine.UpdateIfExists = 1;
                //Added
                salesLine.LNITMSEQ = 16384;
                salesLine.ADDRESS1 = "2345 Main St.";
                salesLine.CUSTNMBR = "Custppp32ty12";
                salesLine.CITY = "Aurora";
                salesLine.SOPTYPE = 3;
                salesLine.DOCID = "INVOICE1";
                salesLine.QUANTITY = 1;
                salesLine.ITEMNMBR = "TICKET";
                salesLine.ITEMDESC = "Phone Cord - 12' White";
                salesLine.UNITPRCE = 8m;
                salesLine.XTNDPRCE = 8m;
                salesLine.LOCNCODE = "SITE1";
                salesLine.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy", dateFormat);
                salesLine.TAXAMNT = 2;
                //salesLine.LNITMSEQ = 16384;
                // Add the SOP line item object to the array
                LineItems[0] = salesLine;




                // Create a second taSopLineIvcInsert_ItemsTaSopLineIvcInsert object and populate its fields
                taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine2 = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();

                //Added
                salesLine2.SOPNUMBE = "IVC00000000000153";
                //Added
                salesLine2.UpdateIfExists = 1;
                //Added
                salesLine2.LNITMSEQ = 32768;
                salesLine2.ADDRESS1 = "2345 Main St.";
                salesLine2.CUSTNMBR = "Custppp32ty12";
                salesLine2.CITY = "Aurora";
                salesLine2.SOPTYPE = 3;
                salesLine2.DOCID = "INVOICE1";
                salesLine2.QUANTITY = 1;
                salesLine2.ITEMNMBR = "TICKET";
                salesLine2.ITEMDESC = "Phone Cord - 25' Black";
                salesLine2.UNITPRCE = 8m;
                salesLine2.XTNDPRCE = 8m;
                salesLine2.LOCNCODE = "SITE1";
                salesLine2.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy", dateFormat);
                salesLine2.TAXAMNT = 3;

                //To test
                taSopLineIvcTaxInsert_ItemsTaSopLineIvcTaxInsert linetax = new taSopLineIvcTaxInsert_ItemsTaSopLineIvcTaxInsert();
                //Added
                linetax.SOPNUMBE = "IVC00000000000153";
                linetax.LNITMSEQ = 16384;
                linetax.TAXDTLID = "TAXCODE1";
                linetax.SALESAMT = 8m;//sales amount
                linetax.STAXAMNT = 2m;//sales tax amount
                linetax.CUSTNMBR = "Custppp32ty12";
                linetax.SOPTYPE = 3;
                linetax.TDTTXSLS = 8m;//total taxatble sales
                linetax.TDTTXSLSSpecified = true;
                linetax.TXDTOTTX = 2;//total tax
                linetax.TXDTOTTXSpecified = true;
                linetax.TAXTYPE = 0;
              

                //To test
                taSopLineIvcTaxInsert_ItemsTaSopLineIvcTaxInsert linetax1 = new taSopLineIvcTaxInsert_ItemsTaSopLineIvcTaxInsert();
                //Added
                linetax1.SOPNUMBE = "IVC00000000000153";
                linetax1.LNITMSEQ = 32768;
                linetax1.TAXDTLID = "TAXCODE1";
                linetax1.SALESAMT = 8m;//sales amount
                linetax1.STAXAMNT = 3m;//sales tax amount
                linetax1.CUSTNMBR = "Custppp32ty12";
                linetax1.SOPTYPE = 3;
                linetax1.TDTTXSLS = 8m;//total taxatble sales
                linetax1.TDTTXSLSSpecified = true;
                linetax1.TXDTOTTX = 3;//total tax
                linetax1.TXDTOTTXSpecified = true;
                linetax1.TAXTYPE = 0;
                // Add the SOP line item object to the array
                LineItems[1] = salesLine2;

                // Create a taSopHdrIvcInsert object and populate its fields
                taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert();

                //Added
                salesHdr.SOPNUMBE = "IVC00000000000153";
                //Added
                salesHdr.UpdateExisting = 1;
                salesHdr.SOPTYPE = 3;
                salesHdr.DOCID = "INVOICE1";
                salesHdr.BACHNUMB = "eConnect";
                salesHdr.TAXSCHID = "TAXSC1";
                //salesHdr.FRTSCHID = "TAXSC1";
                //salesHdr.MSCSCHID = "TAXSC1";
                salesHdr.LOCNCODE = "SITE1";
                salesHdr.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy", dateFormat);
                salesHdr.CUSTNMBR = "Custppp32ty12";
                //salesHdr.CUSTNAME = "Contoso, Ltd.";
                salesHdr.ShipToName = "SITE1";
                salesHdr.ADDRESS1 = "2345 Main St.";
                //salesHdr.CNTCPRSN = "Joe Healy";
                salesHdr.FAXNUMBR = "13125550150";
                salesHdr.CITY = "Aurora";
                salesHdr.STATE = "IL";
                salesHdr.ZIPCODE = "65700";
                salesHdr.COUNTRY = "USA";
                salesHdr.SUBTOTAL = 16m;
                salesHdr.DOCAMNT = 21m;
                salesHdr.TAXAMNT = 5;
           
                //salesHdr.USINGHEADERLEVELTAXES = 0;
                salesHdr.USINGHEADERLEVELTAXES = 0;
                //salesHdr.PYMTRMID = "Net 30";
                //Added to test
                salesHdr.CREATETAXES = 0;
                // Create a eConnect SOPTransactionType schema object
                SOPTransactionType salesOrder = new SOPTransactionType();
                  
                // Populate the schema object with the SOP header and SOP line item objects
                salesOrder.taSopLineIvcInsert_Items = LineItems;
                salesOrder.taSopHdrIvcInsert = salesHdr;
                salesOrder.taSopLineIvcTaxInsert_Items = new taSopLineIvcTaxInsert_ItemsTaSopLineIvcTaxInsert[] { linetax, linetax1 };
                // Create an array that holds SOPTransactionType objects
                // Populate the array with the SOPTransactionType schema object
                SOPTransactionType[] MySopTransactionType = { salesOrder };

                // Create an eConnect XML document object and populate it
                // with the SOPTransactionType schema object
                eConnectType eConnect = new eConnectType();
                eConnect.SOPTransactionType = MySopTransactionType;

                // Create an XML serializer object
                XmlSerializer serializer = new XmlSerializer(eConnect.GetType());

                MemoryStream ms = new MemoryStream();
                // XmlTextWriter writer = new XmlTextWriter(fs, new UTF8Encoding());
                XmlTextWriter writer = new XmlTextWriter(ms, new UTF8Encoding());

                // Serialize the eConnectType object to a file using the XmlTextWriter.
                serializer.Serialize(writer, eConnect);
                //writer.Close();
                writer.Flush();
                ms.Position = 0;
                StreamReader sr = new StreamReader(ms);

                xmlString = sr.ReadToEnd();
                writer.Close();


            }
            //If an eConnect exception occurs, notify the user
            catch (eConnectException ex)
            {
                Console.Write(ex.ToString());
            }
        }

 

When we run the code, we got the exception.

Thanks.

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans